Rails remove old models with migrations

后端 未结 7 1929
傲寒
傲寒 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:19

    If you'd rather have a manual based answer:

    First run the following command to identify which migrations you want removed:

    rake db:migrate:status
    

    Feel free to grep -i on it too if you're confident of your naming scheme.

    Make note of all the "add x to model name" and similar alterations to your Model. These can be removed using:

    rails d migration AddXToModelName
    

    Do this for every migration besides the initial create migration. The following command will take care of the initial create migration and the files associated with the model:

    rails d model ModelName
    

提交回复
热议问题