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

Migration checksum EOL-independent #7101

Closed
andreamatt opened this issue May 17, 2021 · 6 comments
Closed

Migration checksum EOL-independent #7101

andreamatt opened this issue May 17, 2021 · 6 comments
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/schema Issue for team Schema. tech/engines/migration engine Issue in the Migration Engine topic: migrate
Milestone

Comments

@andreamatt
Copy link

Problem

Migrations have a checksum that depends on the EOL char.
I generate migrations on linux, push them, then my collegue on windows has a "migration modified after it was applied" issue.
Our current workaround is adding a .gitattributes so that git treats migrations' sql as binary (without changing newline on checkout).

Suggested solution

Replace the newline char to LF before performing the checksum, so that the checksum is EOL-independent.

@Jolg42 Jolg42 added bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. tech/engines/migration engine Issue in the Migration Engine kind/bug A reported bug. process/candidate team/schema Issue for team Schema. topic: migrate labels May 17, 2021
@pantharshit00 pantharshit00 added bug/2-confirmed Bug has been reproduced and confirmed. and removed bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. labels May 20, 2021
tomhoule added a commit to prisma/prisma-engines that referenced this issue Jul 19, 2021
See code for documentation on the how and why.

Relevant issues:

- prisma/prisma#7398
- prisma/prisma#7101
tomhoule added a commit to prisma/prisma-engines that referenced this issue Jul 19, 2021
See code for documentation on the how and why.

Relevant issues:

- prisma/prisma#7398
- prisma/prisma#7101
tomhoule added a commit to prisma/prisma-engines that referenced this issue Jul 19, 2021
See code for documentation on the how and why.

Relevant issues:

- prisma/prisma#7398
- prisma/prisma#7101
tomhoule added a commit to prisma/prisma-engines that referenced this issue Jul 23, 2021
See code for documentation on the how and why.

Relevant issues:

- prisma/prisma#7398
- prisma/prisma#7101
do4gr pushed a commit to prisma/prisma-engines that referenced this issue Aug 3, 2021
…2101)

* Encapsulate checksum handling into a module in MigrationConnector

* Make checksum comparison try matching with lf and crlf line endings

See code for documentation on the how and why.

Relevant issues:

- prisma/prisma#7398
- prisma/prisma#7101
@Jolg42 Jolg42 added this to the 2.29.0 milestone Aug 3, 2021
@Jolg42
Copy link
Member

Jolg42 commented Aug 3, 2021

A fix just got released in the dev channel on npm (not recommended for production).

If you can try this specific version 2.29.0-dev.20 to confirm it's fixing the issue for you and let us know it will be greatly appreciated! 💚

It will be released next Tuesday in our biweekly release.

@andreamatt
Copy link
Author

Great news, but I'm not sure how to test this without breaking my old migrations.
How will this handle migrations that are already applied to a db? Will it use the old checksum for them?

@Jolg42
Copy link
Member

Jolg42 commented Aug 4, 2021

@andreamatt I checked with @do4gr and this should be backward compatible so it should not break the old migrations. It calculates several checksums and if any matches it will be ok.

prisma/prisma-engines@10a1bec

@Jolg42
Copy link
Member

Jolg42 commented Aug 9, 2021

Fix included in 2.29 release planned for tomorrow, August 10.

@Jolg42 Jolg42 closed this as completed Aug 9, 2021
@krthush
Copy link

krthush commented Aug 9, 2021

just to chime in (as a windows user) been experiencing this problem many times, even tho no changes made at all to the migrations - currently just ignoring all the warnings... for example this is vercel:
image
and then locally:
image

hopefully the fix tomorrow will deal with this (and is backward compatible as you mentioned such that these warnings will go away) - will test and post back

@krthush
Copy link

krthush commented Aug 10, 2021

Amazing just updated prisma and the warnings are gone :D Should hopefully work for anyone else who had the same issue as I and the others...

image

Thanks guys for this! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/schema Issue for team Schema. tech/engines/migration engine Issue in the Migration Engine topic: migrate
Projects
None yet
Development

No branches or pull requests

5 participants