-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e15945b
commit 0db8dbb
Showing
1 changed file
with
15 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,15 @@ | ||
ALTER TABLE "environment_policy_approval" DROP CONSTRAINT "environment_policy_approval_policy_id_environment_policy_id_fk"; | ||
--> statement-breakpoint | ||
ALTER TABLE "environment_policy_approval" DROP CONSTRAINT "environment_policy_approval_release_id_release_id_fk"; | ||
--> statement-breakpoint | ||
ALTER TABLE "environment_policy_approval" DROP CONSTRAINT "environment_policy_approval_user_id_user_id_fk"; | ||
--> statement-breakpoint | ||
DROP INDEX IF EXISTS "environment_policy_approval_policy_id_release_id_index"; | ||
--> statement-breakpoint | ||
ALTER TABLE "environment_policy_approval" RENAME TO "environment_approval"; | ||
--> statement-breakpoint | ||
ALTER TABLE "environment_approval" RENAME COLUMN "policy_id" TO "environment_id"; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "environment_approval" ADD CONSTRAINT "environment_approval_environment_id_environment_id_fk" FOREIGN KEY ("environment_id") REFERENCES "public"."environment"("id") ON DELETE cascade ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "environment_approval" ADD CONSTRAINT "environment_approval_release_id_release_id_fk" FOREIGN KEY ("release_id") REFERENCES "public"."release"("id") ON DELETE cascade ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "environment_approval" ADD CONSTRAINT "environment_approval_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE set null ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
CREATE UNIQUE INDEX IF NOT EXISTS "environment_approval_environment_id_release_id_index" ON "environment_approval" USING btree ("environment_id","release_id"); | ||
DROP TABLE IF EXISTS "environment_policy_approval"; | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "environment_approval" ( | ||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid(), | ||
"environment_id" uuid NOT NULL, | ||
"release_id" uuid NOT NULL, | ||
"status" approval_status_type NOT NULL DEFAULT 'pending', | ||
"user_id" uuid, | ||
FOREIGN KEY ("environment_id") REFERENCES "public"."environment"("id") ON DELETE CASCADE, | ||
FOREIGN KEY ("release_id") REFERENCES "public"."release"("id") ON DELETE CASCADE, | ||
FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE SET NULL | ||
); | ||
--> statement-breakpoint | ||
CREATE UNIQUE INDEX IF NOT EXISTS "environment_approval_environment_id_release_id_index" | ||
ON "environment_approval" ("environment_id", "release_id"); |