Files
experiments-database/backend/prisma/schema.prisma
T
Experiments DB Dev 52d5fca5d1 feat: store matching metadata on session file registration
Each saved file now records three additional fields:
  matched_identifier    — the literal animal_id_string or animal_name
                          substring that matched in the filename
  animal_id_string_snap — snapshot of animal.animal_id_string at
                          registration time
  animal_name_snap      — snapshot of animal.animal_name at
                          registration time

This lets future consumers (scripts, exports, re-matching) identify
the subject from the file record alone, even if animal data changes.
The matched identifier is also shown in the drop preview UI (↳ 2852).

Tests: 25 total (+2 for new payload fields).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-23 13:41:36 -04:00

97 lines
2.8 KiB
Plaintext

generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "linux-musl-openssl-3.0.x"]
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model Experiment {
id String @id @default(uuid())
title String
created_at DateTime @default(now())
template Json @default("[]")
subject_info_template Json @default("[]")
animals Animal[]
@@map("experiments")
}
model Animal {
id String @id @default(uuid())
experiment_id String
animal_id_string String
animal_name String
subject_info Json?
experiment Experiment @relation(fields: [experiment_id], references: [id], onDelete: Cascade)
daily_statuses DailyStatus[]
@@map("animals")
}
model DailyStatus {
id String @id @default(uuid())
animal_id String
date DateTime @db.Date
experiment_description String?
vitals String?
treatment String?
notes String?
custom_fields Json?
analysis_summary Json?
animal Animal @relation(fields: [animal_id], references: [id], onDelete: Cascade)
analyses DailyAnalysis[]
session_files SessionFile[]
@@map("daily_statuses")
}
model SessionFile {
id String @id @default(uuid())
daily_status_id String
daily_status DailyStatus @relation(fields: [daily_status_id], references: [id], onDelete: Cascade)
filename String
file_size BigInt
file_type String?
last_modified BigInt?
matched_identifier String? // the animal ID/name substring that matched in the filename
animal_id_string_snap String? // snapshot of animal.animal_id_string at registration time
animal_name_snap String? // snapshot of animal.animal_name at registration time
notes String?
created_at DateTime @default(now())
@@map("session_files")
}
model DailyAnalysis {
id String @id @default(uuid())
daily_status_id String
daily_status DailyStatus @relation(fields: [daily_status_id], references: [id], onDelete: Cascade)
created_at DateTime @default(now())
file_name String?
timestamp_col String
note_col String
classifications Json
total_note_rows Int
session_end_ts Float?
sequence Json
category_counts Json
consecutive_stats Json
runs Json
@@map("daily_analyses")
}
model AuditLog {
id String @id @default(uuid())
table_name String
record_id String
action String
changes Json
timestamp DateTime @default(now())
@@map("audit_logs")
}