Migration integrity checking #46810
Replies: 2 comments 7 replies
-
A checksum sounds like a good idea in principle, but in practice I suspect this would have to be a hash of the file which might then tend to give false errors if the file has changed in ways that do not change the functionality i.e. Windows CR/LF -> Unix LF or removal of a trailing space or similar. One alternative would be a more complex algorithm which ignores non-functional changes (i.e. multiple consecutive white-space characters, PHP comments etc. - but this might then lead to performance issues. |
Beta Was this translation helpful? Give feedback.
-
We sometimes cleanup/merge data migrations together to improve the tests suite and cleanup code history. We then merge newer migrations (that add columns to existing tables) into the older ones where the table was created. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Some popular DB migration systems like Flyway have a feature which saves a checksum of a migration file when it's being executed to later check if the migration hasn't been changed.
AFAIK this is there to avoid issues when a developer changes a migration that has already been ran on production. Currently in such case Laravel will simply treat the migration as "Ran" and ignore it. These changes will not be applied to the database.
I propose adding a similar mechanism to Laravel migrations.
Changing some already executed migration will result in the following errors:

Some things to consider:
vendor
directory to not fail when some migrations change in packages or in the framework. Nevertheless I think I'd be a good idea to at least warn about this issue by default.Beta Was this translation helpful? Give feedback.
All reactions