Skip to content

Commit

Permalink
Railtie: next unless of break
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Hareau committed Jul 6, 2023
1 parent 606b200 commit 82da265
Showing 1 changed file with 2 additions and 26 deletions.
28 changes: 2 additions & 26 deletions lib/safe-pg-migrations/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,9 @@ class Railtie < Rails::Railtie
ActiveRecord::Migration.singleton_class.prepend(SafePgMigrations::Migration::ClassMethods)
end

break unless Object.const_defined? :StrongMigrations
next unless Object.const_defined? :StrongMigrations

StrongMigrations.add_check do |method, args|
break unless method == :add_column

options = args.last.is_a?(Hash) ? args.last : {}

default_value_backfill = options.fetch(:default_value_backfill, :auto)

if default_value_backfill == :update_in_batches
check_message = <<~CHECK
default_value_backfill: :update_in_batches will take time if the table is too big.
Your configuration sets a pause of #{SafePgMigrations.config.backfill_pause} seconds between batches of
#{SafePgMigrations.config.backfill_batch_size} rows. Each batch execution will take time as well. Please
check that the estimated duration of the migration is acceptable before adding `safety_assured`.
CHECK

check_message += <<~CHECK if SafePgMigrations.config.default_value_backfill_threshold
Also, please note that SafePgMigrations is configured to raise if the table has more than
#{SafePgMigrations.config.default_value_backfill_threshold} rows.
CHECK

stop! check_message
end
end
SafePgMigrations::StrongMigrationsIntegration.initialize
end
end
end

0 comments on commit 82da265

Please sign in to comment.