Rails uses the default method to migrate migration down. In which scenario would I ever want to return to migration, though?
Some thoughts:
In the development or production process, I always have a snapshot of my database to return before I even start the migration. Especially for migrations that perform data conversion, in most cases I find that snapshot recovery is even faster than the migration return. (So I would never do it in a hurry!)
If the migration failed, it will either:
- failure during an exception in a non-transactional database and thus leaving the database broken or
- transaction exception and rollback fail, and therefore there is no need to return otherwise.
If the changes made (or at the end of development), and later become an error, I would correct my error with a new migration. I would not give up the old. In development, I will simply remove the migration.
I also found that the down method introduces additional code that I repeat in, and therefore may introduce new errors. This is contrary to the DRY principle.
So, I'm curious what professionals are, because I can’t come up with.
source
share