Repository navigation
Open
Labels
bug/1-unconfirmedBug should have enough information for reproduction, but confirmation has not happened yet.kind/bugA reported bug.tech/enginesIssue for tech Engines.topic: mariadbtopic: windows
Description
Bug description
When creating a migation on Windows (with MariaDB), the casing of the table names is not consistent. Sometimes it uses lowercase, sometimes pascalcase in the warnings when renaming a column.
This is linked to #6972 as the generated migration will fail on linux-based OSes.
You can find all info and a reproduction in my repository.
How to reproduce
See my repo for full instructions and a reproduction.
Basically, you need to:
- use windows
- rename a column in the prisma schema
- generate a migration using
npx prisma migrate dev
Expected behavior
All table names are in PascalCase because that does work fine on Windows and doesn't crash on linux (like with the lowercase names).
Prisma information
Environment & setup
- OS: Windows 10
- Database: MariaDB
- Node.js version: v17.4.0
Prisma Version
prisma : 3.10.0
@prisma/client : Not found
Current platform : windows
Query Engine (Node-API) : libquery-engine 73e60b76d394f8d37d8ebd1f8918c79029f0db86 (at node_modules\@prisma\engines\query_engine-windows.dll.node)
Migration Engine : migration-engine-cli 73e60b76d394f8d37d8ebd1f8918c79029f0db86 (at node_modules\@prisma\engines\migration-engine-windows.exe)
Introspection Engine : introspection-core 73e60b76d394f8d37d8ebd1f8918c79029f0db86 (at node_modules\@prisma\engines\introspection-engine-windows.exe)
Format Binary : prisma-fmt 73e60b76d394f8d37d8ebd1f8918c79029f0db86 (at node_modules\@prisma\engines\prisma-fmt-windows.exe)
Default Engines Hash : 73e60b76d394f8d37d8ebd1f8918c79029f0db86
Studio : 0.458.0
Reacted by Samuel J.F. Smeys and Bahaa Homecuz
Reacted by Nathan Adhitya
Metadata
Metadata
Assignees
Labels
bug/1-unconfirmedBug should have enough information for reproduction, but confirmation has not happened yet.kind/bugA reported bug.tech/enginesIssue for tech Engines.topic: mariadbtopic: windows
Activity
[-]Inconsistent casing in [/-][+]Inconsistent casing in Migrations[/+]RobertSandiford commentedon Apr 10, 2022
Experiencing the same issue.
RobertSandiford commentedon Apr 11, 2022
TLDR: Set "lower_case_table_names" to 2 on windows in my.cnf/my.ini under [mysqld]. Prisma can avoid issues by always taking table name casing from schema not the database.
Windows has a case-insensitive file system. Correspondingly MySQL / MariaDB on windows has a server setting of lower_case_file_system = ON
Read "lower case file system" as "case insensitive file system". This value can't be changed.
On windows "lower_case_table_names" defaults to 1, which means that table names are converted to lower case.
I believe the issue in prisma occurs because during alterations to tables, the table name is read from the database, not the schema, and the lower case form is used in migrations, while the schema form is using in create statements (there may be some more nuances as to exactly where each approach is used).
The problem can be solved easily by setting "lower_case_table_names" to 2 which retains upper case characters in table names, and so too in prisma migrations. Actual table lookups are still case-insensitive (table names are converted to lowercase during comparisons, so would have a small perfomance hit). This can be set in a config file, e.g. my.cnf or my.ini, under [mysqld]
Prisma can check for lower_case_file_system = ON and lower_case_table_names = 1 to identify the offending setup.
SHOW VARIABLES WHERE Variable_name = 'lower_case_file_system'
Prisma can either warn about the issue, or alternatively resolve the issue entirely by looking up the schema for the intended case for ALTER statements instead of taking the casing from the database. Casing between migrations and the actual database would differ on windows, but I see no problem with that given comparisons will be case-insensitive. This would not be an ideal solution if a windows server were to be used in production, but is fine for development.
Prisma should not lowercase table names in this scenario because it would break interop between developers on different OSs. However, lowercasing all table names throughout would be an alternative solution, that would be preferable if windows was to be used in production.
bhuynhdev commentedon Mar 12, 2023
Experiencing this same problem. As seen here in this migration file warning, when I try to rename column and recreate index. The DROP INDEX (and the first warning sentence) uses
notewhereas CREATE INDEX usesNoteRobertSandiford commentedon Mar 12, 2023
Solution you can use above for MySQL/MariaDB. I suppose you will also need to reset your DB afterwards
erjenkins29 commentedon Sep 26, 2023
I also ran into this today -- prisma 5.3.1, mysql, and developing on windows. I'm not seeing whether this was resolved or attempted to be resolved?
Aloysius999 commentedon Aug 15, 2024
This issue appears not to have been fixed.
I encountered this problem today on Ubuntu using Prisma 5.18.0.
Changing the value of
lower_case_table_namesis not easy on a DB that has already been deployed and used - it is a setting that is configured during initial deployment.ViniciusLeviVL commentedon Aug 15, 2024
Same issue here.
hkiame commentedon Sep 13, 2024
facing the same issue
SamuelSmeys commentedon Sep 29, 2024
Facing the same issue on my end as well. I'm on MacOs Sonoma with Prisma 5.20
alfanzain commentedon Jan 9, 2025
Facing the same issue on Windows 10 with Prisma 5.20
abdullahsaif99 commentedon Feb 14, 2025
I am facing same issue. Let's say table name is User. In migration it changes to user. Moreover, it appears same for each one.
R1NEJ0 commentedon Apr 10, 2025
Same issue on windows 11 with prisma 6.5
bahaa-homecuz commentedon Dec 16, 2025
i have the same issue