Closed versecafe closed 3 weeks ago
@lucia-auth/session-drizzle
Allow drizzle pg uuid types for session and user id fields instead of requiring a string
also just a note package should be @lucia-auth/adapter-drizzle
@lucia-auth/adapter-drizzle
Should allow something like this
import { pgTable, timestamp, varchar, primaryKey, uuid, index, } from "drizzle-orm/pg-core"; import { v7 as uuidv7 } from "uuid"; export const usersTable = pgTable( "users", { id: uuid("id").primaryKey().$defaultFn(uuidv7), username: varchar("username", { length: 60 }).unique().notNull(), avatar: varchar("avatar", { length: 2048 }), email: varchar("email", { length: 255 }), createdAt: timestamp("created_at").defaultNow().notNull(), lastLogin: timestamp("last_login").defaultNow().notNull(), }, (table) => { return { usernameIndex: index("username_index").on(table.username), }; }, ); export const sessionsTable = pgTable("sessions", { id: uuid("id").primaryKey().$defaultFn(uuidv7), userId: uuid("user_id") .notNull() .references(() => usersTable.id), expiresAt: timestamp("expires_at", { withTimezone: true, mode: "date", }).notNull(), });
I don't plan to add any new features to the adapters. See #1714
Package
@lucia-auth/session-drizzle
Description
Allow drizzle pg uuid types for session and user id fields instead of requiring a string
Should allow something like this