Remove rails model after migration

后端 未结 3 1449
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-06 05:38

It seems strange to me, that creation of model, running migration, destroying it, and creating again same model reports SQL exception:

project|master ⇒ rails g m         


        
3条回答
  •  抹茶落季
    2021-02-06 06:14

    according to your migration error there must be something wrong with the migration files, moreover the one which referring to create names table.

    please look at this file, at your change method.

    the change method in a migration file is supposed to execute a DB code, that DB code can do some operations on the DB, and that same code on the change supposed to be right to do the rolling back.

    if you want to separate between the two you should put the code on the up method which will perform operations on the DB, and on the down method the opposite rolling operations.

    i would suggest that you delete all the files on the migration including the one that cause the problem, and write them correct.

    if you need help please post your migration file.

    please also take a look at the guides: http://guides.rubyonrails.org/migrations.html

提交回复
热议问题