drizzle-team / drizzle-team/drizzle-orm
[BUG]: drizzle-kit will incorrectly apply constraints if names are too long without warning
- Dominant language
- TypeScript
- Stars
- 35.8k
- Forks
- 1.6k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 4
Description
### Report hasn't been filed before.
- [x] I have verified that the bug I'm about to report hasn't been filed before.
### What version of `drizzle-orm` are you using?
0.43.1
### What version of `drizzle-kit` are you using?
0.31.1
### Other packages
_No response_
### Describe the Bug
If constraint names are too long, they will be incorrectly truncated and updated. This is currently happening in the push command, I have no current setup to test migrate.
Every time I do a push, the below commands just re-run as it does not detect that the constraint is actually already applied with a different name (note truncated ending of **_id_fk** in first alter statement).
Log:
```
Using 'pg' driver for database querying
[✓] Pulling schema from database...
Warning You are about to execute current statements:
ALTER TABLE "inventory_line" DROP CONSTRAINT "inventory_line_inventory_line_status_id_inventory_line_status_i";
ALTER TABLE "inventory_line" ADD CONSTRAINT "inventory_line_inventory_line_status_id_inventory_line_status_id_fk" FOREIGN KEY ("inventory_line_status_id") REFERENCES "public"."inventory_line_status"("id") ON DELETE no action ON UPDATE no action;
[✓] Changes applied
x@x project %
```
Contributor guide
Assessment
This issue has not been assessed yet.