代码之家  ›  专栏  ›  技术社区  ›  Brian

Ruby on Rails Rake数据库:删除

  •  0
  • Brian  · 技术社区  · 14 年前

    是否有命令删除数据库中的特定表,而不是全部删除?

    或者更新数据库表的方法

    谢谢您。

    2 回复  |  直到 11 年前
        1
  •  6
  •   Pär Wieslander    14 年前

    查看 Ruby on Rails Migration Guide . 例如,要在迁移中删除表,请执行以下操作:

    class DropProducts < ActiveRecord::Migration
      def self.up
        drop_table :products
      end
    
      def self.down
        raise ActiveRecord::IrreversibleMigration
      end
    end
    
        2
  •  1
  •   JShoe    11 年前

    这可以通过以下命令使用迁移来实现:

    def self.up    
      drop_table :table_name   
    end