-
-
Notifications
You must be signed in to change notification settings - Fork 143
feat(database): add migration hash checking #1054
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
feat(database): add migration hash checking #1054
Conversation
|
So what exactly is the flow here? Let's say I have a migration file that has changed. Then what? We run |
Yup, that's it. Migrations will not run if existing migrations have been tempered with. It's been a while since I've used more restrict migration libraries (been doing Laravel for a while now), but I believe that's how they do it. We could not have the check run when you do Anyways, definitely open to suggestions here. |
I'd prefer |
|
I'm fine with it being the default mode. Let's not hook into Let's say you make a change to an existing migration during development and run Possibly by running with To me it feels like, by the time this error is triggered, it's already pretty (too) late: we're deploying to production. That's why I suggested adding a warning of some sorts (maybe an error) that's shown when running The end goal here is that people don't update existing migrations, but instead make new ones that apply on top of the original one. I hope I'm making sense 😅 |
I understand your concern. One of the most popular migration libraries (Redgate Flyway) doesn't have a And I don't know how we'd accomplish a warning or something on Tempest's This may not be a huge issue, though. Here's my idea:
Of course, we can skip running that command entirely if We could even improve the |
|
I like the |
2582f44 to
85aa24e
Compare
|
Ping me when ready :) |
Pull Request Test Coverage Report for Build 14116559981Details
💛 - Coveralls |
@brendt Ready! :) |
innocenzi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super cool PR! Is there a reason why validation is opt-in though? I'd prefer having to specify --no-validate to opt-out
@innocenzi I thought we were already avoiding breaking changes (I was wrong 😅 ). What would a good name for the argument be? I'm not a huge fan of What about PS: I hate that github doesn't allow replying to such comments |
I think Brent would agree with me, but you can wait to be sure to avoid having to revert the change
We have support for negating arguments, so it's fine: you can set the current
I'm with you! 😅 |
🤯 |
brendt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, some minor questions, but that's ok.
FYI I'm merging #1076 today, I'll check this PR afterwards to see if anything breaks because of it. If it does, I'll fix it on your branch.
Yeah it's fine, make it true by default :) |
|
I've merged main, let's see whether anything breaks |
No clue what's going on here. When running the actual command, I get the console error. When running the tests, the `$this->console->error(` line is executed. But on this particular test it looks like console is not printing anything. Very weird stuff.
|
Thanks! |
This PR adds Hash-checking to database migrations - preventing migration files from being tempered with only if the
--validateflag is used.Note
Documentation update PR: tempestphp/tempest-docs#68