From 0fd86c713a37db8b79f8b0914b8c9819dceb1c8c Mon Sep 17 00:00:00 2001 From: Scrum4Me Agent <30029041+madhura68@users.noreply.github.com> Date: Wed, 6 May 2026 03:01:35 +0200 Subject: [PATCH] =?UTF-8?q?feat(ST-mgsu85hr):=20Prisma=20schema=20?= =?UTF-8?q?=E2=80=94=20token-velden=20op=20ClaudeJob=20+=20ModelPrice=20mo?= =?UTF-8?q?del?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Voeg model_id, input_tokens, output_tokens, cache_read_tokens, cache_write_tokens (nullable) toe aan ClaudeJob - Voeg nieuw ModelPrice model toe met per-1M prijsvelden en currency default USD - Migratie 20260506010013_add_token_usage_fields aangemaakt en toegepast - Seed uitgebreid met standaardprijzen voor claude-opus-4-7, claude-sonnet-4-6, claude-haiku-4-5-20251001 Co-Authored-By: Claude Sonnet 4.6 --- .../migration.sql | 24 ++++++++++++++ prisma/schema.prisma | 19 +++++++++++ prisma/seed.ts | 33 +++++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 prisma/migrations/20260506010013_add_token_usage_fields/migration.sql diff --git a/prisma/migrations/20260506010013_add_token_usage_fields/migration.sql b/prisma/migrations/20260506010013_add_token_usage_fields/migration.sql new file mode 100644 index 0000000..322eef5 --- /dev/null +++ b/prisma/migrations/20260506010013_add_token_usage_fields/migration.sql @@ -0,0 +1,24 @@ +-- AlterTable +ALTER TABLE "claude_jobs" ADD COLUMN "cache_read_tokens" INTEGER, +ADD COLUMN "cache_write_tokens" INTEGER, +ADD COLUMN "input_tokens" INTEGER, +ADD COLUMN "model_id" TEXT, +ADD COLUMN "output_tokens" INTEGER; + +-- CreateTable +CREATE TABLE "model_prices" ( + "id" TEXT NOT NULL, + "model_id" TEXT NOT NULL, + "input_price_per_1m" DECIMAL(12,6) NOT NULL, + "output_price_per_1m" DECIMAL(12,6) NOT NULL, + "cache_read_price_per_1m" DECIMAL(12,6) NOT NULL, + "cache_write_price_per_1m" DECIMAL(12,6) NOT NULL, + "currency" TEXT NOT NULL DEFAULT 'USD', + "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updated_at" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "model_prices_pkey" PRIMARY KEY ("id") +); + +-- CreateIndex +CREATE UNIQUE INDEX "model_prices_model_id_key" ON "model_prices"("model_id"); diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 352e5c2..f9d54ef 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -336,6 +336,11 @@ model ClaudeJob { finished_at DateTime? pushed_at DateTime? verify_result VerifyResult? + model_id String? + input_tokens Int? + output_tokens Int? + cache_read_tokens Int? + cache_write_tokens Int? plan_snapshot String? branch String? pr_url String? @@ -353,6 +358,20 @@ model ClaudeJob { @@map("claude_jobs") } +model ModelPrice { + id String @id @default(cuid()) + model_id String @unique + input_price_per_1m Decimal @db.Decimal(12, 6) + output_price_per_1m Decimal @db.Decimal(12, 6) + cache_read_price_per_1m Decimal @db.Decimal(12, 6) + cache_write_price_per_1m Decimal @db.Decimal(12, 6) + currency String @default("USD") + created_at DateTime @default(now()) + updated_at DateTime @updatedAt + + @@map("model_prices") +} + model ClaudeWorker { id String @id @default(cuid()) user User @relation(fields: [user_id], references: [id], onDelete: Cascade) diff --git a/prisma/seed.ts b/prisma/seed.ts index efb88b7..50b4158 100644 --- a/prisma/seed.ts +++ b/prisma/seed.ts @@ -193,6 +193,39 @@ async function main() { } } + const modelPrices = [ + { + model_id: 'claude-opus-4-7', + input_price_per_1m: 15.0, + output_price_per_1m: 75.0, + cache_read_price_per_1m: 1.5, + cache_write_price_per_1m: 18.75, + }, + { + model_id: 'claude-sonnet-4-6', + input_price_per_1m: 3.0, + output_price_per_1m: 15.0, + cache_read_price_per_1m: 0.3, + cache_write_price_per_1m: 3.75, + }, + { + model_id: 'claude-haiku-4-5-20251001', + input_price_per_1m: 0.8, + output_price_per_1m: 4.0, + cache_read_price_per_1m: 0.08, + cache_write_price_per_1m: 1.0, + }, + ] + + for (const mp of modelPrices) { + await prisma.modelPrice.upsert({ + where: { model_id: mp.model_id }, + update: mp, + create: mp, + }) + console.log(` ModelPrice upserted: ${mp.model_id}`) + } + console.log('\nSeeding complete!') console.log('Demo user: username=demo password=demo1234') console.log('Main user: username=lars password=scrum4me123')