Sha256: 708fb69c716f7e7d8a479c20d252604f424acfd11229e1ac5b8d6aa5e4dd3087

Contents?: true

Size: 668 Bytes

Versions: 1

Compression:

Stored size: 668 Bytes

Contents

module SchemaPlus::Tables
  module ActiveRecord
    module ConnectionAdapters
      module Mysql2Adapter

        # implement cascade by removing foreign keys
        def drop_table(name, options={})
          if options[:cascade]
            reverse_foreign_keys(name).each do |foreign_key|
              remove_foreign_key(foreign_key.from_table, name: foreign_key.name)
            end
          end

          sql = 'DROP'
          sql += ' TEMPORARY' if options[:temporary]
          sql += ' TABLE'
          sql += ' IF EXISTS' if options[:if_exists]
          sql += " #{quote_table_name(name)}"

          execute sql
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
schema_plus-2.0.0.pre6 lib/schema_plus/tables/active_record/connection_adapters/mysql2_adapter.rb