Skip to content

Commit d991a08

Browse files
committed
fix(db): add the visibility constraint NOT VALID, then validate
check:migrations blocks a plain ADD CONSTRAINT CHECK on an existing table: it takes an ACCESS EXCLUSIVE lock for a full scan of credential and rejects concurrent writes for the duration. Split into the expand/contract form so the lock is brief and validation runs under SHARE UPDATE EXCLUSIVE, which readers and writers do not block on.
1 parent 44f331a commit d991a08

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
CREATE TYPE "public"."credential_env_visibility" AS ENUM('secret', 'variable');--> statement-breakpoint
22
ALTER TABLE "credential" ADD COLUMN "env_visibility" "credential_env_visibility" DEFAULT 'secret' NOT NULL;--> statement-breakpoint
3-
ALTER TABLE "credential" ADD CONSTRAINT "credential_env_visibility_scope_check" CHECK ((env_visibility = 'secret') OR (type = 'env_workspace'));
3+
ALTER TABLE "credential" ADD CONSTRAINT "credential_env_visibility_scope_check" CHECK ((env_visibility = 'secret') OR (type = 'env_workspace')) NOT VALID;--> statement-breakpoint
4+
ALTER TABLE "credential" VALIDATE CONSTRAINT "credential_env_visibility_scope_check";

0 commit comments

Comments
 (0)