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 users to fail when there are bad migration paths in their source #1048

Open
dnisenbaum1 opened this issue Mar 9, 2024 · 3 comments
Open

Comments

@dnisenbaum1
Copy link

Is your feature request related to a problem? Please describe.
When initializing migrate with a file source, we noticed that migrate silently ignores bad file paths (i.e. 003_some_migration.up copy.json). We don't expect migrate to allow these bad filenames to run, but we were stumped for some time on why a particular migration didn't run (we hadn't noticed the bad filename).

Describe the solution you'd like
We would like to initialize migrate in a more "strict" way, i.e. fail when there are bad filepaths in the source location, or provide us with a function to validate our source location before initializing migrate.

Describe alternatives you've considered
What we currently do is use the regex from source/parse.go in a validate function and run it against our migration directory.

Additional context
Happy to elaborate more if needed.

@atljoseph
Copy link

OMG this is such an annoying thing. I just lost 2-3 hours to something that should be basic. Thank you for reporting.

@atljoseph
Copy link

If one can make migrations invisible by incorrect filename, then that should be advertised more prevalently in the docs.

There should also be more flexibility in the naming structure of migrations.

Why so strict without declaring what the parameters of strictness are more loudly?

Seems like this issue makes it kindof difficult to test that your migrations are being "seen" by the library, too.

@atljoseph
Copy link

0001_test.up.sql - Works

0001-test.up.sql - Doesn't work

  • What if i like dashes?

0001-test-up.sql - Doesn't work

  • What if i don't like all the dots?

0001-up-test.sql - Doesn't work

  • What if i prefer to see "up"/"down" in a different spot?
  • This is actually how i would envision people using it it, day in/out over years.
  • After a unique identifier, Up/Down should appear as far to the left as possible.

0001_up_add-test-table.sql - Doesn't work

  • A variation that might be easier for eyes to parse.

Not everyone uses the same regex when they think up file names that apply to their product.
Flexibility == !Annoyed
!Annoyed == Acceptance

Please fail migrations when there are files that don't conform to the regex, or be more flexible.

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