From 532af343ba61eb554becf3779c395015bab8f819 Mon Sep 17 00:00:00 2001 From: mikeplotean <101570226+mikeplotean@users.noreply.github.com> Date: Wed, 15 Nov 2023 13:48:17 +0200 Subject: [PATCH 1/3] chore: hide import issuer button (#67) --- web/src/pages/settings/issuers/index.vue | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/web/src/pages/settings/issuers/index.vue b/web/src/pages/settings/issuers/index.vue index bddf926..5d8cfd5 100644 --- a/web/src/pages/settings/issuers/index.vue +++ b/web/src/pages/settings/issuers/index.vue @@ -3,14 +3,15 @@

Your issuers:

-
+ +
From a1e314d6ca2685841b04b3204467e877d0a612a5 Mon Sep 17 00:00:00 2001 From: mikeplotean <101570226+mikeplotean@users.noreply.github.com> Date: Thu, 16 Nov 2023 13:39:49 +0200 Subject: [PATCH 2/3] chore: updated docker-package, readme (#69) --- docker-compose/.env | 7 +-- docker-compose/docker-compose.yaml | 48 +++++++++++-------- docker-compose/ingress.conf | 36 ++++++++------ .../issuer/config/issuer-service.conf | 1 + docker-compose/issuer/config/web.conf | 2 + docker-compose/readme.md | 14 +++--- .../verifier/config/verifier-service.conf | 1 + docker-compose/verifier/config/web.conf | 2 + .../walletkit/config/issuer-config.json | 25 ---------- .../walletkit/config/verifier-config.json | 13 ----- .../walletkit/config/wallet-config.json | 11 ----- 11 files changed, 68 insertions(+), 92 deletions(-) create mode 100644 docker-compose/issuer/config/issuer-service.conf create mode 100644 docker-compose/issuer/config/web.conf create mode 100644 docker-compose/verifier/config/verifier-service.conf create mode 100644 docker-compose/verifier/config/web.conf delete mode 100644 docker-compose/walletkit/config/issuer-config.json delete mode 100644 docker-compose/walletkit/config/verifier-config.json delete mode 100644 docker-compose/walletkit/config/wallet-config.json diff --git a/docker-compose/.env b/docker-compose/.env index 9780d46..1be4d51 100644 --- a/docker-compose/.env +++ b/docker-compose/.env @@ -1,6 +1,7 @@ -WALLETKIT_PORT=7000 +WALLET_FRONTEND_PORT=3000 +WALLET_BACKEND_PORT=4545 +WEB_PORTAL_PORT=4000 +VC_REPO_PORT=5000 ISSUER_PORT=8000 VERIFIER_PORT=9000 -WALLET_BACKEND_PORT=4545 -WALLET_FRONTEND_PORT=3000 HOSTNAME=host.docker.internal \ No newline at end of file diff --git a/docker-compose/docker-compose.yaml b/docker-compose/docker-compose.yaml index c0ad7cb..ae02e4b 100644 --- a/docker-compose/docker-compose.yaml +++ b/docker-compose/docker-compose.yaml @@ -1,17 +1,4 @@ services: - walletkit: - image: waltid/walletkit:latest # backend docker image - command: - - run - environment: - WALTID_DATA_ROOT: /waltid-walletkit/data-root - WALTID_WALLET_BACKEND_BIND_ADDRESS: 0.0.0.0 - WALTID_WALLET_BACKEND_PORT: "$WALLETKIT_PORT" - EXTERNAL_HOSTNAME: $HOSTNAME - volumes: - - ./walletkit:/waltid-walletkit/data-root # data store volume incl. config files. - extra_hosts: - - "$HOSTNAME:host-gateway" wallet-backend: image: waltid/wallet-backend:latest volumes: @@ -20,11 +7,24 @@ services: wallet-frontend: image: waltid/wallet-frontend:latest environment: - NUXT_PUBLIC_ISSUER_URL: "http://localhost:$ISSUER_PORT" - issuer-portal: - image: waltid/ssikit-issuer-portal:latest - verifier-portal: - image: waltid/ssikit-verifier-portal:latest + NUXT_PUBLIC_ISSUER_CALLBACK_URL: "http://localhost:$WALLET_FRONTEND_PORT" + issuer: + image: waltid/issuer:latest + volumes: + - ./issuer/config:/waltid-issuer/config + verifier: + image: waltid/verifier:latest + volumes: + - ./verifier/config:/waltid-verifier/config + web-portal: + image: waltid/portal:latest + environment: + NEXT_PUBLIC_VC_REPO: "http://localhost:$VC_REPO_PORT" + NEXT_PUBLIC_ISSUER: "http://localhost:$ISSUER_PORT" + NEXT_PUBLIC_VERIFIER: "http://localhost:$VERIFIER_PORT" + NEXT_PUBLIC_WALLET: "http://localhost:$WALLET_FRONTEND_PORT" + vc-repo: + image: waltid/vc-repository:latest ingress: image: nginx:1.15.10-alpine ports: @@ -32,12 +32,20 @@ services: published: $WALLET_FRONTEND_PORT # wallet-frontend protocol: tcp mode: host + - target: $WEB_PORTAL_PORT + published: $WEB_PORTAL_PORT # web-portal + protocol: tcp + mode: host + - target: $VC_REPO_PORT + published: $VC_REPO_PORT # vc-repo + protocol: tcp + mode: host - target: $ISSUER_PORT - published: $ISSUER_PORT # issuer-portal + published: $ISSUER_PORT # issuer-api protocol: tcp mode: host - target: $VERIFIER_PORT - published: $VERIFIER_PORT # verifier-portal + published: $VERIFIER_PORT # verifier-api protocol: tcp mode: host volumes: diff --git a/docker-compose/ingress.conf b/docker-compose/ingress.conf index dea3287..5068ae0 100644 --- a/docker-compose/ingress.conf +++ b/docker-compose/ingress.conf @@ -16,41 +16,49 @@ server { # wallet-backend server { listen 4545; - location ~* /(api|webjars|verifier-api|issuer-api)/ { - proxy_pass http://walletkit:7000; + + location / { + proxy_pass http://wallet-backend:4545; proxy_redirect default; } +} + +# web-portal +server { + listen 4000; location / { - proxy_pass http://wallet-backend; + proxy_pass http://web-portal:3000; proxy_redirect default; } } -# issuer-portal +# vc-repo server { - listen 8000; - location ~* /(api|webjars|verifier-api|issuer-api)/ { - proxy_pass http://walletkit:7000; + listen 5000; + + location / { + proxy_pass http://vc-repo:3000; proxy_redirect default; } +} + +# issuer +server { + listen 8000; location / { - proxy_pass http://issuer-portal; + proxy_pass http://issuer:3000; proxy_redirect default; } } -# verifier-portal +# verifier server { listen 9000; - location ~* /(api|webjars|verifier-api|issuer-api)/ { - proxy_pass http://walletkit:7000; - proxy_redirect default; - } location / { - proxy_pass http://verifier-portal; + proxy_pass http://verifier:3000; proxy_redirect default; } } \ No newline at end of file diff --git a/docker-compose/issuer/config/issuer-service.conf b/docker-compose/issuer/config/issuer-service.conf new file mode 100644 index 0000000..b9ebd65 --- /dev/null +++ b/docker-compose/issuer/config/issuer-service.conf @@ -0,0 +1 @@ +baseUrl = "localhost:8000" \ No newline at end of file diff --git a/docker-compose/issuer/config/web.conf b/docker-compose/issuer/config/web.conf new file mode 100644 index 0000000..57b2f0a --- /dev/null +++ b/docker-compose/issuer/config/web.conf @@ -0,0 +1,2 @@ +webHost = "0.0.0.0" +webPort = 3000 \ No newline at end of file diff --git a/docker-compose/readme.md b/docker-compose/readme.md index 84aa004..1c3f242 100644 --- a/docker-compose/readme.md +++ b/docker-compose/readme.md @@ -9,18 +9,20 @@ run a complete credential flow: ## Services The complete list of services and their port mapping is following: -- walletkit: `7000` -- web-wallet-backend: `4545` -- web-wallet-frontend: `3000` (published) -- issuer-portal: `8000` (published) -- verifier-portal: `9000` (published) +- web-wallet-frontend: `3000` +- web-wallet-backend: `4545` (not published) +- web-portal: `4000` +- vc-repo: `5000` +- issuer: `8000` +- verifier: `9000` ## Configurations Config locations: - web-wallet: `wallet-backend/config` -- walletkit: `walletkit/config` +- issuer: `issuer/config` +- verifier: `verifier/config` - ingress: `ingress.conf` - environment: `.env` diff --git a/docker-compose/verifier/config/verifier-service.conf b/docker-compose/verifier/config/verifier-service.conf new file mode 100644 index 0000000..deda911 --- /dev/null +++ b/docker-compose/verifier/config/verifier-service.conf @@ -0,0 +1 @@ +baseUrl = "localhost:9000" \ No newline at end of file diff --git a/docker-compose/verifier/config/web.conf b/docker-compose/verifier/config/web.conf new file mode 100644 index 0000000..57b2f0a --- /dev/null +++ b/docker-compose/verifier/config/web.conf @@ -0,0 +1,2 @@ +webHost = "0.0.0.0" +webPort = 3000 \ No newline at end of file diff --git a/docker-compose/walletkit/config/issuer-config.json b/docker-compose/walletkit/config/issuer-config.json deleted file mode 100644 index 9468560..0000000 --- a/docker-compose/walletkit/config/issuer-config.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "credentialTypes": [ - "VerifiableId", - "VerifiableDiploma", - "ParticipantCredential", - "OpenBadgeCredential", - "Europass", - "GaiaxCredential", - "ProofOfResidence", - "VerifiableVaccinationCertificate", - "VerifiableAttestation" - ], - "issuerUiUrl": "http://$EXTERNAL_HOSTNAME:8000", - "issuerApiUrl": "http://$EXTERNAL_HOSTNAME:8000/issuer-api/default", - "issuerClientName": "walt.id Issuer Portal", - "wallets": { - "walt.id": { - "id": "walt.id", - "url": "http://$EXTERNAL_HOSTNAME:3000", - "presentPath": "api/siop/initiatePresentation/", - "receivePath" : "api/siop/initiateIssuance/", - "description": "walt.id web wallet" - } - } -} \ No newline at end of file diff --git a/docker-compose/walletkit/config/verifier-config.json b/docker-compose/walletkit/config/verifier-config.json deleted file mode 100644 index e7c8a89..0000000 --- a/docker-compose/walletkit/config/verifier-config.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "verifierUiUrl": "http://$EXTERNAL_HOSTNAME:9000", - "verifierApiUrl": "http://$EXTERNAL_HOSTNAME:9000/verifier-api/default", - "wallets": { - "walt.id": { - "id": "walt.id", - "url": "http://$EXTERNAL_HOSTNAME:3000", - "presentPath": "api/siop/initiatePresentation/", - "receivePath" : "api/siop/initiateIssuance/", - "description": "walt.id web wallet" - } - } -} \ No newline at end of file diff --git a/docker-compose/walletkit/config/wallet-config.json b/docker-compose/walletkit/config/wallet-config.json deleted file mode 100644 index 2f5cc71..0000000 --- a/docker-compose/walletkit/config/wallet-config.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "walletUiUrl": "http://$EXTERNAL_HOSTNAME:3000", - "walletApiUrl": "http://$EXTERNAL_HOSTNAME:3000/api", - "issuers": { - "walt.id": { - "id": "walt.id", - "url": "http://$EXTERNAL_HOSTNAME:8000/issuer-api/default/oidc", - "description": "walt.id Issuer Portal" - } - } -} \ No newline at end of file From ebf80a2289317e22e690e1b9b17bbbde2afcb15f Mon Sep 17 00:00:00 2001 From: mikeplotean <101570226+mikeplotean@users.noreply.github.com> Date: Sat, 25 Nov 2023 00:24:16 +0200 Subject: [PATCH 3/3] chore: pr66 (#74) * 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 <46957159+Happy2C0de@users.noreply.github.com> --- docker-compose/docker-compose.yaml | 4 + docker-compose/wallet-backend/config/db.conf | 1 + .../wallet-backend/config/db.postgres.conf | 13 +++ ...accountwallet_walletoperationhistories.sql | 72 ++++++------ ...untdids_accountkeys_accountcredentials.sql | 103 ++++++++++++++++++ .../db/postgres/V5__create_table_issuers.sql | 34 ++++++ ...V6__insert_default_issuer_for_accounts.sql | 10 ++ 7 files changed, 201 insertions(+), 36 deletions(-) create mode 100644 docker-compose/wallet-backend/config/db.postgres.conf create mode 100644 src/main/resources/db/postgres/V4__create_tables_keys_dids_credentials_accountdids_accountkeys_accountcredentials.sql create mode 100644 src/main/resources/db/postgres/V5__create_table_issuers.sql create mode 100644 src/main/resources/db/postgres/V6__insert_default_issuer_for_accounts.sql diff --git a/docker-compose/docker-compose.yaml b/docker-compose/docker-compose.yaml index ae02e4b..4d0232d 100644 --- a/docker-compose/docker-compose.yaml +++ b/docker-compose/docker-compose.yaml @@ -1,4 +1,8 @@ services: + # postgresdb: # Uncomment to connect a Postgres DB + # image: postgres + # environment: + # POSTGRES_PASSWORD: secret wallet-backend: image: waltid/wallet-backend:latest volumes: diff --git a/docker-compose/wallet-backend/config/db.conf b/docker-compose/wallet-backend/config/db.conf index 1ab9596..f491984 100644 --- a/docker-compose/wallet-backend/config/db.conf +++ b/docker-compose/wallet-backend/config/db.conf @@ -1 +1,2 @@ +# database = "db.postgres" database = "db.sqlite" \ No newline at end of file diff --git a/docker-compose/wallet-backend/config/db.postgres.conf b/docker-compose/wallet-backend/config/db.postgres.conf new file mode 100644 index 0000000..7295a95 --- /dev/null +++ b/docker-compose/wallet-backend/config/db.postgres.conf @@ -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 + } +} \ No newline at end of file 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 17b36bd..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 new file mode 100644 index 0000000..bffb2ec --- /dev/null +++ b/src/main/resources/db/postgres/V4__create_tables_keys_dids_credentials_accountdids_accountkeys_accountcredentials.sql @@ -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"); \ 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 new file mode 100644 index 0000000..1cc38eb --- /dev/null +++ b/src/main/resources/db/postgres/V5__create_table_issuers.sql @@ -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"); \ No newline at end of file diff --git a/src/main/resources/db/postgres/V6__insert_default_issuer_for_accounts.sql b/src/main/resources/db/postgres/V6__insert_default_issuer_for_accounts.sql new file mode 100644 index 0000000..c340136 --- /dev/null +++ b/src/main/resources/db/postgres/V6__insert_default_issuer_for_accounts.sql @@ -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'); \ No newline at end of file