lutefd
lutefd
DTDrizzle Team
Created by lutefd on 1/20/2024 in #help
Next auth with extended columns not able to create a user
I'm trying to create an app that relies on role based authentication with next auth and drizzle, the problem is when I try to create a user by signing in I get the following error, even tough there's a default applied in the schema:
[auth][cause]: PostgresError: null value in column "role" of relation "project1_user" violates not-null constraint
[auth][cause]: PostgresError: null value in column "role" of relation "project1_user" violates not-null constraint
This is my table:
export const users = pgTable('user', {
id: uuid('id')
.$default(() => cuid2.createId())
.notNull()
.primaryKey(),
name: text('name'),
email: text('email').notNull(),
emailVerified: timestamp('emailVerified', { mode: 'date' }),
password: text('password'),
image: text('image'),
role: RoleEnum('role')
.$default(() => 'USER')
.notNull(),
status: UserStatusEnum('status')
.$default(() => 'ACTIVE')
.notNull(),
});
export const users = pgTable('user', {
id: uuid('id')
.$default(() => cuid2.createId())
.notNull()
.primaryKey(),
name: text('name'),
email: text('email').notNull(),
emailVerified: timestamp('emailVerified', { mode: 'date' }),
password: text('password'),
image: text('image'),
role: RoleEnum('role')
.$default(() => 'USER')
.notNull(),
status: UserStatusEnum('status')
.$default(() => 'ACTIVE')
.notNull(),
});
Shouldn't those columns not be null and instead have the default value instead of null?
5 replies
DTDrizzle Team
Created by lutefd on 1/10/2024 in #help
Reusing db connection in lambda with Drizzle
No description
3 replies