PrismaP
Prisma2y ago
2 replies
Moray

Introspecting an existing database doesn't handle join tables correctly

I'm in the process of adding Prisma to an existing project with a large existing database (originally created with Prisma 1). I've introspected the database and edited the schema so that the names of the relation fields are cased correctly. I then created an initial migration SQL file as per the guide and marked it as applied.
When I try to create a new migration, I keep getting errors telling me that ALL of my existing JOIN tables are incorrect:
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 `_RoleToTenantUser` table
  [-] Removed foreign key on columns (A)
  [-] Removed foreign key on columns (B)
  [+] Added foreign key on columns (A)
  [+] Added foreign key on columns (B)
  [*] Renamed index `_RoleToTenantUser_AB_unique` to `RoleToTenantUser_AB_unique`
  [*] Renamed index `_RoleToTenantUser_B_index` to `B`

... continued for the other 87 join tables in my schema ...

What's going on here, and how do I fix it?
Was this page helpful?