parapapao
parapapao

Reputation: 5

rails db:migrate doesn't work after altering the database manually

I am still new to rails and I have some questions regarding rails migration.

I am using rails 5, windows 8. I generated a model and wrote some code which creates a table with columns. Then I deleted that table from my development db (MySQL) and tried to execute db:migrate again to see if it would create the table and columns written in the migration file. After executing db:migrate, it didn't show any messages in the terminal and it did not create the table and the columns.

Based from my observation, deleting the version of my migration file from schema_migrations and running db:migrate once again, it worked and created the table and columns.

I would like to ask the pros of rails development on why is this happening and what should I do when I start to develop a large database model.

I would also like some suggestions about great resource materials for learning ruby on rails.

Thanks!

Upvotes: 0

Views: 836

Answers (1)

Argonus
Argonus

Reputation: 1035

Its because rake db:migrate is running only migrations for the current env that have not run yet. So if you run db:migrate and then manually delete table form DB, your app does not know that.

MIgration Guides

Upvotes: 1

Related Questions