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 11-- AlterTable
22ALTER 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;
66
77-- Add the parentEnvironmentId column
88DO $$
1919END $$;
2020
2121-- 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