From c78532241b820bca7b47d94fd076b3b99b88f1aa Mon Sep 17 00:00:00 2001 From: mikeplotean Date: Sat, 25 Nov 2023 00:19:58 +0200 Subject: [PATCH] chore: minor consistency related updates --- ...accountwallet_walletoperationhistories.sql | 72 ++++++++-------- ...untdids_accountkeys_accountcredentials.sql | 84 +++++++++---------- .../db/postgres/V5__create_table_issuers.sql | 30 +++---- 3 files changed, 93 insertions(+), 93 deletions(-) diff --git a/src/main/resources/db/postgres/V1__create_tables_account_email_wallet_accountwallet_walletoperationhistories.sql b/src/main/resources/db/postgres/V1__create_tables_account_email_wallet_accountwallet_walletoperationhistories.sql index 67d5f1e..0e0818d 100644 --- a/src/main/resources/db/postgres/V1__create_tables_account_email_wallet_accountwallet_walletoperationhistories.sql +++ b/src/main/resources/db/postgres/V1__create_tables_account_email_wallet_accountwallet_walletoperationhistories.sql @@ -3,40 +3,40 @@ -- ---------------------------------- CREATE TABLE IF NOT EXISTS "emails" ( - "id" uuid NOT NULL, - "email" text COLLATE pg_catalog."default" NOT NULL, - "password" text COLLATE pg_catalog."default" NOT NULL, - CONSTRAINT "emails_pkey" PRIMARY KEY (id), - CONSTRAINT email UNIQUE (email) + "id" UUID NOT NULL, + "email" TEXT COLLATE pg_catalog."default" NOT NULL, + "password" TEXT COLLATE pg_catalog."default" NOT NULL, + CONSTRAINT "emails_pkey" PRIMARY KEY ("id"), + CONSTRAINT "email" UNIQUE ("email") ); -- ---------------------------------- -- Wallets table -- ---------------------------------- CREATE TABLE IF NOT EXISTS "wallets" ( - "id" uuid NOT NULL, - "address" text COLLATE pg_catalog."default" NOT NULL, - "ecosystem" text COLLATE pg_catalog."default" NOT NULL, - CONSTRAINT wallets_pkey PRIMARY KEY (id), - CONSTRAINT address UNIQUE (address) + "id" UUID NOT NULL, + "address" TEXT COLLATE pg_catalog."default" NOT NULL, + "ecosystem" TEXT COLLATE pg_catalog."default" NOT NULL, + CONSTRAINT "wallets_pkey" PRIMARY KEY ("id"), + CONSTRAINT "address" UNIQUE ("address") ); -- ---------------------------------- -- Accounts table -- ---------------------------------- CREATE TABLE IF NOT EXISTS "accounts" ( - "id" uuid NOT NULL, - "email" uuid NULL, - "wallet" uuid NULL, - CONSTRAINT accounts_pkey PRIMARY KEY (id), - CONSTRAINT accounts_email_wallet_unique UNIQUE (email, wallet) - INCLUDE(email, wallet), - CONSTRAINT account_email_fk FOREIGN KEY (email) - REFERENCES public.emails (id) MATCH SIMPLE + "id" UUID NOT NULL, + "email" UUID NULL, + "wallet" UUID NULL, + CONSTRAINT "accounts_pkey" PRIMARY KEY ("id"), + CONSTRAINT "accounts_email_wallet_unique" UNIQUE ("email", "wallet") + INCLUDE("email", "wallet"), + CONSTRAINT "account_email_fk" FOREIGN KEY ("email") + REFERENCES "emails" ("id") MATCH SIMPLE ON UPDATE CASCADE ON DELETE CASCADE, - CONSTRAINT account_wallet_fk FOREIGN KEY (wallet) - REFERENCES public.wallets (id) MATCH SIMPLE + CONSTRAINT "account_wallet_fk" FOREIGN KEY ("wallet") + REFERENCES "wallets" ("id") MATCH SIMPLE ON UPDATE CASCADE ON DELETE CASCADE ); @@ -45,16 +45,16 @@ CREATE TABLE IF NOT EXISTS "accounts" -- ---------------------------------- CREATE TABLE IF NOT EXISTS "account_wallets" ( - "id" uuid NOT NULL, - "account" uuid NOT NULL, - "wallet" uuid NOT NULL, - CONSTRAINT account_wallets_pkey PRIMARY KEY (id), - CONSTRAINT account_wallets_account_fk FOREIGN KEY (account) - REFERENCES "accounts" (id) MATCH SIMPLE + "id" UUID NOT NULL, + "account" UUID NOT NULL, + "wallet" UUID NOT NULL, + CONSTRAINT "account_wallets_pkey" PRIMARY KEY ("id"), + CONSTRAINT "account_wallets_account_fk" FOREIGN KEY ("account") + REFERENCES "accounts" ("id") MATCH SIMPLE ON UPDATE CASCADE ON DELETE CASCADE, - CONSTRAINT account_wallets_wallet_fk FOREIGN KEY (wallet) - REFERENCES "wallets" (id) MATCH SIMPLE + CONSTRAINT "account_wallets_wallet_fk" FOREIGN KEY ("wallet") + REFERENCES "wallets" ("id") MATCH SIMPLE ON UPDATE CASCADE ON DELETE CASCADE ); @@ -63,14 +63,14 @@ CREATE TABLE IF NOT EXISTS "account_wallets" -- ---------------------------------- CREATE TABLE IF NOT EXISTS "wallet_operation_histories" ( - "id" uuid NOT NULL, - "account" uuid NOT NULL, - "timestamp" text COLLATE pg_catalog."default" NOT NULL, - "operation" text COLLATE pg_catalog."default" NOT NULL, - "data" text COLLATE pg_catalog."default" NOT NULL, - CONSTRAINT wallet_operation_histories_pkey PRIMARY KEY (id), - CONSTRAINT wallet_operation_histories_account_fk FOREIGN KEY (account) - REFERENCES "accounts" (id) MATCH SIMPLE + "id" UUID NOT NULL, + "account" UUID NOT NULL, + "timestamp" TEXT COLLATE pg_catalog."default" NOT NULL, + "operation" TEXT COLLATE pg_catalog."default" NOT NULL, + "data" TEXT COLLATE pg_catalog."default" NOT NULL, + CONSTRAINT "wallet_operation_histories_pkey" PRIMARY KEY ("id"), + CONSTRAINT "wallet_operation_histories_account_fk" FOREIGN KEY ("account") + REFERENCES "accounts" ("id") MATCH SIMPLE ON UPDATE CASCADE ON DELETE CASCADE ); \ No newline at end of file diff --git a/src/main/resources/db/postgres/V4__create_tables_keys_dids_credentials_accountdids_accountkeys_accountcredentials.sql b/src/main/resources/db/postgres/V4__create_tables_keys_dids_credentials_accountdids_accountkeys_accountcredentials.sql index 6fc0ff4..bffb2ec 100644 --- a/src/main/resources/db/postgres/V4__create_tables_keys_dids_credentials_accountdids_accountkeys_accountcredentials.sql +++ b/src/main/resources/db/postgres/V4__create_tables_keys_dids_credentials_accountdids_accountkeys_accountcredentials.sql @@ -3,23 +3,23 @@ -- ---------------------------------- CREATE TABLE IF NOT EXISTS "keys" ( - "id" uuid NOT NULL, - "kid" text COLLATE pg_catalog."default" NOT NULL, - "document" text COLLATE pg_catalog."default" NOT NULL, - CONSTRAINT "keys_pkey" PRIMARY KEY (id) + "id" UUID NOT NULL, + "kid" TEXT COLLATE pg_catalog."default" NOT NULL, + "document" TEXT COLLATE pg_catalog."default" NOT NULL, + CONSTRAINT "keys_pkey" PRIMARY KEY ("id") ); -- ---------------------------------- -- Dids table -- ---------------------------------- CREATE TABLE IF NOT EXISTS "dids" ( - "id" uuid NOT NULL, - "did" text COLLATE pg_catalog."default" NOT NULL, - "document" text COLLATE pg_catalog."default" NOT NULL, - "key" uuid NOT NULL, - CONSTRAINT "dids_pkey" PRIMARY KEY (id), - CONSTRAINT did_key_fk FOREIGN KEY (key) - REFERENCES public.keys (id) MATCH SIMPLE + "id" UUID NOT NULL, + "did" TEXT COLLATE pg_catalog."default" NOT NULL, + "document" TEXT COLLATE pg_catalog."default" NOT NULL, + "key" UUID NOT NULL, + CONSTRAINT "dids_pkey" PRIMARY KEY ("id"), + CONSTRAINT "did_key_fk" FOREIGN KEY ("key") + REFERENCES "keys" ("id") MATCH SIMPLE ON UPDATE CASCADE ON DELETE CASCADE ); @@ -28,26 +28,26 @@ CREATE TABLE IF NOT EXISTS "dids" -- ---------------------------------- CREATE TABLE IF NOT EXISTS "credentials" ( - "id" uuid NOT NULL, - "cid" text COLLATE pg_catalog."default" NOT NULL, - "document" text COLLATE pg_catalog."default" NOT NULL, - CONSTRAINT "credentials_pkey" PRIMARY KEY (id) + "id" UUID NOT NULL, + "cid" TEXT COLLATE pg_catalog."default" NOT NULL, + "document" TEXT COLLATE pg_catalog."default" NOT NULL, + CONSTRAINT "credentials_pkey" PRIMARY KEY ("id") ); -- ---------------------------------- -- AccountKeys table -- ---------------------------------- CREATE TABLE IF NOT EXISTS "account_keys" ( - "id" uuid NOT NULL, - "account" uuid NOT NULL, - "key" uuid NOT NULL, - CONSTRAINT "account_keys_pkey" PRIMARY KEY (id), - CONSTRAINT account_keys_account_fk FOREIGN KEY (account) - REFERENCES public.accounts (id) MATCH SIMPLE + "id" UUID NOT NULL, + "account" UUID NOT NULL, + "key" UUID NOT NULL, + CONSTRAINT "account_keys_pkey" PRIMARY KEY ("id"), + CONSTRAINT "account_keys_account_fk" FOREIGN KEY ("account") + REFERENCES "accounts" ("id") MATCH SIMPLE ON UPDATE CASCADE ON DELETE CASCADE, - CONSTRAINT account_keys_key_fk FOREIGN KEY (key) - REFERENCES public.keys (id) MATCH SIMPLE + CONSTRAINT "account_keys_key_fk" FOREIGN KEY (key) + REFERENCES "keys" ("id") MATCH SIMPLE ON UPDATE CASCADE ON DELETE CASCADE ); @@ -56,18 +56,18 @@ CREATE TABLE IF NOT EXISTS "account_keys" -- ---------------------------------- CREATE TABLE IF NOT EXISTS "account_dids" ( - "id" uuid NOT NULL, - "account" uuid NOT NULL, - "did" uuid NOT NULL, - "alias" text COLLATE pg_catalog."default" NOT NULL, + "id" UUID NOT NULL, + "account" UUID NOT NULL, + "did" UUID NOT NULL, + "alias" TEXT COLLATE pg_catalog."default" NOT NULL, "default" BOOLEAN NOT NULL DEFAULT FALSE, - CONSTRAINT "account_dids_pkey" PRIMARY KEY (id), - CONSTRAINT account_dids_account_fk FOREIGN KEY (account) - REFERENCES public.accounts (id) MATCH SIMPLE + CONSTRAINT "account_dids_pkey" PRIMARY KEY ("id"), + CONSTRAINT "account_dids_account_fk" FOREIGN KEY ("account") + REFERENCES "accounts" ("id") MATCH SIMPLE ON UPDATE CASCADE ON DELETE CASCADE, - CONSTRAINT account_dids_did_fk FOREIGN KEY (did) - REFERENCES public.dids (id) MATCH SIMPLE + CONSTRAINT "account_dids_did_fk" FOREIGN KEY ("did") + REFERENCES "dids" ("id") MATCH SIMPLE ON UPDATE CASCADE ON DELETE CASCADE ); @@ -76,28 +76,28 @@ CREATE TABLE IF NOT EXISTS "account_dids" -- ---------------------------------- CREATE TABLE IF NOT EXISTS "account_credentials" ( - "id" uuid NOT NULL, - "account" uuid NOT NULL, - "credential" uuid NOT NULL, + "id" UUID NOT NULL, + "account" UUID NOT NULL, + "credential" UUID NOT NULL, CONSTRAINT "account_credentials_pkey" PRIMARY KEY (id), - CONSTRAINT account_credentials_account_fk FOREIGN KEY (account) - REFERENCES public.accounts (id) MATCH SIMPLE + CONSTRAINT "account_credentials_account_fk" FOREIGN KEY ("account") + REFERENCES "accounts" ("id") MATCH SIMPLE ON UPDATE CASCADE ON DELETE CASCADE, - CONSTRAINT account_credentials_credential_fk FOREIGN KEY (credential) - REFERENCES public.credentials (id) MATCH SIMPLE + CONSTRAINT "account_credentials_credential_fk" FOREIGN KEY ("credential") + REFERENCES "credentials" ("id") MATCH SIMPLE ON UPDATE CASCADE ON DELETE CASCADE ); -- ---------------------------------- -- Keys index -- ---------------------------------- -CREATE UNIQUE INDEX keys_kid ON keys(kid); +CREATE UNIQUE INDEX "keys_kid" ON "keys"("kid"); -- ---------------------------------- -- Dids index -- ---------------------------------- -CREATE UNIQUE INDEX dids_did ON dids(did); +CREATE UNIQUE INDEX "dids_did" ON "dids"("did"); -- ---------------------------------- -- Credentials index -- ---------------------------------- -CREATE UNIQUE INDEX credentials_cid ON credentials(cid); \ No newline at end of file +CREATE UNIQUE INDEX "credentials_cid" ON "credentials"("cid"); \ No newline at end of file diff --git a/src/main/resources/db/postgres/V5__create_table_issuers.sql b/src/main/resources/db/postgres/V5__create_table_issuers.sql index b25c4d4..1cc38eb 100644 --- a/src/main/resources/db/postgres/V5__create_table_issuers.sql +++ b/src/main/resources/db/postgres/V5__create_table_issuers.sql @@ -3,32 +3,32 @@ -- ---------------------------------- CREATE TABLE IF NOT EXISTS "issuers" ( - "id" uuid NOT NULL, - "name" text COLLATE pg_catalog."default" NOT NULL, - "description" text COLLATE pg_catalog."default" NOT NULL, - "ui" text COLLATE pg_catalog."default" NOT NULL, - "configuration" text COLLATE pg_catalog."default" NOT NULL, - CONSTRAINT "issuers_pkey" PRIMARY KEY (id) + "id" UUID NOT NULL, + "name" TEXT COLLATE pg_catalog."default" NOT NULL, + "description" TEXT COLLATE pg_catalog."default" NOT NULL, + "ui" TEXT COLLATE pg_catalog."default" NOT NULL, + "configuration" TEXT COLLATE pg_catalog."default" NOT NULL, + CONSTRAINT "issuers_pkey" PRIMARY KEY ("id") ); -- ---------------------------------- -- AccountIssuers table -- ---------------------------------- CREATE TABLE IF NOT EXISTS "account_issuers" ( - "id" uuid NOT NULL, - "account" uuid NOT NULL, - "issuer" uuid NOT NULL, - CONSTRAINT "account_issuers_pkey" PRIMARY KEY (id), - CONSTRAINT account_issuers_account_fk FOREIGN KEY (account) - REFERENCES public.accounts (id) MATCH SIMPLE + "id" UUID NOT NULL, + "account" UUID NOT NULL, + "issuer" UUID NOT NULL, + CONSTRAINT "account_issuers_pkey" PRIMARY KEY ("id"), + CONSTRAINT "account_issuers_account_fk" FOREIGN KEY ("account") + REFERENCES "accounts" ("id") MATCH SIMPLE ON UPDATE CASCADE ON DELETE CASCADE, - CONSTRAINT account_issuers_issuer_fk FOREIGN KEY (issuer) - REFERENCES public.issuers (id) MATCH SIMPLE + CONSTRAINT "account_issuers_issuer_fk" FOREIGN KEY (issuer) + REFERENCES "issuers" ("id") MATCH SIMPLE ON UPDATE CASCADE ON DELETE CASCADE ); -- ---------------------------------- -- AccountIssuers unique index -- ---------------------------------- -CREATE UNIQUE INDEX account_issuers_account_issuer ON account_issuers(account, issuer); \ No newline at end of file +CREATE UNIQUE INDEX "account_issuers_account_issuer" ON "account_issuers"("account", "issuer"); \ No newline at end of file