import { sql } from "drizzle-orm"; import { integer, sqliteTable, text, uniqueIndex } from "drizzle-orm/sqlite-core"; export const users = sqliteTable( "users", { id: text("id").primaryKey(), username: text("username").notNull(), passwordHash: text("password_hash").notNull(), name: text("name").notNull(), role: text("role").notNull().default("user"), active: integer("active", { mode: "boolean" }).notNull().default(true), mustChangePassword: integer("must_change_password", { mode: "boolean" }) .notNull() .default(true), createdAt: integer("created_at", { mode: "timestamp" }) .notNull() .default(sql`(unixepoch())`), updatedAt: integer("updated_at", { mode: "timestamp" }) .notNull() .default(sql`(unixepoch())`), }, (table) => [uniqueIndex("users_username_unique").on(table.username)] ); export type User = typeof users.$inferSelect; export type NewUser = typeof users.$inferInsert;