Rails remove old models with migrations

后端 未结 7 1917
傲寒
傲寒 2021-02-13 01:41

I have a bunch of rails models that i\'m re-writing into a single model to simplify my code and reduce unnecessary tables.

I\'m wondering what the best way to delete a

相关标签:
7条回答
  • 2021-02-13 02:25

    All in one solution.

    Run the following commands:

    rails destroy model ModelName
    rails g migration DropTableModelName
    

    The former will generate a new migration file which should looks like this:

    class DropTableModelName < ActiveRecord::Migration
      def change
        drop_table :model_name
      end
    end
    

    Now run db:migrate and you're done.

    0 讨论(0)
提交回复
热议问题