next-auth drizzle adapter customization

Hi folks,

I'm using t3 app dir stack with next-auth and drizzle. I wanna customize the drizzle adapter while creating a user. I inspected the source code and customized the createUser callback function of the adapter as the following:
// node_modules/@auth/drizzle-adapter/src/lib/pg.ts
async createUser(data){
      console.log("createUser", data)
      return await client
        .insert(users)
        .values({
          ...data,
          id: crypto.randomUUID(),
          username: data.email.split("@")[0] // added this by myself
        }).returning().then((res) => res[0] ?? null)
},

I have extended my users table by adding password and email columns and need to set the username column with notNull restriction using the email without domain like you see above.
the problem is that the username value still gets null somehow even though the email is not null so I can't add users since the notNull restriction error.
It seems that my changes doesn't work at all, how do I customize this adapter as I need ?
Was this page helpful?