22 lines
521 B
TypeScript
22 lines
521 B
TypeScript
// lib/schema/sessions.ts
|
|
import {
|
|
pgTable,
|
|
text,
|
|
timestamp,
|
|
} from "drizzle-orm/pg-core";
|
|
import { users } from "./users";
|
|
|
|
export const sessions = pgTable("sessions", {
|
|
id: text("id").primaryKey(), // opaque session id (UUID string)
|
|
|
|
userId: text("user_id")
|
|
.notNull()
|
|
.references(() => users.id, { onDelete: "cascade" }),
|
|
|
|
expiresAt: timestamp("expires_at", { withTimezone: true })
|
|
.notNull(),
|
|
|
|
createdAt: timestamp("created_at", { withTimezone: true })
|
|
.notNull()
|
|
.defaultNow(),
|
|
});
|