diff --git a/infrastructure/migrations/0026_smart_mastermind.sql b/infrastructure/migrations/0026_smart_mastermind.sql new file mode 100644 index 0000000..42f8596 --- /dev/null +++ b/infrastructure/migrations/0026_smart_mastermind.sql @@ -0,0 +1,9 @@ +CREATE TABLE "gemini_usage" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "task_type" text NOT NULL, + "prompt_tokens" integer NOT NULL, + "output_tokens" integer NOT NULL, + "total_tokens" integer NOT NULL, + "cost_microcents" bigint +); diff --git a/packages/database/src/schema/gemini-usage.ts b/packages/database/src/schema/gemini-usage.ts new file mode 100644 index 0000000..b243718 --- /dev/null +++ b/packages/database/src/schema/gemini-usage.ts @@ -0,0 +1,16 @@ +import { bigint, integer, pgTable, text, uuid } from "drizzle-orm/pg-core"; +import { createdAt } from "./_shared.js"; + +/** + * Token-telemetri för Gemini-anrop (spec §EOC): + * Rådata för /ops/v1/summary och framtida kostnadsuppföljning. + */ +export const geminiUsage = pgTable("gemini_usage", { + id: uuid("id").primaryKey().defaultRandom(), + createdAt: createdAt(), + taskType: text("task_type").notNull(), + promptTokens: integer("prompt_tokens").notNull(), + outputTokens: integer("output_tokens").notNull(), + totalTokens: integer("total_tokens").notNull(), + costMicrocents: bigint("cost_microcents", { mode: "number" }), +}); diff --git a/packages/database/src/schema/index.ts b/packages/database/src/schema/index.ts index bd8ada5..daf12f0 100644 --- a/packages/database/src/schema/index.ts +++ b/packages/database/src/schema/index.ts @@ -22,3 +22,4 @@ export * from "./feedback.js"; export * from "./ops.js"; export * from "./platform.js"; export * from "./releaseGates.js"; +export * from "./gemini-usage.js";