Skip to content

Add model association override to @auth/sequelize-adapter #13120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

chipgpt
Copy link

@chipgpt chipgpt commented Jul 17, 2025

☕️ Reasoning

I want to be able to customize the associations that are set up between the models when using the @auth/sequelize-adapter. This PR adds an optional override to the SequelizeAdapter options:

new SequelizeAdapter(sequelize, {
  models: {
    ...
  },
  associations: (User, Account, Session) => {
    Account.belongsTo(User, { onDelete: "cascade", foreignKey: "userId", as: 'user' });
    Session.belongsTo(User, { onDelete: "cascade", foreignKey: "userId", as: 'user' });
  }
});

🧢 Checklist

  • Documentation
  • Tests - There are no tests covering the associations.
  • Ready to be merged

🎫 Affected issues

📌 Resources

@chipgpt chipgpt requested a review from ndom91 as a code owner July 17, 2025 17:36
Copy link

vercel bot commented Jul 17, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
auth-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 17, 2025 5:48pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
next-auth-docs ⬜️ Ignored (Inspect) Visit Preview Jul 17, 2025 5:48pm

Copy link

vercel bot commented Jul 17, 2025

@chipgpt is attempting to deploy a commit to the authjs Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions bot added adapters Changes related to the core code concerning database adapters sequelize @auth/sequelize-adapter labels Jul 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
adapters Changes related to the core code concerning database adapters sequelize @auth/sequelize-adapter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant