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

Traverse symlinks when resolving migrations #2445

Merged
merged 2 commits into from
Jun 13, 2023

Conversation

tgeoghegan
Copy link
Contributor

When enumerating the source directory seeking migration files, sqlx ignores entries that aren't files. This was previously reported as #614 and fixed in #985 but apparently regressed somewhere along the way. This commit reintroduces the fix from #985 to the current implementation: use std::fs::metadata instead of std::fs::DirEntry::metadata. The former is documented to traverse symlinks; the latter does not.

When enumerating the source directory seeking migration files, `sqlx`
ignores entries that aren't files. This was previously reported as launchbadge#614
and fixed in launchbadge#985 but apparently regressed somewhere along the way. This
commit reintroduces the fix from launchbadge#985 to the current implementation: use
`std::fs::metadata` instead of `std::fs::DirEntry::metadata`. The former
is documented to traverse symlinks; the latter does not.
@tgeoghegan
Copy link
Contributor Author

I would love to add a test to stop this from regressing, but it's not obvious where to do so. It looks like there are tests for migrations in tests/migrate and tests/postgres/migrate.rs, but AFAICT neither gets run when I invoke tests/x.py as instructed by tests/README.md.

@abonander
Copy link
Collaborator

@tgeoghegan tests/x.py is old and not very well maintained. I personally don't use it, and neither does the Github Actions workflow.

tests/migrate asserts that Migrator::new() and migrate!() behave the same, so I reckon that's the best place to put the regression test.

@abonander
Copy link
Collaborator

@tgeoghegan do you have time to write a regression test so I can get this merged? If not, can you tell me if you're mainly symlinking the migrations/ directory itself or the individual files within? With that I can add the regression test myself.

@tgeoghegan
Copy link
Contributor Author

tgeoghegan commented May 15, 2023

@abonander Thank you for the pointers, and apologies for the late reply (I was on vacation). I added a test that I think should do the trick; let's see how it goes in CI.

@abonander abonander merged commit 0c8fe72 into launchbadge:main Jun 13, 2023
@tgeoghegan
Copy link
Contributor Author

🎉 Thank you for reviewing and taking the change!

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

Successfully merging this pull request may close these issues.

2 participants