forked from glitch-soc/mastodon
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
48 additions
and
5 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
15 changes: 15 additions & 0 deletions
15
db/migrate/20241218034614_change_avatar_and_header_description_non_nullable.rb
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,15 @@ | ||
# frozen_string_literal: true | ||
|
||
class ChangeAvatarAndHeaderDescriptionNonNullable < ActiveRecord::Migration[7.2] | ||
def change | ||
change_column_default :accounts, :avatar_description, from: nil, to: '' | ||
add_check_constraint :accounts, 'avatar_description IS NOT NULL', name: 'accounts_avatar_description_null', validate: false | ||
|
||
change_column_default :accounts, :header_description, from: nil, to: '' | ||
add_check_constraint :accounts, 'header_description IS NOT NULL', name: 'accounts_header_description_null', validate: false | ||
|
||
safety_assured do | ||
execute "UPDATE accounts SET avatar_description = COALESCE(avatar_description, ''), header_description = COALESCE(header_description, '') WHERE avatar_description IS NULL OR header_description IS NULL" | ||
end | ||
end | ||
end |
14 changes: 14 additions & 0 deletions
14
db/migrate/20241218034746_validate_change_avatar_description_non_nullable.rb
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,14 @@ | ||
# frozen_string_literal: true | ||
|
||
class ValidateChangeAvatarDescriptionNonNullable < ActiveRecord::Migration[7.2] | ||
def up | ||
validate_check_constraint :accounts, name: 'accounts_avatar_description_null' | ||
change_column_null :accounts, :avatar_description, false | ||
remove_check_constraint :accounts, name: 'accounts_avatar_description_null' | ||
end | ||
|
||
def down | ||
add_check_constraint :accounts, 'avatar_description IS NOT NULL', name: 'accounts_avatar_description_null', validate: false | ||
change_column_null :accounts, :avatar_description, true | ||
end | ||
end |
14 changes: 14 additions & 0 deletions
14
db/migrate/20241218050032_validate_change_header_description_non_nullable.rb
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,14 @@ | ||
# frozen_string_literal: true | ||
|
||
class ValidateChangeHeaderDescriptionNonNullable < ActiveRecord::Migration[7.2] | ||
def up | ||
validate_check_constraint :accounts, name: 'accounts_header_description_null' | ||
change_column_null :accounts, :header_description, false | ||
remove_check_constraint :accounts, name: 'accounts_header_description_null' | ||
end | ||
|
||
def down | ||
add_check_constraint :accounts, 'header_description IS NOT NULL', name: 'accounts_header_description_null', validate: false | ||
change_column_null :accounts, :header_description, true | ||
end | ||
end |
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