import { jsonb, pgTable, timestamp, varchar } from "drizzle-orm/pg-core";

/**
 * 系统参数配置（按模块 key 存储）
 * 例如：key=ocpp16j, value={ heartbeatInterval: 60 }
 */
export const systemSetting = pgTable("system_setting", {
  key: varchar("key", { length: 64 }).primaryKey(),
  value: jsonb("value").notNull().$type<Record<string, unknown>>(),
  createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
  updatedAt: timestamp("updated_at", { withTimezone: true })
    .notNull()
    .defaultNow()
    .$onUpdate(() => new Date()),
});
