drizzle-team / drizzle-orm

Headless TypeScript ORM with a head. Runs on Node, Bun and Deno. Lives on the Edge and yes, it's a JavaScript ORM too 😅
https://orm.drizzle.team
Apache License 2.0
21.44k stars 484 forks source link

[BUG]: #2503

Open mitchellwarr opened 2 weeks ago

mitchellwarr commented 2 weeks ago

What version of drizzle-orm are you using?

0.31.2

What version of drizzle-kit are you using?

0.22.7

Describe the Bug

Running a migration with composite primary keys will break.

In drizzle-kit bin.cjs the issue sits with

prepareDeleteCompositePrimaryKeyPg = (tableName, schema5, pks, json1) => {
      return Object.values(pks).map((it) => {
        return {
          type: "delete_composite_pk",
          tableName,
          data: it,
          schema: schema5,
          constraintName: json1.tables[`${schema5}.${tableName}`].compositePrimaryKeys[PgSquasher.unsquashPK(it).name].name
        };
      });
    };

The issue is schema5 is undefined leading to json1.tables['.table'] instead of json1.tables['public.table']

Expected behavior

You should be able to generate migrations when your table has composite primary keys

Environment & setup

No response

AndriiSherman commented 2 hours ago

please check drizzle-kit@0.22.8, should have the fix for that