You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you use JavaScript migrations it is possible to generate an unique SQL string each time when application starts. In this case postgres-migrations will fail because of hash mismatch. It would be nice to have an ability to disable hash checking for some migrations like it's already possible to disable transactions using a special comment string.
Possible real-world scenarious when generated query might be different on every application startup:
Inserting rows with generated by JavaScript UUID values
Inserting rows with current date and/or time values obtained by JavaScript
Inserting salted passwords into the user table (e. g. create a first user after application installation)
Sometimes it's possible to have a workaround moving the value generation to SQL (e. g. use NOW() SQL expression, use pg_crypto module for UUID generation etc), but it's not always either possible or readable (actually complex data generation is the reason to use JavaScript migrations).
The text was updated successfully, but these errors were encountered:
One detail (that might happening who is searching for tips on a similar hash mismatch problem):
Linux users usually checkout git files with LF line endings, while Windows users checkout CRLF line endings.
This causes the hash to have distinct values on Windows and Linux, and makes the migration tool unusable cross-platform (for developers that share a common pg_dump with a common migrations table).
So initially, I just (forked the code) and disabled the whole hash check by commenting out the call to validateMigrationHashes() at
to be done after CRLF -> LF convertion, by replacing the sql string parameter by sql.replace(/\r\n/g, "\n"). (Only for hash calculation, as I am not very sure if multi-line SQL strings can be impacted by this change).
Hope that this helps someone else searching for a similar issue.
If you use JavaScript migrations it is possible to generate an unique SQL string each time when application starts. In this case
postgres-migrations
will fail because of hash mismatch. It would be nice to have an ability to disable hash checking for some migrations like it's already possible to disable transactions using a special comment string.Possible real-world scenarious when generated query might be different on every application startup:
Sometimes it's possible to have a workaround moving the value generation to SQL (e. g. use
NOW()
SQL expression, usepg_crypto
module for UUID generation etc), but it's not always either possible or readable (actually complex data generation is the reason to use JavaScript migrations).The text was updated successfully, but these errors were encountered: