-
The example below is the schema used by the basic drizzle adapter described in the documentation. export const users = pgTable("user", {
id: text("id")
.primaryKey()
.$defaultFn(() => crypto.randomUUID()),
name: text("name"),
email: text("email").notNull(),
emailVerified: timestamp("emailVerified", { mode: "date" }), // camelCase
image: text("image"),
})
export const accounts = pgTable(
"account",
{
userId: text("userId") // camelCase
.notNull()
.references(() => users.id, { onDelete: "cascade" }),
type: text("type").$type<AdapterAccountType>().notNull(),
provider: text("provider").notNull(),
providerAccountId: text("providerAccountId").notNull(), // camelCase
refresh_token: text("refresh_token"), // snake-case
access_token: text("access_token"), // snake-case
expires_at: integer("expires_at"), // snake-case
token_type: text("token_type"), // snake-case
scope: text("scope"),
id_token: text("id_token"), // snake-case
session_state: text("session_state"), // snake-case
},
(account) => ({
compoundKey: primaryKey({
columns: [account.provider, account.providerAccountId],
}),
})
) If you look at the comments in the code above, you'll see that the schema names have different cases. Why is this done this way? Is there a special reason? I'm curious. If you change it arbitrarily, Typescript will complain, which is understandable because it references it internally against its schema. Is there any way to change this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
|
Beta Was this translation helpful? Give feedback.
https://authjs.dev/concepts/database-models