kawadhiya21 / mysql-migrations

A tool to use with mysql package to maintain migrations
MIT License
31 stars 25 forks source link

Include all unapplied migrations in "up" command #14

Closed Technoguyfication closed 3 years ago

Technoguyfication commented 3 years ago

Currently, the script only applies migrations newer than the latest migration applied in the database. This causes issues for developers who apply newer migrations before older ones, like when you merge an older branch into a newer one that's already been migrated.

Example:

I have master with migrations 100, 200, and 300. Someone forks this branch and creates migration 400, but before they're finished working on their branch, I've already created migration 500 and pushed it to production. When their fork is merged back into master, migration 400 will never be applied because I've already applied 500. This is an issue.

I wasn't sure what the best behavior is in this scenario. Maybe the script should always apply migrations less than the highest applied migration, even when downgrading the database. This fix works for my uses though, and I may extend it in the future.

New behavior: When upgrading the database, all unapplied migrations will be included in the upgrade. Entering a limiting argument will limit these steps as normal.

kawadhiya21 commented 3 years ago

I have gotten a previous request for this too. I will do this with a flag if you don't mind.

kawadhiya21 commented 3 years ago

I have merged and published it. Use it in production with caution. Haven't written production level code.