Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
3 tasks
zacherkkila opened this issue Feb 29, 2024 · 2 comments
Open
3 tasks

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

zacherkkila opened this issue Feb 29, 2024 · 2 comments

Comments

@zacherkkila
Copy link

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

  • Keep the original data I am moving in place (if possible)
  • Run the migration, check for base functionality, compare against existing
  • Add more data to test the migration and run it again (rinse and repeat as needed)
  • Once tested, add code to cleanup the original data, test again, and ship

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]:

  • am interested in building this feature myself
  • am interested in collaborating on building this feature
  • [ x ] am willing to help testing this feature before it's released
  • am willing to write a test-driven test suite for this feature (before it exists)
  • [ x ] am a Graphile sponsor ❤️
  • [ x ] have an active support or consultancy contract with Graphile
@zacherkkila zacherkkila changed the title Allow force running of --once, even if no migration is necessary Allow force running of --once if current.sql has not changed Feb 29, 2024
@benjie
Copy link
Member

benjie commented Mar 4, 2024

I think essentially we just want to disable this code:

migrationsAreEquivalent =
currentBodyMinified === previousBodyMinified;
// 4: if different
if (!migrationsAreEquivalent) {
await executeActions(

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
Copy link
Member

benjie commented Mar 4, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants