-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a migration to fill the created_by values
and make it non-null
- Loading branch information
Showing
2 changed files
with
16 additions
and
0 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
resources/migrations/20240906144223-make-document-version-created-by-non-null.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
13 changes: 13 additions & 0 deletions
13
resources/migrations/20240906144223-make-document-version-created-by-non-null.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|