import { index, integer, primaryKey, sqliteTable, text } from "drizzle-orm/sqlite-core"; import { users } from "./auth"; export const appConfigs = sqliteTable("app_configs", { key: text().primaryKey(), value: text().notNull(), valueType: text("value_type").notNull(), updatedAt: integer("updated_at", { mode: "timestamp_ms" }) .defaultNow() .$onUpdate(() => new Date()) .notNull(), }); export const userConfigs = sqliteTable( "user_configs", { userId: integer("user_id") .notNull() .references(() => users.id, { onDelete: "cascade" }), key: text().notNull(), value: text().notNull(), valueType: text("value_type").notNull(), updatedAt: integer("updated_at", { mode: "timestamp_ms" }) .defaultNow() .$onUpdate(() => new Date()) .notNull(), }, (table) => [ primaryKey({ name: "user_configs_user_id_key_pk", columns: [table.userId, table.key], }), index("user_configs_user_id_idx").on(table.userId), ], );