class ZeroDowntimeMigrations::Validation::DdlMigration

Public Instance Methods

validate!() click to toggle source
  # File lib/zero_downtime_migrations/validation/ddl_migration.rb
4 def validate!
5   return unless migration.ddl_disabled? && !Migration.index?
6   error!(message)
7 end

Private Instance Methods

message() click to toggle source
   # File lib/zero_downtime_migrations/validation/ddl_migration.rb
11       def message
12         <<-MESSAGE.strip_heredoc
13           Disabling the DDL transaction is unsafe!
14 
15           The DDL transaction should only be disabled for migrations that add indexes.
16           All other types of migrations should keep the DDL transaction enabled so
17           that changes can be rolled back if any unexpected errors occur.
18 
19           Any other data or schema changes must live in their own migration files with
20           the DDL transaction enabled just in case they need to be rolled back.
21 
22           If you're 100% positive that this migration is already safe, then simply
23           add a call to `safety_assured` to your migration.
24 
25             class #{migration_name} < ActiveRecord::Migration
26               disable_ddl_transaction!
27               safety_assured
28 
29               def change
30                 # ...
31               end
32             end
33         MESSAGE
34       end