boredgame/src/schema.ts

28 lines
753 B
TypeScript
Raw Normal View History

2024-01-31 02:19:51 +00:00
import { DrizzleMySQLAdapter } from "@lucia-auth/adapter-drizzle";
import mysql from "mysql2/promise";
import { int, mysqlEnum, mysqlTable, uniqueIndex, datetime, varchar, serial } from 'drizzle-orm/mysql-core';
import { drizzle } from "drizzle-orm/mysql2";
const connection = await mysql.createConnection();
const db = drizzle(connection);
const userTable = mysqlTable("user", {
id: varchar("id", {
length: 255
}).primaryKey()
});
const sessionTable = mysqlTable("session", {
id: varchar("id", {
length: 255
}).primaryKey(),
userId: varchar("user_id", {
length: 255
})
.notNull()
.references(() => userTable.id),
expiresAt: datetime("expires_at").notNull()
});
const adapter = new DrizzleMySQLAdapter(db, sessionTable, userTable);