fix: migrations

This commit is contained in:
Lorenzo Migliorero
2024-07-26 09:51:35 +02:00
parent 2e3a7c6164
commit 7e39be4ca1
6 changed files with 43 additions and 3045 deletions

View File

@@ -0,0 +1,25 @@
CREATE TABLE IF NOT EXISTS "ssh-key" (
"sshKeyId" text PRIMARY KEY NOT NULL,
"publicKey" text NOT NULL,
"name" text NOT NULL,
"description" text,
"createdAt" text NOT NULL,
"lastUsedAt" text
);
--> statement-breakpoint
ALTER TABLE "application" ADD COLUMN "customGitSSHKeyId" text;--> statement-breakpoint
ALTER TABLE "compose" ADD COLUMN "customGitSSHKeyId" text;--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "application" ADD CONSTRAINT "application_customGitSSHKeyId_ssh-key_sshKeyId_fk" FOREIGN KEY ("customGitSSHKeyId") REFERENCES "public"."ssh-key"("sshKeyId") ON DELETE set null ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "compose" ADD CONSTRAINT "compose_customGitSSHKeyId_ssh-key_sshKeyId_fk" FOREIGN KEY ("customGitSSHKeyId") REFERENCES "public"."ssh-key"("sshKeyId") ON DELETE set null ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
ALTER TABLE "application" DROP COLUMN IF EXISTS "customGitSSHKey";--> statement-breakpoint
ALTER TABLE "compose" DROP COLUMN IF EXISTS "customGitSSHKey";

View File

@@ -1,15 +0,0 @@
CREATE TABLE IF NOT EXISTS "ssh-key" (
"sshKeyId" text PRIMARY KEY NOT NULL,
"publicKey" text NOT NULL,
"name" text NOT NULL,
"description" text,
"createdAt" text NOT NULL,
"lastUsedAt" text
);
--> statement-breakpoint
ALTER TABLE "application" RENAME COLUMN "customGitSSHKey" TO "customGitSSHKeyId";--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "application" ADD CONSTRAINT "application_customGitSSHKeyId_ssh-key_sshKeyId_fk" FOREIGN KEY ("customGitSSHKeyId") REFERENCES "public"."ssh-key"("sshKeyId") ON DELETE set null ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;

View File

@@ -1,8 +0,0 @@
ALTER TABLE "compose" ADD COLUMN "customGitSSHKeyId" text;--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "compose" ADD CONSTRAINT "compose_customGitSSHKeyId_ssh-key_sshKeyId_fk" FOREIGN KEY ("customGitSSHKeyId") REFERENCES "public"."ssh-key"("sshKeyId") ON DELETE set null ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
ALTER TABLE "compose" DROP COLUMN IF EXISTS "customGitSSHKey";

View File

@@ -1,5 +1,5 @@
{
"id": "e5196aec-c724-4f9e-bb4e-81dca01905e4",
"id": "3dff4fa9-1d03-4748-b3ee-908c34324171",
"prevId": "771c1412-7931-4f79-a789-055b0f51cf0f",
"version": "6",
"dialect": "postgresql",
@@ -2392,8 +2392,8 @@
"primaryKey": false,
"notNull": false
},
"customGitSSHKey": {
"name": "customGitSSHKey",
"customGitSSHKeyId": {
"name": "customGitSSHKeyId",
"type": "text",
"primaryKey": false,
"notNull": false
@@ -2435,6 +2435,19 @@
},
"indexes": {},
"foreignKeys": {
"compose_customGitSSHKeyId_ssh-key_sshKeyId_fk": {
"name": "compose_customGitSSHKeyId_ssh-key_sshKeyId_fk",
"tableFrom": "compose",
"tableTo": "ssh-key",
"columnsFrom": [
"customGitSSHKeyId"
],
"columnsTo": [
"sshKeyId"
],
"onDelete": "set null",
"onUpdate": "no action"
},
"compose_projectId_project_projectId_fk": {
"name": "compose_projectId_project_projectId_fk",
"tableFrom": "compose",

File diff suppressed because it is too large Load Diff

View File

@@ -187,15 +187,8 @@
{
"idx": 26,
"version": "6",
"when": 1721928706816,
"tag": "0026_yielding_king_cobra",
"breakpoints": true
},
{
"idx": 27,
"version": "6",
"when": 1721937297064,
"tag": "0027_fantastic_squadron_sinister",
"when": 1721979220929,
"tag": "0026_known_dormammu",
"breakpoints": true
}
]