Skip to content

Commit

Permalink
feat: update admin codes for new tables
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-bisonai committed Apr 26, 2024
1 parent 9c401c0 commit c203f35
Show file tree
Hide file tree
Showing 27 changed files with 255 additions and 1,618 deletions.
2 changes: 1 addition & 1 deletion node/cmd/node/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func main() {
return
}

syncUrl := "http://localhost:" + port + "/api/v1/sync"
syncUrl := "http://localhost:" + port + "/api/v1/config/sync"
_, err = http.Post(syncUrl, "application/json", nil)
if err != nil {
log.Error().Err(err).Msg("Failed to sync from orakl config")
Expand Down
15 changes: 15 additions & 0 deletions node/migrations/000019_feeds_update.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
DO $$
BEGIN
IF EXISTS(SELECT 1 FROM feeds) THEN
DELETE FROM feeds;
END IF;

IF EXISTS(SELECT 1 FROM information_schema.columns WHERE table_name = 'feeds' AND column_name = 'config_id') THEN
ALTER TABLE feeds DROP COLUMN config_id;
END IF;

IF NOT EXISTS(SELECT 1 FROM information_schema.columns WHERE table_name = 'feeds' AND column_name = 'adapter_id') THEN
ALTER TABLE feeds ADD COLUMN adapter_id INT8 NOT NULL;
ALTER TABLE feeds ADD CONSTRAINT feeds_adapter_id_fkey FOREIGN KEY(adapter_id) REFERENCES adapters(id) ON DELETE CASCADE;
END IF;
END $$;
15 changes: 15 additions & 0 deletions node/migrations/000019_feeds_update.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
DO $$
BEGIN
IF EXISTS(SELECT 1 FROM feeds) THEN
DELETE FROM feeds;
END IF;

IF EXISTS(SELECT 1 FROM information_schema.columns WHERE table_name = 'feeds' AND column_name = 'adapter_id') THEN
ALTER TABLE feeds DROP COLUMN adapter_id;
END IF;

IF NOT EXISTS(SELECT 1 FROM information_schema.columns WHERE table_name = 'feeds' AND column_name = 'config_id') THEN
ALTER TABLE feeds ADD COLUMN config_id INT8 NOT NULL;
ALTER TABLE feeds ADD CONSTRAINT feeds_config_id_fkey FOREIGN KEY(config_id) REFERENCES configs(id) ON DELETE CASCADE;
END IF;
END $$;
20 changes: 20 additions & 0 deletions node/migrations/000020_remove_tables.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
CREATE TABLE IF NOT EXISTS adapters (
id SERIAL PRIMARY KEY,
name text NOT NULL,
active bool NOT NULL DEFAULT true,
interval int4 NOT NULL DEFAULT 2000,
);

CREATE TABLE IF NOT EXISTS aggregators (
id SERIAL PRIMARY KEY,
name test NOT NULL,
active bool NOT NULL DEFAULT true,
interval int4 NOT NULL DEFAULT 5000,
)

CREATE TABLE IF NOT EXISTS submission_addresses (
id SERIAL PRIMARY KEY,
name text NOT NULL,
address text NOT NULL,
interval int4
)
3 changes: 3 additions & 0 deletions node/migrations/000020_remove_tables.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DROP TABLE IF EXISTS adapters;
DROP TABLE IF EXISTS aggregators;
DROP TABLE IF EXISTS submission_addresses;
301 changes: 0 additions & 301 deletions node/pkg/admin/adapter/controller.go

This file was deleted.

Loading

0 comments on commit c203f35

Please sign in to comment.