diff --git a/db/migrate/20230925093142_strip_whitespace_from_batch_invitation_user_email.rb b/db/migrate/20230925093142_strip_whitespace_from_batch_invitation_user_email.rb new file mode 100644 index 000000000..7cd445533 --- /dev/null +++ b/db/migrate/20230925093142_strip_whitespace_from_batch_invitation_user_email.rb @@ -0,0 +1,7 @@ +class StripWhitespaceFromBatchInvitationUserEmail < ActiveRecord::Migration[7.0] + def change + BatchInvitationUser.where("email REGEXP ? OR email REGEXP ?", "^\\s+", "\\s+$").each do |biu| + biu.update_attribute(:email, biu.email&.strip) # rubocop:disable Rails/SkipsModelValidations + end + end +end diff --git a/db/migrate/20230925093143_strip_whitespace_from_batch_invitation_user_organisation_slug.rb b/db/migrate/20230925093143_strip_whitespace_from_batch_invitation_user_organisation_slug.rb new file mode 100644 index 000000000..1f5502f83 --- /dev/null +++ b/db/migrate/20230925093143_strip_whitespace_from_batch_invitation_user_organisation_slug.rb @@ -0,0 +1,7 @@ +class StripWhitespaceFromBatchInvitationUserOrganisationSlug < ActiveRecord::Migration[7.0] + def change + BatchInvitationUser.where("organisation_slug REGEXP ? OR organisation_slug REGEXP ?", "^\\s+", "\\s+$").each do |biu| + biu.update_attribute(:organisation_slug, biu.organisation_slug&.strip) # rubocop:disable Rails/SkipsModelValidations + end + end +end diff --git a/db/schema.rb b/db/schema.rb index a1db393a8..02c7771e4 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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_18_141453) do +ActiveRecord::Schema[7.0].define(version: 2023_09_25_093143) 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