Module: SchemaPlus::ForeignKeys::Middleware::Mysql::Migration::DropTable

Defined in:
lib/schema_plus/foreign_keys/middleware/mysql.rb

Instance Method Summary collapse

Instance Method Details

#around(env) {|env| ... } ⇒ Object

Yields:

  • (env)


8
9
10
11
12
13
14
15
# File 'lib/schema_plus/foreign_keys/middleware/mysql.rb', line 8

def around(env)
  if (env.options[:force] == :cascade)
    env.connection.reverse_foreign_keys(env.table_name).each do |foreign_key|
      env.connection.remove_foreign_key(foreign_key.from_table, name: foreign_key.name)
    end
  end
  yield env
end