fix: populate default created_by and add not-null constraint in templates (#2290)

This commit is contained in:
Abhineet Jain
2022-06-13 13:25:06 -04:00
committed by GitHub
parent 49f857806f
commit a91482cb25
12 changed files with 28 additions and 31 deletions

View File

@ -0,0 +1 @@
ALTER TABLE ONLY templates ALTER COLUMN created_by DROP NOT NULL;

View File

@ -0,0 +1,14 @@
UPDATE
templates
SET
created_by = (
SELECT user_id FROM organization_members
WHERE organization_members.organization_id = templates.organization_id
ORDER BY created_at
LIMIT 1
)
WHERE
created_by IS NULL;
ALTER TABLE ONLY templates ALTER COLUMN created_by SET NOT NULL;