-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add users.avatar_url constraint and default (#1141)
- Loading branch information
1 parent
208f358
commit 2a2e18c
Showing
3 changed files
with
22 additions
and
6 deletions.
There are no files selected for viewing
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
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
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,16 @@ | ||
-- --- !Ups | ||
-- Update any existing null avatar_url values to the default | ||
UPDATE users | ||
SET avatar_url = '/assets/images/user_no_image.png' | ||
WHERE avatar_url IS NULL; | ||
|
||
-- Alter the table to set avatar_url as NOT NULL with a default value | ||
ALTER TABLE IF EXISTS users | ||
ALTER COLUMN avatar_url SET DEFAULT '/assets/images/user_no_image.png', | ||
ALTER COLUMN avatar_url SET NOT NULL; | ||
|
||
-- --- !Downs | ||
-- Revert the avatar_url column to allow null values and remove the default value | ||
ALTER TABLE IF EXISTS users | ||
ALTER COLUMN avatar_url DROP NOT NULL, | ||
ALTER COLUMN avatar_url DROP DEFAULT; |