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
The migration 20210501202953_name_of_previous_migration
was modified after it was applied
#7077
Comments
Can you please describe the steps we need to follow to get to the same situation? The problem here is that it tells you |
As I said I just changed the schema and added a And I just tried with a new Blitz app and added a
When I add field with default, like this: Out put of prisma version:
But with my production code and prisma Version: I am wondering the detection of modification is implemented? Is checking the checksum of the migration file or something like that? If so, then autoformat or changing from CR to LF could also trigger that modification detection. Soon I will write and test after I downgraded to 2.20.1 Thanks for reviewing this issue! |
I had slightly modify the schema to downgrade from 2.21.2 to be able to see same message on 2.20.1
Content of that migration file is: -- CreateEnum
CREATE TYPE "ConsentType" AS ENUM ('NEWSLETTER', 'TERMS');
-- AlterTable
ALTER TABLE "UserConsent" ADD COLUMN "ip" TEXT;
-- AlterTable
ALTER TABLE "Userprofile" ADD COLUMN "newsletter" BOOLEAN NOT NULL DEFAULT false; And I checked the database. This changes were already applied as I had already run this migration before. My new change is adding a boolean field with default value to another model. Which causes the problem in both versions I have testet so far. Any idea how I could possibly continue? Maybe somehow tell prisma client to ignore this modification? Or should I just delete all migrations? To make it easy to keep the data and create new migrations? |
@kivi Can you share your the contents of your migrations folder? I wasn't able to reproduce this in |
Hi @pantharshit00, sorry can not share content of my migrations directory. I almost sure it is the checksum, that is saved in migrations table that differs after committing oder pulling from repository. I think a pragmatic approach could be that the file get's created with LF only.
More details about gitattributes: https://www.aleksandrhovhannisyan.com/blog/crlf-vs-lf-normalizing-line-endings-in-git/#autocrlf-true Here is how could be reproduced:Change git config
Now you can run SuggestionWhy I suggesting a pragmatic solution? I guess most Users are using a modern tool like vsCode and they can handle LF as good as CRLF. But I have set autocrlf based on some documentations about Formatting and Whitespaces: https://www.git-scm.com/book/en/v2/Customizing-Git-Git-Configuration So prompting to add .gitattributes with that fix while running |
thanks @kivi. It saved me massive time. I used |
I will close this in favour of #7101 Thanks for reporting everyone |
Bug description
When I try to run migrations after changes in the schema file, I am getting almos always an error message:
The migration ... was modified after it was applied
.I can continue but I will loose all data after confirming resetting the database.
How to reproduce
I am using Blitz.js with Prisma, so the command looks a bit different.
I change the
shema.prisma
file.Then I run
migration dev
with prisma cli tool in PowerShellblitz prisma migrate dev --create-only
And I have the same issue, with:
npx prisma migrate dev
Expected behavior
The migration files should be created with no warnings and without suggesting to reset the database. Without this message:
We need to reset the PostgreSQL database
Prisma information
The change I made in a model.
model Event { id Int @id @default(autoincrement()) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt title String titleShort String? ..... + private Boolean @default(true) published Boolean @default(false) .... }
Environment & setup
The text was updated successfully, but these errors were encountered: