Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add default and constraint to CensorRule#regexp
Add default value and not null constraint to `CensorRule#regexp`. While effectively the same behaviour, this makes the intent explicit and prevents empty values appearing in admin tables where we render censor rules.
- Loading branch information
1 parent
90def2a
commit 146a517
Showing
5 changed files
with
19 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
12 changes: 12 additions & 0 deletions
12
db/migrate/20240313094449_add_not_null_constraint_to_censor_rule_regexp.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,12 @@ | ||
class AddNotNullConstraintToCensorRuleRegexp < ActiveRecord::Migration[7.0] | ||
def up | ||
change_column_default :censor_rules, :regexp, false | ||
CensorRule.where(regexp: nil).update_all(regexp: false) | ||
change_column_null :censor_rules, :regexp, false | ||
end | ||
|
||
def down | ||
change_column_null :censor_rules, :regexp, true | ||
change_column_default :censor_rules, :regexp, nil | ||
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
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