Hello, this is tt_tsutsumi. This time too, I will explain how to change the migrate file. I hope this article helps somebody.
https://qiita.com/tt_tsutsumi/items/ea8bc346d5b9cb21e05b
↑↑↑
In the previous article, you can change the migrate file, etc. Among them, there was a story that only one file can be downed, but This time, I will describe how to bring down any file at once.
$ rails db:migrate:status
Status Migration ID Migration Name
--------------------------------------------------
up year/month/day Devise create users
up year/month/day Create spots
Add ** STEP = 2 ** after the previous ** rails db: rollback ** and execute. The meaning of this code is to down ** the file from the current file up to ** 2 steps ago. When executed, it will be as follows.
$ rails db:rollback STEP=2
$ rails db:migrate:status
Status Migration ID Migration Name
--------------------------------------------------
down year/month/day Devise create users
down year/month/day Create spots
If you want to change or delete multiple files at once, it is faster to use STEP. However, please note that if you do not use it after checking it, everything may go down. 3. rails db:migrate
When the changes are complete, save and do ** rails db: migrate **. Even if you go back several steps in STEP, all will be changed to up in one migrate.
$ rails db:migrate
$ rails db:migrate:status
Status Migration ID Migration Name
--------------------------------------------------
up year/month/day Devise create users
up year/month/day Create spots
This completes batch modification and saving of migrate files. Thank you for visiting !!
Recommended Posts