Inconsistent table names in migrations
See original GitHub issueBug description
The capitalization for generated table names appears to be inconsistent. When creating new tables, the migrations contain the capitalized and correct version of the table names, however altering the model causes an alter migration to be created with a fully lowercase version of the table name. This causes issues where migrate fails because it cannot find the right table.
Creation migration:
Alter migration:
This causes my production setup to break with The underlying table for model 'report' does not exist.
How to reproduce
- Create a migration adding a new table
- Create a migration that alters the previously created table
- The generated alter query will use a lowercase version of the table name
Expected behavior
The migration files should contain the actual model names, which in my case are capitalized
Environment & setup
- OS: Windows 10
- Database: MariaDB
- Node.js version: v12.18.4
- Prisma version:
prisma : 2.22.0
@prisma/client : 2.22.0
Current platform : windows
Query Engine : query-engine 60cc71d884972ab4e897f0277c4b84383dddaf6c (at node_modules\@prisma\engines\query-engine-windows.exe)
Migration Engine : migration-engine-cli 60cc71d884972ab4e897f0277c4b84383dddaf6c (at node_modules\@prisma\engines\migration-engine-windows.exe)
Introspection Engine : introspection-core 60cc71d884972ab4e897f0277c4b84383dddaf6c (at node_modules\@prisma\engines\introspection-engine-windows.exe)
Format Binary : prisma-fmt 60cc71d884972ab4e897f0277c4b84383dddaf6c (at node_modules\@prisma\engines\prisma-fmt-windows.exe)
Default Engines Hash : 60cc71d884972ab4e897f0277c4b84383dddaf6c
Studio : 0.379.0
Preview Features : orderByRelation
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Inconsistent casing in Migrations #12053 - prisma ... - GitHub
I believe the issue in prisma occurs because during alterations to tables, the table name is read from the database, not the schema,...
Read more >Flutter Drift library inconsistency found while naming table and ...
I want my table names to be specific as I am migrating from Native Android Room database to Flutter using Drift library for...
Read more >How to fix inconsistency between the snapshot and migrations?
Hello,. There is an inconsistency when editing relationships between entities. I also deleted a migration, How can I fix this inconsistency?
Read more >Table names inconsistent across platforms - concrete5
I checked MySQL on XAMPP and found that all the table names are lower case. Meaning the backup did work in XAMPP but...
Read more >Rename table without downtime - GitLab Docs
After running the migration locally, check if there are inconsistently named indexes ( db/structure.sql ). Those can be renamed manually in a separate...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve managed to reproduce it with a simple example
Initial schema:
Which generates the following migration:
If I now add a new
status
field to myUser
model like so:The following migration will be generated, this time with a lowercase table name:
Closing in favour of https://github.com/prisma/prisma/issues/6972