© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•16mo ago
Ganbatte

How to Handle Incorrect Schema Generation with Drizzle?

Hi everyone! What is the usual practice when I generate an incorrect schema with Drizzle and can't successfully migrate? Is there a command to delete the previous migration/generation? Because no matter what I change afterward, it keeps throwing the same error.

For example, I have two tables that I linked together, but I later noticed that one has an int column and the other has text. Even if I fix the schema, regenerate it, and try to migrate again, it still throws the same error. How should I properly handle this? Thanks in advance!

Error example:
  severity_local: 'ERROR',
  severity: 'ERROR',
  code: '42804',
  detail: 'Key columns "dishID" and "id" are of incompatible types: integer and text.',
  where: 'SQL statement "ALTER TABLE "topping_dish" ADD CONSTRAINT "topping_dish_dishID_dish_id_fk" FOREIGN KEY ("dishID") REFERENCES "public"."dish"("id") ON DELETE cascade ON UPDATE no action"\n' +
    'PL/pgSQL function inline_code_block line 2 at SQL statement',
  file: 'tablecmds.c',
  line: '9339',
  routine: 'ATAddForeignKeyConstraint'
  severity_local: 'ERROR',
  severity: 'ERROR',
  code: '42804',
  detail: 'Key columns "dishID" and "id" are of incompatible types: integer and text.',
  where: 'SQL statement "ALTER TABLE "topping_dish" ADD CONSTRAINT "topping_dish_dishID_dish_id_fk" FOREIGN KEY ("dishID") REFERENCES "public"."dish"("id") ON DELETE cascade ON UPDATE no action"\n' +
    'PL/pgSQL function inline_code_block line 2 at SQL statement',
  file: 'tablecmds.c',
  line: '9339',
  routine: 'ATAddForeignKeyConstraint'
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Drizzle-Kit: incorrect schema.ts being used
Drizzle TeamDTDrizzle Team / help
3y ago
Drizzle / PlanetScale : (How to properly handle replicas)
Drizzle TeamDTDrizzle Team / help
2y ago
How to handle adding new columns to schema?
Drizzle TeamDTDrizzle Team / help
3y ago