-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2374 from alphagov/fix-for-migrations-that-stripp…
…ed-whitespace Fix for previous migrations that didn't strip whitespace for all the relevant records
- Loading branch information
Showing
4 changed files
with
22 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class StripWhitespaceFromUserName < ActiveRecord::Migration[7.0] | ||
def change | ||
User.where("name REGEXP ? OR name REGEXP ?", "^\\s+", "\\s+$").each do |u| | ||
u.update_attribute(:name, u.name&.strip) # rubocop:disable Rails/SkipsModelValidations | ||
end | ||
end | ||
end |
7 changes: 7 additions & 0 deletions
7
db/migrate/20230925104848_strip_whitespace_from_batch_invitation_user_name.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,7 @@ | ||
class StripWhitespaceFromBatchInvitationUserName < ActiveRecord::Migration[7.0] | ||
def change | ||
BatchInvitationUser.where("name REGEXP ? OR name REGEXP ?", "^\\s+", "\\s+$").each do |u| | ||
u.update_attribute(:name, u.name&.strip) # rubocop:disable Rails/SkipsModelValidations | ||
end | ||
end | ||
end |
7 changes: 7 additions & 0 deletions
7
db/migrate/20230925104849_strip_whitespace_from_organisation_name.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,7 @@ | ||
class StripWhitespaceFromOrganisationName < ActiveRecord::Migration[7.0] | ||
def change | ||
Organisation.where("name REGEXP ? OR name REGEXP ?", "^\\s+", "\\s+$").each do |o| | ||
o.update_attribute(:name, o.name&.strip) # rubocop:disable Rails/SkipsModelValidations | ||
end | ||
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