Compatibility with sql_generate_invisible_primary_key
MySQL setting on v8.0.32
#20944
Labels
bug/1-unconfirmed
Bug should have enough information for reproduction, but confirmation has not happened yet.
domain/schema
Issue in the "Schema" domain: Prisma Schema, Introspection, Migrations etc.
kind/bug
A reported bug.
topic: azure
topic: migrate
topic: mysql
topic: mysql 8
Bug description
Recently our Microsoft Azure hosted MySQL server infrastructure was upgraded to 8.0.32 from 8.0.30 which had set the MySQL server variable for "sql_generate_invisible_primary_key" from 0 to 1.
We noticed that since that had happened any table creation via scripts generated through prisma migrate for many-to-many joining tables were gaining an extra column being set as the primary key named
my_row_id
.This additional column then causes any subsequent migrations to generate additional scripts to remove these fields. Running this migration then fails with the error:
This version of MySQL doesn't yet support 'existing primary key drop without adding a new primary key. In @@sql_generate_invisible_primary_key=ON mode table should have a primary key. Please add a new primary key to be able to drop existing primary key.'
I'm unsure whether there is anything we can use from a Prisma POV to ensure compatibility with this so that columns are in sync with what the prisma migration files suggest, for the time being we are looking to make sure this setting is set back to 0 to workaround it though. Thankfully we don't think any tables were created with this setting in place in a production setting so we're good to reset DBs accordingly to revert the incompatible changes.
How to reproduce
Expected behavior
No response
Prisma information
Example of many-to-many relationship syntax which causes issue:
Environment & setup
Database: MySQL v8.0.32
Prisma Version
4.11.0
The text was updated successfully, but these errors were encountered: