import { sqliteTable, text, integer, real } from "drizzle-orm/sqlite-core";

export const kpiSnapshots = sqliteTable("kpi_snapshots", {
  id: integer("id").primaryKey({ autoIncrement: true }),
  kpiKey: text("kpi_key").notNull(),
  kpiValue: real("kpi_value").notNull(),
  periodStart: integer("period_start", { mode: "timestamp" }).notNull(),
  periodEnd: integer("period_end", { mode: "timestamp" }).notNull(),
  metadata: text("metadata"),
  createdAt: integer("created_at", { mode: "timestamp" }).notNull().default(new Date()),
});

export type KPISnapshot = typeof kpiSnapshots.$inferSelect;
export type NewKPISnapshot = typeof kpiSnapshots.$inferInsert;
