Rails : Create a drop table cascade migration

前端 未结 3 2040
滥情空心
滥情空心 2021-02-18 18:52

How do I force a DROP TABLE CASCADE in a Rails 3.2 migration?

Is there an option to pass to drop_table(\"table_name\")?

3条回答
  •  伪装坚强ぢ
    2021-02-18 19:23

    Put a file in your initializers directory called postgres.rb then did. This works for rails 4.1 anyway.

    module ActiveRecord
        module ConnectionAdapters # :nodoc:
            module SchemaStatements
                def drop_table(table_name, options = {})
                    execute "DROP TABLE  #{quote_table_name(table_name)} CASCADE"
                end
            end
        end
    end
    

提交回复
热议问题