graphile / migrate

Opinionated SQL-powered productive roll-forward migration tool for PostgreSQL.
MIT License
751 stars 58 forks source link

Allow force running of --once if current.sql has not changed #210

Open zacherkkila opened 8 months ago

zacherkkila commented 8 months ago

Feature description

Often we use tricks like select n and increment the number or change current.sql in another way to get it to run.

It would be handy to have a flag to force run --once if the file hasn't changed.

Motivating example

When testing a data migration, it is often very handy to have an idempotent migration that can get run multiple times as you add/change data in your application.

Typical workflow for me in a data migration involves

Though workarounds are simple as described in the feature description, I think it would be a nice add.

Breaking changes

n/a

Supporting development

I [tick all that apply]:

benjie commented 8 months ago

I think essentially we just want to disable this code:

https://github.com/graphile/migrate/blob/bb2f8f9795d4af90c1bc5a19eb411c570d5c9c9e/src/commands/watch.ts#L86-L91

Which is useful to disable in both watch and watch --once modes.

Maybe --always-different (-a) or --no-ignore-unchanged or --no-require-changes or similar might make sense? --force (-f) also makes sense, but it's a bit less specific and limits our future options, perhaps. A --force-when-unchanged flag that --force automatically enables might make sense... but we'd need some more forces (--force-actions) first.

benjie commented 8 months ago

@jemgillam suggests --force-migration which I think is pretty apt - you're forcing the migration to happen even if no changes occurred.