Skip to content

Commit c98f87b

Browse files
committed
wrap migration for a single txn
1 parent 4dcde2f commit c98f87b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1+
BEGIN;
2+
13
ALTER TABLE ONLY template_versions ADD COLUMN IF NOT EXISTS created_by uuid REFERENCES users (id) ON DELETE RESTRICT;
24

35
UPDATE
46
template_versions
57
SET
6-
created_by = (
7-
SELECT created_by FROM templates
8+
template_versions.created_by = (
9+
SELECT templates.created_by FROM templates
810
WHERE template_versions.template_id = templates.id
911
LIMIT 1
1012
)
1113
WHERE
12-
created_by IS NULL;
14+
template_versions.created_by IS NULL;
1315

1416
ALTER TABLE ONLY template_versions ALTER COLUMN created_by SET NOT NULL;
17+
18+
COMMIT;

0 commit comments

Comments
 (0)