[BUG]: Drizzle edits timestamp fields and recreates FK constraints when migrating from prisma
Author: jansedlonCreated Apr 8, 2024Updated Sep 29, 2026
Labelsbugdrizzle/kitpriority
What version of drizzle-orm are you using?
0.30.7
What version of drizzle-kit are you using?
0.20.14
Describe the Bug
- Have an existing database generated by prisma
- Have a db column that has
Json[]type - Install Drizzle
- Run
drizzle-kit introspect:pg - Drizzle generates initial migration (one column should have
unknown().arra()column type) - Fix it to
json().array() - Run
drizzle-kit generate:pg
Drizzle kit generates a new migrations altering all createdAt and updatedAt columns to
ALTER TABLE "{tableName}" ALTER COLUMN "{updatedAt or createdAt}" SET DEFAULT now();--> statement-breakpointDrizzle kit also drops all FK constraints and then recreates them
ALTER TABLE "{tableName}" DROP CONSTRAINT "{fKeyConstraintName}";
DO $$ BEGIN
ALTER TABLE "{tableName}" ADD CONSTRAINT "{differentFKeyConstraint" FOREIGN KEY ("{column}") REFERENCES "{table}"("{column}") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;The generated migration has about 700 LOC so it would be tedious to check if all constraints are not valid and it doesn't mess up something.
Expected behavior
It shouldn't create any migration since i haven't changed anything
Environment & setup
No response
Source: drizzle-team/drizzle-orm