This repository has been archived by the owner on Jan 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Database schema update (postgres) * Add docker-compose options for Postgres DB # Conflicts: # docker-compose/docker-compose.yaml * chore: minor consistency related updates --------- Co-authored-by: Happy2C0de <[email protected]>
- Loading branch information
1 parent
a1e314d
commit ebf80a2
Showing
7 changed files
with
201 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
# database = "db.postgres" | ||
database = "db.sqlite" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
hikariDataSource { | ||
jdbcUrl = "jdbc:postgresql://postgresdb:5432/postgres" | ||
driverClassName = "org.postgresql.Driver" | ||
username = "postgres" | ||
password = "secret" | ||
transactionIsolation = "TRANSACTION_SERIALIZABLE" | ||
maximumPoolSize = 5 | ||
autoCommit = false | ||
dataSource { | ||
journalMode = WAL | ||
fullColumnNames = false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
...es/V4__create_tables_keys_dids_credentials_accountdids_accountkeys_accountcredentials.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
-- ---------------------------------- | ||
-- Keys table | ||
-- ---------------------------------- | ||
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") | ||
); | ||
-- ---------------------------------- | ||
-- 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 "keys" ("id") MATCH SIMPLE | ||
ON UPDATE CASCADE | ||
ON DELETE CASCADE | ||
); | ||
-- ---------------------------------- | ||
-- Credentials table | ||
-- ---------------------------------- | ||
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") | ||
); | ||
-- ---------------------------------- | ||
-- 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 "accounts" ("id") MATCH SIMPLE | ||
ON UPDATE CASCADE | ||
ON DELETE CASCADE, | ||
CONSTRAINT "account_keys_key_fk" FOREIGN KEY (key) | ||
REFERENCES "keys" ("id") MATCH SIMPLE | ||
ON UPDATE CASCADE | ||
ON DELETE CASCADE | ||
); | ||
-- ---------------------------------- | ||
-- AccountDids table | ||
-- ---------------------------------- | ||
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, | ||
"default" BOOLEAN NOT NULL DEFAULT FALSE, | ||
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 "dids" ("id") MATCH SIMPLE | ||
ON UPDATE CASCADE | ||
ON DELETE CASCADE | ||
); | ||
-- ---------------------------------- | ||
-- AccountCredentials table | ||
-- ---------------------------------- | ||
CREATE TABLE IF NOT EXISTS "account_credentials" | ||
( | ||
"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 "accounts" ("id") MATCH SIMPLE | ||
ON UPDATE CASCADE | ||
ON DELETE CASCADE, | ||
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"); | ||
-- ---------------------------------- | ||
-- Dids index | ||
-- ---------------------------------- | ||
CREATE UNIQUE INDEX "dids_did" ON "dids"("did"); | ||
-- ---------------------------------- | ||
-- Credentials index | ||
-- ---------------------------------- | ||
CREATE UNIQUE INDEX "credentials_cid" ON "credentials"("cid"); |
34 changes: 34 additions & 0 deletions
34
src/main/resources/db/postgres/V5__create_table_issuers.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
-- ---------------------------------- | ||
-- Issuers table | ||
-- ---------------------------------- | ||
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") | ||
); | ||
-- ---------------------------------- | ||
-- 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 "accounts" ("id") MATCH SIMPLE | ||
ON UPDATE CASCADE | ||
ON DELETE CASCADE, | ||
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"); |
10 changes: 10 additions & 0 deletions
10
src/main/resources/db/postgres/V6__insert_default_issuer_for_accounts.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
-- ---------------------------------- | ||
-- Insert issuers table | ||
-- ---------------------------------- | ||
INSERT INTO public."issuers" ("id", "name", "description", "ui", "configuration") | ||
VALUES ('6B638061-E4C6-4636-B4E4-F4BE2FCA582C'::UUID, 'walt.id', 'walt.id issuer portal', 'https://portal.walt.id/credentials?ids=', 'https://issuer.portal.walt.id/.well-known/openid-credential-issuer'); | ||
-- ---------------------------------- | ||
-- Insert account-issuers table | ||
-- ---------------------------------- | ||
INSERT INTO public."account_issuers" ("id", "account", "issuer") | ||
VALUES ('3FAD4023-9E97-4DD0-8B42-9471517757EF'::UUID, 'C59A7223-BF89-A04A-97B2-7C4F121F83B1', '6B638061-E4C6-4636-B4E4-F4BE2FCA582C'); |