CP-10359 - Rubocop fix for migration files with bulk change_table operations

pull/544/head
Bernardo Anderson 4 months ago
parent 2aac5f428b
commit 7154d4b5e4

@ -10,9 +10,11 @@ class AddTemplateFieldsToSubmission < ActiveRecord::Migration[7.0]
end
def up
add_column :submissions, :template_fields, :text
add_column :submissions, :template_schema, :text
add_column :submissions, :template_submitters, :text
change_table :submissions, bulk: true do |t|
t.text :template_fields
t.text :template_schema
t.text :template_submitters
end
MigrationTemplate.all.each do |template|
MigrationSubmission.where(template_id: template.id).each do |submission|
@ -24,8 +26,10 @@ class AddTemplateFieldsToSubmission < ActiveRecord::Migration[7.0]
end
def down
remove_column :submissions, :template_fields
remove_column :submissions, :template_schema
remove_column :submissions, :template_submitters
change_table :submissions, bulk: true do |t|
t.remove :template_fields
t.remove :template_schema
t.remove :template_submitters
end
end
end

@ -2,7 +2,9 @@
class RemoveUserFirstLastNameNotNull < ActiveRecord::Migration[7.0]
def change
change_column_null :users, :first_name, true
change_column_null :users, :last_name, true
change_table :users, bulk: true do |t|
t.change_null :first_name, true
t.change_null :last_name, true
end
end
end

@ -2,9 +2,10 @@
class AddPhoneAndNameToSubmitters < ActiveRecord::Migration[7.0]
def change
add_column :submitters, :name, :string
add_column :submitters, :phone, :string
change_column_null :submitters, :email, true
change_table :submitters, bulk: true do |t|
t.string :name
t.string :phone
t.change_null :email, true
end
end
end

@ -2,8 +2,10 @@
class AddDeviseTwoFactorToUsers < ActiveRecord::Migration[7.0]
def change
add_column :users, :otp_secret, :string
add_column :users, :consumed_timestep, :integer
add_column :users, :otp_required_for_login, :boolean, default: false, null: false
change_table :users, bulk: true do |t|
t.string :otp_secret
t.integer :consumed_timestep
t.boolean :otp_required_for_login, default: false, null: false
end
end
end

@ -8,12 +8,14 @@ class AddSharedLinkToTemplates < ActiveRecord::Migration[8.0]
end
def up
add_column :templates, :shared_link, :boolean, if_not_exists: true
add_column :templates, :shared_link, :boolean, default: false, null: false, if_not_exists: true
MigrationTemplate.where(shared_link: nil).in_batches.update_all(shared_link: true)
change_column_default :templates, :shared_link, from: nil, to: false
change_column_null :templates, :shared_link, false
change_table :templates, bulk: true do |t|
t.change_default :shared_link, from: nil, to: false
t.change_null :shared_link, false
end
end
def down

Loading…
Cancel
Save