Drizzle TeamDT
Drizzle Team•17mo ago
Ganbatte

Help Needed with Drizzlekit Migration Issue

I've encountered an issue where I manually deleted a table in Drizzlekit Studio using DROP TABLE "orderProduct". This was due to a bug inside my orderProduct where I had both an "orders" and "order" column, each referencing the "orders" table, and I couldn't remove them.

I'm not fully understanding how migrations work in Drizzlekit, which is why I'm reaching out. When I run bunx drizzle-kit generate and migrate, the table isn't being regenerated along with its relations.
Bunx drizzle-kit generate output:
14 tables orderProduct 5 columns 0 indexes 3 fks orders 7 columns 0 indexes 1 fks ..... No schema changes, nothing to migrate 😴

Bunx drizzle-kit migrate output:
No config path provided, using default 'drizzle.config.ts' Reading config file 'C:\...\drizzle.config.ts' Using 'postgres' driver for database querying [⣟] applying migrations...{ severity_local: 'NOTICE', severity: 'NOTICE', code: '42P06', message: 'schema "drizzle" already exists, skipping', file: 'schemacmds.c', line: '132', routine: 'CreateSchemaCommand' } { severity_local: 'NOTICE', severity: 'NOTICE', code: '42P07', message: 'relation "__drizzle_migrations" already exists, skipping', file: 'parse_utilcmd.c', line: '207', routine: 'transformCreateStmt' } [⡿] applying migrations...PostgresError: relation "orderProduct" does not exist severity_local: 'ERROR', severity: 'ERROR', code: '42P01', file: 'namespace.c', line: '434', routine: 'RangeVarGetRelidExtended' } error: script "migrate" exited with code 1

How can I fix this? The schema clearly defines what should be generated. Any help would be greatly appreciated!
Was this page helpful?