lib/strong_migrations/migration.rb in strong_migrations-0.1.1 vs lib/strong_migrations/migration.rb in strong_migrations-0.1.2

- old
+ new

@@ -6,12 +6,17 @@ yield ensure @safe = previous_value end + def migrate(direction) + @direction = direction + super + end + def method_missing(method, *args, &block) - unless @safe || is_a?(ActiveRecord::Schema) + unless @safe || is_a?(ActiveRecord::Schema) || @direction == :down case method when :remove_column raise_error :remove_column when :remove_timestamps raise_error :remove_column @@ -20,10 +25,14 @@ when :rename_table raise_error :rename_table when :rename_column raise_error :rename_column when :add_index + columns = args[1] + if columns.is_a?(Array) && columns.size > 3 + raise_error :add_index_columns + end options = args[2] if %w(PostgreSQL PostGIS).include?(connection.adapter_name) && !(options && options[:algorithm] == :concurrently) raise_error :add_index end when :add_column @@ -105,9 +114,13 @@ def change commit_db_transaction add_index :users, :some_column, algorithm: :concurrently end" + when :add_index_columns +"Adding an index with more than three columns only helps on extremely large tables. + +If you're sure this is what you want, wrap it in a safety_assured { ... } block." when :change_table "The strong_migrations gem does not support inspecting what happens inside a change_table block, so cannot help you here. Please make really sure that what you're doing is safe before proceding, then wrap it in a safety_assured { ... } block." end