Skip to content
This repository has been archived by the owner on Jan 9, 2024. It is now read-only.

Commit

Permalink
chore: minor consistency related updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeplotean committed Nov 24, 2023
1 parent dc50857 commit c785322
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 93 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand All @@ -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
);
Expand All @@ -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
);
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand All @@ -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
);
Expand All @@ -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
);
Expand All @@ -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);
CREATE UNIQUE INDEX "credentials_cid" ON "credentials"("cid");
30 changes: 15 additions & 15 deletions src/main/resources/db/postgres/V5__create_table_issuers.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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);
CREATE UNIQUE INDEX "account_issuers_account_issuer" ON "account_issuers"("account", "issuer");

0 comments on commit c785322

Please sign in to comment.