Skip to content

Commit

Permalink
Merge pull request #422 from shawakash/client_set
Browse files Browse the repository at this point in the history
feat: adds a connections table to store the the blockchain connections data
  • Loading branch information
shawakash authored Apr 18, 2024
2 parents 3c47535 + 3db2729 commit ef2f0d5
Show file tree
Hide file tree
Showing 19 changed files with 4,863 additions and 557 deletions.
5 changes: 5 additions & 0 deletions backend/backend-common/src/db/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,11 @@ export const createBaseClient = async (
lastname,
mobile: mobile || null,
password: hashPassword,
client_setting: {
data: {
lang: "en",
}
}
},
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
table:
name: connections
schema: public
configuration:
column_config:
btc_network:
custom_name: btcNetwork
client_id:
custom_name: clientId
client_settings_id:
custom_name: clientSettingsId
created_at:
custom_name: createdAt
eth_network:
custom_name: ethNetwork
sol_network:
custom_name: solNetwork
updated_at:
custom_name: updatedAt
custom_column_names:
btc_network: btcNetwork
client_id: clientId
client_settings_id: clientSettingsId
created_at: createdAt
eth_network: ethNetwork
sol_network: solNetwork
updated_at: updatedAt
custom_root_fields: {}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- "!include public_chat.yaml"
- "!include public_client.yaml"
- "!include public_client_settings.yaml"
- "!include public_connections.yaml"
- "!include public_eth.yaml"
- "!include public_friendship.yaml"
- "!include public_notif_to_subs.yaml"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE "public"."client_settings" ALTER COLUMN "prefered_explorer" drop default;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alter table "public"."client_settings" alter column "prefered_explorer" set default 'solscan';
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
alter table "public"."client_settings" drop constraint "client_settings_client_id_fkey",
add constraint "client_settings_client_id_fkey"
foreign key ("client_id")
references "public"."client"
("id") on update no action on delete no action;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
alter table "public"."client_settings" drop constraint "client_settings_client_id_fkey",
add constraint "client_settings_client_id_fkey"
foreign key ("client_id")
references "public"."client"
("id") on update set default on delete no action;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP TABLE "public"."connections";
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
CREATE TABLE "public"."connections" ("id" uuid NOT NULL DEFAULT gen_random_uuid(), "client_id" uuid NOT NULL, "sol_network" text NOT NULL DEFAULT 'devnet', "eth_network" text NOT NULL DEFAULT 'sepolia', "btc_network" text NOT NULL, "client_settings_id" uuid NOT NULL, "created_at" timestamptz NOT NULL DEFAULT now(), "updated_at" timestamptz NOT NULL DEFAULT now(), PRIMARY KEY ("id") , FOREIGN KEY ("client_id") REFERENCES "public"."client"("id") ON UPDATE no action ON DELETE no action, FOREIGN KEY ("client_settings_id") REFERENCES "public"."client_settings"("id") ON UPDATE no action ON DELETE no action, UNIQUE ("id"), UNIQUE ("client_settings_id"), UNIQUE ("client_id"));COMMENT ON TABLE "public"."connections" IS E'blockchains connections metadata';
CREATE OR REPLACE FUNCTION "public"."set_current_timestamp_updated_at"()
RETURNS TRIGGER AS $$
DECLARE
_new record;
BEGIN
_new := NEW;
_new."updated_at" = NOW();
RETURN _new;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER "set_public_connections_updated_at"
BEFORE UPDATE ON "public"."connections"
FOR EACH ROW
EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"();
COMMENT ON TRIGGER "set_public_connections_updated_at" ON "public"."connections"
IS 'trigger to set value of column "updated_at" to current timestamp on row update';
CREATE EXTENSION IF NOT EXISTS pgcrypto;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE "public"."connections" ALTER COLUMN "btc_network" drop default;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alter table "public"."connections" alter column "btc_network" set default 'testnet';
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
alter table "public"."connections" drop constraint "connections_client_id_fkey",
add constraint "connections_client_id_fkey"
foreign key ("client_id")
references "public"."client"
("id") on update no action on delete no action;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
alter table "public"."connections" drop constraint "connections_client_id_fkey",
add constraint "connections_client_id_fkey"
foreign key ("client_id")
references "public"."client"
("id") on update set default on delete no action;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
alter table "public"."connections" drop constraint "connections_client_settings_id_fkey",
add constraint "connections_client_settings_id_fkey"
foreign key ("client_settings_id")
references "public"."client_settings"
("id") on update no action on delete no action;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
alter table "public"."connections" drop constraint "connections_client_settings_id_fkey",
add constraint "connections_client_settings_id_fkey"
foreign key ("client_settings_id")
references "public"."client_settings"
("id") on update set default on delete no action;
Loading

0 comments on commit ef2f0d5

Please sign in to comment.