Skip to content
New issue

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

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

Already on GitHub? # to your account

Detect migrations automatically in TestCase #347

Merged
merged 3 commits into from
Jan 6, 2025

Conversation

ralphjsmit
Copy link
Contributor

@ralphjsmit ralphjsmit commented Jan 3, 2025

Hello! Thank you for the nice package, I've used it a lot on (I think) all my packages!

Currently, in the TestCase file, people have to manually provide their migration paths. I've always found this a bit surprising/not-DX friendly, as it is very easy to just get and run all migrations instead of manually needing to provide the full path(s). Therefore, this PR replaces it with a simple snippet to just run all migrations in the database/migrations path.

The snippet is using the File::allFiles() method. This is fine, the only thing is that people would need to import the file after uncommenting for the most clean result. Alternatives like the scandir() function are also not great, as scandir() is returning results like . or .. and then the snippet to un-comment would start to contain if-conditions, even less nice.

Thanks!

@freekmurze
Copy link
Member

Nice, thanks!

@freekmurze freekmurze merged commit f6b37a4 into spatie:main Jan 6, 2025
1 check passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants