migrate icon indicating copy to clipboard operation
migrate copied to clipboard

Support for adding applied migration in schema_migrations table

Open shantanu28sharma opened this issue 2 years ago • 3 comments

Due to multiple team members working with the same application we need to track what all migration have been applied in their local system compared to production. Currently schema_migrations table contains the record of the latest applied migration but that is not helpful for rollback because their is no information regarding how many steps rollback is needed before the incoming migrations can be applied.

This issue has been mentioned #510 here but there is no update if this feature will be supported in future. Ideally it should be like sql-migrate which stores previously run migrations.

shantanu28sharma avatar Dec 28 '21 08:12 shantanu28sharma

This is a very serious problem for migrate. It represents a massive foot gun.

Scenario: Two devs are working on branches and they both add migrations. The branch with a migration with a later timestamp merges and deploy's first. The branch with the earlier timestamped migration merges and deploy's

Result: The earlier timestamped migration does not run at all, and migrate does not complain about it at all.

nickpalmer avatar May 17 '22 21:05 nickpalmer

duplicate https://github.com/golang-migrate/migrate/issues/179

I described a workaround that has been quite successful at catching "invalid" migration timestamps on my team as we have grown https://github.com/golang-migrate/migrate/issues/179#issuecomment-947094417

dillonstreator avatar Jun 07 '22 03:06 dillonstreator

What happens when you run the down command? If I have 20 migration pairs (up/down) for a project that has been going for a while now, creating tables, modifying column types, adding columns, etc, if I run the down command its going to run all down migrations for all 20 files?

redeemefy avatar Mar 16 '23 17:03 redeemefy