Repository navigation
Closed
Labels
bug/0-unknownBug is new, does not have information for reproduction or reproduction could not be confirmed.kind/bugA reported bug.topic: mariadbtopic: migratetopic: windows
Description
Bug 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.
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
Reacted by catmeme
Metadata
Metadata
Assignees
Labels
bug/0-unknownBug is new, does not have information for reproduction or reproduction could not be confirmed.kind/bugA reported bug.topic: mariadbtopic: migratetopic: windows


Activity
janpio commentedon May 6, 2021
Can you maybe show the full cycle - initial schema, generated migration file, adapted schema file (with modified model), and then the next migration file that uses the wrong casing? That would help us understand what is going on.
MariaDB on Windows is most probably the culprit here, there are funny things going on with MySQL like databases on Windows quite often which we are partially already handling - probably that is one of the things we are not.
macjuul commentedon May 6, 2021
I've managed to reproduce it with a simple example
Initial schema:
Which generates the following migration:
If I now add a new
statusfield to myUsermodel like so:The following migration will be generated, this time with a lowercase table name:
pantharshit00 commentedon May 6, 2021
Hmm I wasn't able to reproduce this. This is what I get when I generate the migration:
Can you please tell me whether your database is running inside of docker or it is running directly in Windows? MySQL on windows does have some text case related quirks so this might be related to that.
janpio commentedon May 6, 2021
Maybe also see if you can share your MariaDB configuration, especially around things like https://mariadb.com/docs/reference/mdb/system-variables/lower_case_table_names/
How is the table shown in some other database GUI (dbeaver etc) - lower or uppercase?
macjuul commentedon May 6, 2021
After some more testing it does actually look like my local Windows installation is handling the difference in capitalization correctly, however I'm only experiencing issues on my Ubuntu production server
While locally on Windows running
SHOW TABLESreturns all tables in lowercase, on Ubuntu it shows up capitalized. I did check the config files (there seem to be quite a few on ubuntu) however I could not find any reference to the setting, so presumably it is using the default valuepantharshit00 commentedon May 6, 2021
Yeah this is known, by default windows mariadb lowercase everything. I will suggest you run the database in docker for now for development so that it can match the production environment.
You can also change the lower_case setting pointed out by @janpio to match the unix specification.
macjuul commentedon May 6, 2021
Running my local MariaDB in WSL has indeed solved the problem and generates correct migration files. Thanks!
pantharshit00 commentedon May 6, 2021
Closing in favour of #6972