forked from farhoodlabs/paperclip
fix(db): make document revision migration replay-safe
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
ALTER TABLE "document_revisions" ADD COLUMN "title" text;--> statement-breakpoint
|
||||
ALTER TABLE "document_revisions" ADD COLUMN "format" text DEFAULT 'markdown' NOT NULL;
|
||||
ALTER TABLE "document_revisions" ADD COLUMN IF NOT EXISTS "title" text;--> statement-breakpoint
|
||||
ALTER TABLE "document_revisions" ADD COLUMN IF NOT EXISTS "format" text;--> statement-breakpoint
|
||||
ALTER TABLE "document_revisions" ALTER COLUMN "format" SET DEFAULT 'markdown';
|
||||
--> statement-breakpoint
|
||||
UPDATE "document_revisions" AS "dr"
|
||||
SET
|
||||
"title" = "d"."title",
|
||||
"format" = COALESCE("d"."format", 'markdown')
|
||||
"title" = COALESCE("dr"."title", "d"."title"),
|
||||
"format" = COALESCE("dr"."format", "d"."format", 'markdown')
|
||||
FROM "documents" AS "d"
|
||||
WHERE "d"."id" = "dr"."document_id";
|
||||
WHERE "d"."id" = "dr"."document_id";--> statement-breakpoint
|
||||
ALTER TABLE "document_revisions" ALTER COLUMN "format" SET NOT NULL;
|
||||
|
||||
Reference in New Issue
Block a user