I'm getting "Your database schema is not in sync with your migration history" every time I change something #23137
Replies: 5 comments 5 replies
|
Hi @tigran1100 👋 Thank you for raising this question. When you attempt to run If you do not want to reset the database, you can baseline the database by using prisma migrate diff to compare your schema and database, and save the output into a SQL file. The steps to baseline are written in the documentation. If this answers your question, it would be great if you could mark this Discussion as answered to indicate that it has been resolved. Otherwise please let us know how else we can help you further or close the Discussion if it was resolved in some other way 🙏 |
|
Hi there, To keep our discussions organized and focused on the most relevant topics, we’re reviewing and tidying up our backlog. As part of this process, we’re closing discussions that haven’t had any recent activity and appear to be outdated. If this discussion is still important to you or unresolved, we’d love to hear from you! Feel free to reopen it or start a new one with updated details. For more details about our priorities and vision for the future of Prisma ORM, check out our latest blog post: https://www.prisma.io/blog/prisma-orm-manifesto. Thank you for your understanding and being part of the community! |
|
This is absolutely one of the reasons I regret choosing Prisma, where the hell is your history saved? The default shadow database according to your documentation is auto created everytime I run the migrations, but the historical updates are nowhere to be found which keeps causing this issue for me |
|
i have the answer to prevent that bug : you just have to remove all uppercase letter in you db name, like changing Issue_tracker to issue_tracker. i made a github issue (#27712 ) |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Bug description
Every time I want to make a change in my schema.prisma file, the terminal is saying that I have to reset my database.
For example this is my "Issues" model
When I add new column, for example`
just_test_column String @db.Text
And the I run
npx prisma migrate dev, it's asking me to reset my database.How to reproduce
This is the error message`
PS E:\Win11Dev\Xampp\htdocs\issue-tracker-v4> npx prisma migrate dev
Environment variables loaded from .env
Prisma schema loaded from prisma\schema.prisma
Datasource "db": MySQL database "Issue_tracker" at "localhost:3306"
Drift detected: Your database schema is not in sync with your migration history.
The following is a summary of the differences between the expected database schema given your migrations files, and the actual schema of the database.
It should be understood as the set of changes to get from the expected schema to the actual schema.
[*] Changed the
accounttable[-] Removed foreign key on columns (userId)
[*] Changed the
issuetable[-] Removed foreign key on columns (assigned_to_user_id)
[*] Changed the
sessiontable[-] Removed foreign key on columns (userId)
× We need to reset the MySQL database "Issue_tracker" at "localhost:3306"
Do you want to continue? All data will be lost. ... no
Reset cancelled.
Expected behavior
I expect prisma to not require reset every time I change something
Prisma information
Environment & setup
Prisma Version
All reactions