File tree Expand file tree Collapse file tree 1 file changed +19
-4
lines changed
internal-packages/database/prisma/migrations/20250509180155_runtime_environment_branching Expand file tree Collapse file tree 1 file changed +19
-4
lines changed Original file line number Diff line number Diff line change 1
1
-- AlterTable
2
2
ALTER TABLE " RuntimeEnvironment"
3
- ADD COLUMN " archivedAt" TIMESTAMP (3 ),
4
- ADD COLUMN " branchName" TEXT ,
5
- ADD COLUMN " git" JSONB;
3
+ ADD COLUMN IF NOT EXISTS " archivedAt" TIMESTAMP (3 ),
4
+ ADD COLUMN IF NOT EXISTS " branchName" TEXT ,
5
+ ADD COLUMN IF NOT EXISTS " git" JSONB;
6
6
7
7
-- Add the parentEnvironmentId column
8
8
DO $$
19
19
END $$;
20
20
21
21
-- AddForeignKey
22
- ALTER TABLE " RuntimeEnvironment" ADD CONSTRAINT " RuntimeEnvironment_parentEnvironmentId_fkey" FOREIGN KEY (" parentEnvironmentId" ) REFERENCES " RuntimeEnvironment" (" id" ) ON DELETE CASCADE ON UPDATE CASCADE;
22
+ DO $$
23
+ BEGIN
24
+ IF NOT EXISTS (
25
+ SELECT 1
26
+ FROM information_schema .table_constraints
27
+ WHERE table_name = ' RuntimeEnvironment'
28
+ AND constraint_name = ' RuntimeEnvironment_parentEnvironmentId_fkey'
29
+ ) THEN
30
+ ALTER TABLE " RuntimeEnvironment"
31
+ ADD CONSTRAINT " RuntimeEnvironment_parentEnvironmentId_fkey"
32
+ FOREIGN KEY (" parentEnvironmentId" )
33
+ REFERENCES " RuntimeEnvironment" (" id" )
34
+ ON DELETE CASCADE
35
+ ON UPDATE CASCADE;
36
+ END IF;
37
+ END $$;
You can’t perform that action at this time.
0 commit comments