Skip to content
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

ID not beeing created in the database #11124

Open
ZzyzxIsAlreadyTaken opened this issue Jun 9, 2024 · 3 comments
Open

ID not beeing created in the database #11124

ZzyzxIsAlreadyTaken opened this issue Jun 9, 2024 · 3 comments
Labels
adapters Changes related to the core code concerning database adapters bug Something isn't working triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.

Comments

@ZzyzxIsAlreadyTaken
Copy link

ZzyzxIsAlreadyTaken commented Jun 9, 2024

Adapter type

@auth/drizzle-adapter

Environment

System:
OS: macOS 14.5
CPU: (12) arm64 Apple M2 Max
Memory: 53.95 MB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.12.2 - ~/.nvm/versions/node/v20.12.2/bin/node
npm: 10.5.0 - ~/.nvm/versions/node/v20.12.2/bin/npm
Browsers:
Chrome: 125.0.6422.142
Safari: 17.5
npmPackages:
@auth/drizzle-adapter: ^1.1.0 => 1.2.0
next: ^14.2.1 => 14.2.3
next-auth: ^4.24.7 => 4.24.7
react: ^18.3.0 => 18.3.1

Reproduction URL

https://github.com/ZzyzxIsAlreadyTaken/monthly

Describe the issue

The issue is that the ID in the users table is not created when logging in. The session is kind of started, but the user is never created in the local db for some reason. 
When I change the ID to Integer and autoincremenet the authentication works. But I know this will break other stuff.

Now auth.ts complains that the userstable has int but should have text.

![Screenshot 2024-06-10 at 11 53 25](https://github.com/nextauthjs/next-auth/assets/18461079/7adb08be-ccf7-4cf7-a4e4-494d21933ddd)

[next-auth][debug][adapter_getUserByEmail] { args: [ '[email protected]' ] }
[next-auth][debug][adapter_createUser] {
args: [
{
name: 'someusername',
email: '[email protected]',
image: 'https://cdn.discordapp.com/embed/avatars/0.png',
emailVerified: null
}
]
}
[next-auth][error][adapter_error_createUser]
https://next-auth.js.org/errors#adapter_error_createuser NOT NULL constraint failed: monthly_user.id {
message: 'NOT NULL constraint failed: monthly_user.id',

Also getting this:
Screenshot 2024-06-09 at 23 32 09@2x

Turned on debugging in nexauth options and is getting the same error both with discord and google providers. Both are getting the users, but creating database entry fails with no userid beeing updated.

How to reproduce

Create T3 app with sqlite and drizzle, set up basic client id, secret and callback for Discord and Google.

Expected behavior

User beeing created in db, and login succeded

@ZzyzxIsAlreadyTaken ZzyzxIsAlreadyTaken added adapters Changes related to the core code concerning database adapters bug Something isn't working triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime. labels Jun 9, 2024
@Infiplaya
Copy link

I have the same problem, have u fixed it?

@mbilenko-florio
Copy link

If you generated template with t3, try modifying your sqlite schema like this ZzyzxIsAlreadyTaken/monthly@385c95a

@ZzyzxIsAlreadyTaken
Copy link
Author

ZzyzxIsAlreadyTaken commented Jun 13, 2024

Yeah mbilenko-florio has the fix. I reported it in T3 aswell. The error is the same with some other adapters, and with similar solutions. My github and databse schema should be updated with the solution.

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 bug Something isn't working triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.
Projects
None yet
Development

No branches or pull requests

3 participants