Compare commits

...
Sign in to create a new pull request.

1 commit

Author SHA1 Message Date
Scrum4Me Agent
0fd86c713a feat(ST-mgsu85hr): Prisma schema — token-velden op ClaudeJob + ModelPrice model
- 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 <noreply@anthropic.com>
2026-05-06 03:01:35 +02:00
3 changed files with 76 additions and 0 deletions

View file

@ -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");

View file

@ -336,6 +336,11 @@ model ClaudeJob {
finished_at DateTime? finished_at DateTime?
pushed_at DateTime? pushed_at DateTime?
verify_result VerifyResult? verify_result VerifyResult?
model_id String?
input_tokens Int?
output_tokens Int?
cache_read_tokens Int?
cache_write_tokens Int?
plan_snapshot String? plan_snapshot String?
branch String? branch String?
pr_url String? pr_url String?
@ -353,6 +358,20 @@ model ClaudeJob {
@@map("claude_jobs") @@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 { model ClaudeWorker {
id String @id @default(cuid()) id String @id @default(cuid())
user User @relation(fields: [user_id], references: [id], onDelete: Cascade) user User @relation(fields: [user_id], references: [id], onDelete: Cascade)

View file

@ -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('\nSeeding complete!')
console.log('Demo user: username=demo password=demo1234') console.log('Demo user: username=demo password=demo1234')
console.log('Main user: username=lars password=scrum4me123') console.log('Main user: username=lars password=scrum4me123')