DEV: Only lock rows that need to change in migration (#18319)

This commit is contained in:
Daniel Waterworth 2022-09-21 14:14:45 -05:00 committed by GitHub
parent 61f5c8716d
commit e3d7253199
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -2,8 +2,8 @@
class EnforceUserProfileMaxLimits < ActiveRecord::Migration[7.0]
def change
execute "UPDATE user_profiles SET location = LEFT(location, 3000) WHERE location IS NOT NULL"
execute "UPDATE user_profiles SET website = LEFT(website, 3000) WHERE website IS NOT NULL"
execute "UPDATE user_profiles SET location = LEFT(location, 3000) WHERE location IS NOT NULL AND LENGTH(location) > 3000"
execute "UPDATE user_profiles SET website = LEFT(website, 3000) WHERE website IS NOT NULL AND LENGTH(website) > 3000"
change_column :user_profiles, :location, :string, limit: 3000
change_column :user_profiles, :website, :string, limit: 3000