6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/safe-pg-migrations/plugins/strong_migrations_integration.rb', line 6
def initialize
return unless strong_migration_available?
StrongMigrations.disable_check(:add_column_default)
StrongMigrations.disable_check(:add_column_default_callable)
StrongMigrations.add_check do |method, args|
next 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
end
|