Skip to content

Commit

Permalink
Merge pull request #2374 from alphagov/fix-for-migrations-that-stripp…
Browse files Browse the repository at this point in the history
…ed-whitespace

Fix for previous migrations that didn't strip whitespace for all the relevant records
  • Loading branch information
floehopper authored Sep 25, 2023
2 parents b6c7bf1 + 4bdebf6 commit 9da737c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
7 changes: 7 additions & 0 deletions db/migrate/20230925104847_strip_whitespace_from_user_name.rb
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
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
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
2 changes: 1 addition & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.0].define(version: 2023_09_25_093143) do
ActiveRecord::Schema[7.0].define(version: 2023_09_25_104849) do
create_table "batch_invitation_application_permissions", id: :integer, charset: "utf8mb3", force: :cascade do |t|
t.integer "batch_invitation_id", null: false
t.integer "supported_permission_id", null: false
Expand Down

0 comments on commit 9da737c

Please sign in to comment.