Report hasn't been filed before.
What version of drizzle-orm are you using?
1.0.0-beta.20
What version of drizzle-kit are you using?
1.0.0-beta.20
Other packages
No response
Describe the Bug
- drizzle-kit
- postgres dialect
When modifying an existing unique constraint, drizzle-kit generate correctly detects the change and reports it in the migration summary.
However, the generated SQL is incorrect: the ADD CONSTRAINT statement is missing the the changes that were made. The migration will silently re-create the old constraint without applying the intended change.
In my specific case i tried adding .nullsNotDistinct() to an existing unique constraint. Below you see the output of the drizzle-kit generate command.
┌─── public.attrition_timeline.attrition_timeline_unique unique changed:
│ nullsNotDistinct: false -> true
├───
│ ALTER TABLE "attrition_timeline" DROP CONSTRAINT "attrition_timeline_unique";
│ ALTER TABLE "attrition_timeline" ADD CONSTRAINT "attrition_timeline_unique" UNIQUE("job_holder_aggregation_id","scenario_id","year");
└───
As you can see the change what detected, but the generated SQL did not add NULLS NOT DISTINCT
Generated (incorrect):
ALTER TABLE "attrition_timeline" DROP CONSTRAINT "attrition_timeline_unique";
ALTER TABLE "attrition_timeline" ADD CONSTRAINT "attrition_timeline_unique" UNIQUE("job_holder_aggregation_id","scenario_id","year");
Expected:
ALTER TABLE "attrition_timeline" DROP CONSTRAINT "attrition_timeline_unique";
ALTER TABLE "attrition_timeline" ADD CONSTRAINT "attrition_timeline_unique" UNIQUE NULLS NOT DISTINCT ("job_holder_aggregation_id","scenario_id","year");
After looking at the code and doing some further testing it seems that any change to a unique constaint is not being picked up. Adding or removing a column for example is also not reflected in the generated SQL.
Report hasn't been filed before.
What version of
drizzle-ormare you using?1.0.0-beta.20
What version of
drizzle-kitare you using?1.0.0-beta.20
Other packages
No response
Describe the Bug
When modifying an existing unique constraint,
drizzle-kit generatecorrectly detects the change and reports it in the migration summary.However, the generated SQL is incorrect: the
ADD CONSTRAINTstatement is missing the the changes that were made. The migration will silently re-create the old constraint without applying the intended change.In my specific case i tried adding
.nullsNotDistinct()to an existing unique constraint. Below you see the output of thedrizzle-kit generatecommand.As you can see the change what detected, but the generated SQL did not add
NULLS NOT DISTINCTGenerated (incorrect):
Expected:
After looking at the code and doing some further testing it seems that any change to a unique constaint is not being picked up. Adding or removing a column for example is also not reflected in the generated SQL.