Skip to content

Commit

Permalink
Add a migration to fill the created_by values
Browse files Browse the repository at this point in the history
and make it non-null
  • Loading branch information
egli committed Sep 6, 2024
1 parent 0019e56 commit d507c2c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- allow `created_by` to be NULL
ALTER TABLE documents_version
MODIFY created_by VARCHAR(32) DEFAULT NULL;
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-- Fill `created_by` with the values that correspond to `created_by_id`
UPDATE documents_version
INNER JOIN auth_user
ON documents_version.created_by_id = auth_user.id
SET created_by = auth_user.username
WHERE documents_version.created_by IS NULL;

--;;

-- `created_by` should not be NULL
ALTER TABLE documents_version
MODIFY created_by VARCHAR(32) NOT NULL;

0 comments on commit d507c2c

Please sign in to comment.