From de1bb7c90bc2c3f4898576da12b802c6cecae9e6 Mon Sep 17 00:00:00 2001 From: Jeroen Branje Date: Thu, 18 Jan 2024 11:38:10 +0100 Subject: [PATCH] feat: add db generate staging Signed-off-by: Jeroen Branje --- ...ranger.sql => 0000_fantastic_the_fury.sql} | 0 .../development/meta/0000_snapshot.json | 68 +++++++++++----- .../drizzle/development/meta/_journal.json | 6 +- ...stalgic_mauler.sql => 0000_sour_brood.sql} | 15 ++-- .../drizzle/staging/meta/0000_snapshot.json | 80 ++++++++++++++----- .../drizzle/staging/meta/_journal.json | 6 +- 6 files changed, 126 insertions(+), 49 deletions(-) rename apps/envited.ascs.digital/drizzle/development/{0000_lean_the_stranger.sql => 0000_fantastic_the_fury.sql} (100%) rename apps/envited.ascs.digital/drizzle/staging/{0000_nostalgic_mauler.sql => 0000_sour_brood.sql} (78%) diff --git a/apps/envited.ascs.digital/drizzle/development/0000_lean_the_stranger.sql b/apps/envited.ascs.digital/drizzle/development/0000_fantastic_the_fury.sql similarity index 100% rename from apps/envited.ascs.digital/drizzle/development/0000_lean_the_stranger.sql rename to apps/envited.ascs.digital/drizzle/development/0000_fantastic_the_fury.sql diff --git a/apps/envited.ascs.digital/drizzle/development/meta/0000_snapshot.json b/apps/envited.ascs.digital/drizzle/development/meta/0000_snapshot.json index 7f3c9e2d..201cb0b6 100644 --- a/apps/envited.ascs.digital/drizzle/development/meta/0000_snapshot.json +++ b/apps/envited.ascs.digital/drizzle/development/meta/0000_snapshot.json @@ -1,5 +1,5 @@ { - "id": "96c668c6-208a-4336-907b-bd99e7497d16", + "id": "8fbe3d01-c68f-48ae-9a7f-49222e392a4a", "prevId": "00000000-0000-0000-0000-000000000000", "version": "5", "dialect": "pg", @@ -35,7 +35,9 @@ "addressType_name_unique": { "name": "addressType_name_unique", "nullsNotDistinct": false, - "columns": ["name"] + "columns": [ + "name" + ] } } }, @@ -104,7 +106,9 @@ "issuer_id_unique": { "name": "issuer_id_unique", "nullsNotDistinct": false, - "columns": ["id"] + "columns": [ + "id" + ] } } }, @@ -138,7 +142,9 @@ "role_id_unique": { "name": "role_id_unique", "nullsNotDistinct": false, - "columns": ["id"] + "columns": [ + "id" + ] } } }, @@ -268,8 +274,12 @@ "tableFrom": "user", "tableTo": "issuer", "schemaTo": "public", - "columnsFrom": ["issuer_id"], - "columnsTo": ["id"], + "columnsFrom": [ + "issuer_id" + ], + "columnsTo": [ + "id" + ], "onDelete": "no action", "onUpdate": "no action" }, @@ -278,8 +288,12 @@ "tableFrom": "user", "tableTo": "addressType", "schemaTo": "public", - "columnsFrom": ["address_type_id"], - "columnsTo": ["id"], + "columnsFrom": [ + "address_type_id" + ], + "columnsTo": [ + "id" + ], "onDelete": "no action", "onUpdate": "no action" } @@ -289,7 +303,9 @@ "user_id_unique": { "name": "user_id_unique", "nullsNotDistinct": false, - "columns": ["id"] + "columns": [ + "id" + ] } } }, @@ -317,8 +333,12 @@ "tableFrom": "usersToCredentialTypes", "tableTo": "user", "schemaTo": "public", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], "onDelete": "no action", "onUpdate": "no action" }, @@ -327,8 +347,12 @@ "tableFrom": "usersToCredentialTypes", "tableTo": "credentialType", "schemaTo": "public", - "columnsFrom": ["credential_type_id"], - "columnsTo": ["id"], + "columnsFrom": [ + "credential_type_id" + ], + "columnsTo": [ + "id" + ], "onDelete": "no action", "onUpdate": "no action" } @@ -360,8 +384,12 @@ "tableFrom": "usersToRoles", "tableTo": "user", "schemaTo": "public", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], "onDelete": "no action", "onUpdate": "no action" }, @@ -370,8 +398,12 @@ "tableFrom": "usersToRoles", "tableTo": "role", "schemaTo": "public", - "columnsFrom": ["role_id"], - "columnsTo": ["id"], + "columnsFrom": [ + "role_id" + ], + "columnsTo": [ + "id" + ], "onDelete": "no action", "onUpdate": "no action" } @@ -387,4 +419,4 @@ "schemas": {}, "tables": {} } -} +} \ No newline at end of file diff --git a/apps/envited.ascs.digital/drizzle/development/meta/_journal.json b/apps/envited.ascs.digital/drizzle/development/meta/_journal.json index 3a7372f9..d3cc0cad 100644 --- a/apps/envited.ascs.digital/drizzle/development/meta/_journal.json +++ b/apps/envited.ascs.digital/drizzle/development/meta/_journal.json @@ -5,9 +5,9 @@ { "idx": 0, "version": "5", - "when": 1705324440754, - "tag": "0000_lean_the_stranger", + "when": 1705574231633, + "tag": "0000_fantastic_the_fury", "breakpoints": true } ] -} +} \ No newline at end of file diff --git a/apps/envited.ascs.digital/drizzle/staging/0000_nostalgic_mauler.sql b/apps/envited.ascs.digital/drizzle/staging/0000_sour_brood.sql similarity index 78% rename from apps/envited.ascs.digital/drizzle/staging/0000_nostalgic_mauler.sql rename to apps/envited.ascs.digital/drizzle/staging/0000_sour_brood.sql index 462399db..b36b43a5 100644 --- a/apps/envited.ascs.digital/drizzle/staging/0000_nostalgic_mauler.sql +++ b/apps/envited.ascs.digital/drizzle/staging/0000_sour_brood.sql @@ -1,7 +1,8 @@ CREATE TABLE IF NOT EXISTS "addressType" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "name" text, - "description" text + "description" text, + CONSTRAINT "addressType_name_unique" UNIQUE("name") ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "credentialType" ( @@ -59,37 +60,37 @@ CREATE TABLE IF NOT EXISTS "usersToRoles" ( ); --> statement-breakpoint DO $$ BEGIN - ALTER TABLE "user" ADD CONSTRAINT "user_issuer_id_issuer_id_fk" FOREIGN KEY ("issuer_id") REFERENCES "issuer"("id") ON DELETE no action ON UPDATE no action; + ALTER TABLE "user" ADD CONSTRAINT "user_issuer_id_issuer_id_fk" FOREIGN KEY ("issuer_id") REFERENCES "public"."issuer"("id") ON DELETE no action ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$; --> statement-breakpoint DO $$ BEGIN - ALTER TABLE "user" ADD CONSTRAINT "user_address_type_id_addressType_id_fk" FOREIGN KEY ("address_type_id") REFERENCES "addressType"("id") ON DELETE no action ON UPDATE no action; + ALTER TABLE "user" ADD CONSTRAINT "user_address_type_id_addressType_id_fk" FOREIGN KEY ("address_type_id") REFERENCES "public"."addressType"("id") ON DELETE no action ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$; --> statement-breakpoint DO $$ BEGIN - ALTER TABLE "usersToCredentialTypes" ADD CONSTRAINT "usersToCredentialTypes_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE no action ON UPDATE no action; + ALTER TABLE "usersToCredentialTypes" ADD CONSTRAINT "usersToCredentialTypes_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE no action ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$; --> statement-breakpoint DO $$ BEGIN - ALTER TABLE "usersToCredentialTypes" ADD CONSTRAINT "usersToCredentialTypes_credential_type_id_credentialType_id_fk" FOREIGN KEY ("credential_type_id") REFERENCES "credentialType"("id") ON DELETE no action ON UPDATE no action; + ALTER TABLE "usersToCredentialTypes" ADD CONSTRAINT "usersToCredentialTypes_credential_type_id_credentialType_id_fk" FOREIGN KEY ("credential_type_id") REFERENCES "public"."credentialType"("id") ON DELETE no action ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$; --> statement-breakpoint DO $$ BEGIN - ALTER TABLE "usersToRoles" ADD CONSTRAINT "usersToRoles_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE no action ON UPDATE no action; + ALTER TABLE "usersToRoles" ADD CONSTRAINT "usersToRoles_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE no action ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$; --> statement-breakpoint DO $$ BEGIN - ALTER TABLE "usersToRoles" ADD CONSTRAINT "usersToRoles_role_id_role_id_fk" FOREIGN KEY ("role_id") REFERENCES "role"("id") ON DELETE no action ON UPDATE no action; + ALTER TABLE "usersToRoles" ADD CONSTRAINT "usersToRoles_role_id_role_id_fk" FOREIGN KEY ("role_id") REFERENCES "public"."role"("id") ON DELETE no action ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$; diff --git a/apps/envited.ascs.digital/drizzle/staging/meta/0000_snapshot.json b/apps/envited.ascs.digital/drizzle/staging/meta/0000_snapshot.json index ce9c4c88..77d24f03 100644 --- a/apps/envited.ascs.digital/drizzle/staging/meta/0000_snapshot.json +++ b/apps/envited.ascs.digital/drizzle/staging/meta/0000_snapshot.json @@ -1,5 +1,5 @@ { - "id": "9a29c149-759a-4275-b107-d83917a4a9ab", + "id": "0f18334e-00d5-49b3-a2e4-c4f1e330f663", "prevId": "00000000-0000-0000-0000-000000000000", "version": "5", "dialect": "pg", @@ -31,7 +31,15 @@ "indexes": {}, "foreignKeys": {}, "compositePrimaryKeys": {}, - "uniqueConstraints": {} + "uniqueConstraints": { + "addressType_name_unique": { + "name": "addressType_name_unique", + "nullsNotDistinct": false, + "columns": [ + "name" + ] + } + } }, "credentialType": { "name": "credentialType", @@ -98,7 +106,9 @@ "issuer_id_unique": { "name": "issuer_id_unique", "nullsNotDistinct": false, - "columns": ["id"] + "columns": [ + "id" + ] } } }, @@ -132,7 +142,9 @@ "role_id_unique": { "name": "role_id_unique", "nullsNotDistinct": false, - "columns": ["id"] + "columns": [ + "id" + ] } } }, @@ -261,8 +273,13 @@ "name": "user_issuer_id_issuer_id_fk", "tableFrom": "user", "tableTo": "issuer", - "columnsFrom": ["issuer_id"], - "columnsTo": ["id"], + "schemaTo": "public", + "columnsFrom": [ + "issuer_id" + ], + "columnsTo": [ + "id" + ], "onDelete": "no action", "onUpdate": "no action" }, @@ -270,8 +287,13 @@ "name": "user_address_type_id_addressType_id_fk", "tableFrom": "user", "tableTo": "addressType", - "columnsFrom": ["address_type_id"], - "columnsTo": ["id"], + "schemaTo": "public", + "columnsFrom": [ + "address_type_id" + ], + "columnsTo": [ + "id" + ], "onDelete": "no action", "onUpdate": "no action" } @@ -281,7 +303,9 @@ "user_id_unique": { "name": "user_id_unique", "nullsNotDistinct": false, - "columns": ["id"] + "columns": [ + "id" + ] } } }, @@ -308,8 +332,13 @@ "name": "usersToCredentialTypes_user_id_user_id_fk", "tableFrom": "usersToCredentialTypes", "tableTo": "user", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], + "schemaTo": "public", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], "onDelete": "no action", "onUpdate": "no action" }, @@ -317,8 +346,13 @@ "name": "usersToCredentialTypes_credential_type_id_credentialType_id_fk", "tableFrom": "usersToCredentialTypes", "tableTo": "credentialType", - "columnsFrom": ["credential_type_id"], - "columnsTo": ["id"], + "schemaTo": "public", + "columnsFrom": [ + "credential_type_id" + ], + "columnsTo": [ + "id" + ], "onDelete": "no action", "onUpdate": "no action" } @@ -349,8 +383,13 @@ "name": "usersToRoles_user_id_user_id_fk", "tableFrom": "usersToRoles", "tableTo": "user", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], + "schemaTo": "public", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], "onDelete": "no action", "onUpdate": "no action" }, @@ -358,8 +397,13 @@ "name": "usersToRoles_role_id_role_id_fk", "tableFrom": "usersToRoles", "tableTo": "role", - "columnsFrom": ["role_id"], - "columnsTo": ["id"], + "schemaTo": "public", + "columnsFrom": [ + "role_id" + ], + "columnsTo": [ + "id" + ], "onDelete": "no action", "onUpdate": "no action" } @@ -375,4 +419,4 @@ "schemas": {}, "tables": {} } -} +} \ No newline at end of file diff --git a/apps/envited.ascs.digital/drizzle/staging/meta/_journal.json b/apps/envited.ascs.digital/drizzle/staging/meta/_journal.json index 657a65fe..d10c5148 100644 --- a/apps/envited.ascs.digital/drizzle/staging/meta/_journal.json +++ b/apps/envited.ascs.digital/drizzle/staging/meta/_journal.json @@ -5,9 +5,9 @@ { "idx": 0, "version": "5", - "when": 1704723156913, - "tag": "0000_nostalgic_mauler", + "when": 1705574199077, + "tag": "0000_sour_brood", "breakpoints": true } ] -} +} \ No newline at end of file