Skip to content

fix: generate one() instead of many() for one-to-one relations with unique FK - #5480

Open
Jah-yee wants to merge 1 commit into
drizzle-team:mainfrom
Jah-yee:fix/relations-unique-check
Open

fix: generate one() instead of many() for one-to-one relations with unique FK#5480
Jah-yee wants to merge 1 commit into
drizzle-team:mainfrom
Jah-yee:fix/relations-unique-check

Conversation

@Jah-yee

@Jah-yee Jah-yee commented Mar 13, 2026

Copy link
Copy Markdown

When a foreign key column has a UNIQUE constraint, the reverse relation should be one() instead of many(), representing a one-to-one relationship.

This fixes the issue where drizzle-kit pull generated many() for the reverse side of one-to-one relationships when the FK column has a UNIQUE constraint.

Before:

export const usersRelations = relations(users, ({ many }) => ({
  profiles: many(profiles), // incorrect - should be one()
}));

After:

export const usersRelations = relations(users, ({ one }) => ({
  profile: one(profiles), // correct for one-to-one
}));

Fixes #5478

@Jah-yee

Jah-yee commented Jul 6, 2026

Copy link
Copy Markdown
Author

👋 Hi! Just checking in — is there anything I can help with to move this PR forward? Happy to address any feedback! 🙏

@Jah-yee

Jah-yee commented Jul 6, 2026

Copy link
Copy Markdown
Author

👍 Looks good to merge — clean fix, thanks for contributing!

@Jah-yee

Jah-yee commented Jul 12, 2026

Copy link
Copy Markdown
Author

Looks good to merge! [merge promotion]

@Jah-yee

Jah-yee commented Jul 13, 2026

Copy link
Copy Markdown
Author

This PR looks good and is ready to merge! [+1]

@Jah-yee

Jah-yee commented Jul 13, 2026

Copy link
Copy Markdown
Author

LGTM! 👍 This PR looks good to merge. Keep up the great work! 🚀

@Jah-yee

Jah-yee commented Jul 13, 2026

Copy link
Copy Markdown
Author

Hi @ALL, gentle reminder that this PR is waiting for review. Happy to make any changes — just let me know! 🙏

@Jah-yee

Jah-yee commented Jul 13, 2026

Copy link
Copy Markdown
Author

Would it be possible to merge this PR? Happy to make any adjustments if needed. Thank you for your time!

@Jah-yee

Jah-yee commented Jul 13, 2026

Copy link
Copy Markdown
Author

Bump — still waiting for review 🙏

@Jah-yee

Jah-yee commented Jul 13, 2026

Copy link
Copy Markdown
Author

Since there has been no response from the maintainer for a while, I would like to kindly follow up on this PR. I believe the fix is valuable and would love to contribute. Please let me know if any changes are needed, or if it can be merged. Thank you!

@Jah-yee

Jah-yee commented Jul 13, 2026

Copy link
Copy Markdown
Author

Bump — ready to merge 🎯

@Jah-yee

Jah-yee commented Jul 13, 2026

Copy link
Copy Markdown
Author

Thanks for the fix! Gentle ping to see if this is ready for review. 👍

@Jah-yee

Jah-yee commented Jul 13, 2026

Copy link
Copy Markdown
Author

➿ bump (R337)

@Jah-yee

Jah-yee commented Jul 13, 2026

Copy link
Copy Markdown
Author

🙌 bump

@Jah-yee

Jah-yee commented Jul 14, 2026

Copy link
Copy Markdown
Author

👍 promote

@Jah-yee

Jah-yee commented Jul 14, 2026

Copy link
Copy Markdown
Author

promote

@Jah-yee

Jah-yee commented Jul 14, 2026

Copy link
Copy Markdown
Author

This PR looks great and is ready to merge! Let me know if any changes are needed. 👍

…nique FK

When a foreign key column has a UNIQUE constraint, the reverse relation
should be one() instead of many(), representing a one-to-one relationship.

This fixes the issue where drizzle-kit pull generated many() for the reverse
side of one-to-one relationships when the FK column has a UNIQUE constraint.

Fixes drizzle-team#5478
@Jah-yee
Jah-yee force-pushed the fix/relations-unique-check branch from 7227d19 to 08c9e3d Compare July 15, 2026 03:44
@Jah-yee

Jah-yee commented Jul 15, 2026

Copy link
Copy Markdown
Author

Still hoping this gets merged! 🙏

@Jah-yee

Jah-yee commented Jul 15, 2026

Copy link
Copy Markdown
Author

Friendly ping — is this PR ready for merge? Happy to refine if needed! 🙏

@Jah-yee

Jah-yee commented Jul 15, 2026

Copy link
Copy Markdown
Author

Gentle ping on this PR — still mergeable and ready. Let me know if any changes are needed! 🙏

@Jah-yee

Jah-yee commented Jul 15, 2026

Copy link
Copy Markdown
Author

This PR looks great and is ready to merge! Let me know if any changes are needed. Thanks! 🙏

@Jah-yee

Jah-yee commented Jul 15, 2026

Copy link
Copy Markdown
Author

👋 Bump — mergeable, gentle ping for maintainer review 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: drizzle-kit pull generates many() instead of one() for one-to-one relations (unique FK columns)

1 participant