문제

I created an integer for a phone number, and then learned that it is better to consider it as a string due to it's size. I decided then to change directly the migration and apply db:reset instead of adding a new migration since the project is only on my computer at this moment. Db:reset worked but it doesn't seem that my database changed.

It raised a lot of questions :

Is there a command to analyse a database and identify the types of its columns ?

Does db:reset allow to modify a migration, like after rolling back a migration ?

Even though it isn't preferable, what are the conditions to modify directly a migration ?

도움이 되었습니까?

해결책

The db:reset task resets the database by dropping the database and then loading schema.rb - it does not run migrations again. If you dropped the database, then created it and ran db:migrate then you should get the desired outcome

다른 팁

Change the field as string in migration, then run the commands:-

rake db:drop
rake db:create
rake db:migrate

And it will change the field type from integer to string.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top