Drizzle generate creates default values as variables instead of strings
In the code below the default values for status in invitation and role for member (
This is based on this config:
membermember and pendingpending) should be strings but are generated as variables.export const member = pgTable("member", {
id: text('id').primaryKey(),
organizationId: text('organization_id').notNull().references(()=> organization.id, { onDelete: 'cascade' }),
userId: text('user_id').notNull().references(()=> user.id, { onDelete: 'cascade' }),
role: text('role').default(member).notNull(),
createdAt: timestamp('created_at').notNull()
});
export const invitation = pgTable("invitation", {
id: text('id').primaryKey(),
organizationId: text('organization_id').notNull().references(()=> organization.id, { onDelete: 'cascade' }),
email: text('email').notNull(),
role: text('role'),
status: text('status').default(pending).notNull(),
expiresAt: timestamp('expires_at').notNull(),
inviterId: text('inviter_id').notNull().references(()=> user.id, { onDelete: 'cascade' })
});export const member = pgTable("member", {
id: text('id').primaryKey(),
organizationId: text('organization_id').notNull().references(()=> organization.id, { onDelete: 'cascade' }),
userId: text('user_id').notNull().references(()=> user.id, { onDelete: 'cascade' }),
role: text('role').default(member).notNull(),
createdAt: timestamp('created_at').notNull()
});
export const invitation = pgTable("invitation", {
id: text('id').primaryKey(),
organizationId: text('organization_id').notNull().references(()=> organization.id, { onDelete: 'cascade' }),
email: text('email').notNull(),
role: text('role'),
status: text('status').default(pending).notNull(),
expiresAt: timestamp('expires_at').notNull(),
inviterId: text('inviter_id').notNull().references(()=> user.id, { onDelete: 'cascade' })
});This is based on this config:
import { betterAuth } from "better-auth";
import { drizzleAdapter } from "better-auth/adapters/drizzle";
import { organization } from "better-auth/plugins";
import { eq } from "drizzle-orm";
import { createAccessControl } from "better-auth/plugins/access";
export const auth = betterAuth({
baseURL: process.env.API_URL,
database: drizzleAdapter(Database.db, {
provider: "pg",
schema: Database.schema,
}),
emailAndPassword: {
enabled: true,
requireEmailVerification: true,
autoSignIn: true,
},
advanced: {
useSecureCookies: true,
defaultCookieAttributes: {
httpOnly: true,
secure: true,
path: "/",
sameSite: "lax", // Use 'lax' for better compatibility
},
cookiePrefix: "autopilot",
},
trustedOrigins: [process.env.API_URL || ""].filter(Boolean),
plugins: [organization()],
});import { betterAuth } from "better-auth";
import { drizzleAdapter } from "better-auth/adapters/drizzle";
import { organization } from "better-auth/plugins";
import { eq } from "drizzle-orm";
import { createAccessControl } from "better-auth/plugins/access";
export const auth = betterAuth({
baseURL: process.env.API_URL,
database: drizzleAdapter(Database.db, {
provider: "pg",
schema: Database.schema,
}),
emailAndPassword: {
enabled: true,
requireEmailVerification: true,
autoSignIn: true,
},
advanced: {
useSecureCookies: true,
defaultCookieAttributes: {
httpOnly: true,
secure: true,
path: "/",
sameSite: "lax", // Use 'lax' for better compatibility
},
cookiePrefix: "autopilot",
},
trustedOrigins: [process.env.API_URL || ""].filter(Boolean),
plugins: [organization()],
});