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>
This commit is contained in:
Experiments DB Dev
2026-04-23 13:41:36 -04:00
parent 5cd6d2a8a3
commit 52d5fca5d1
5 changed files with 111 additions and 43 deletions
+12 -9
View File
@@ -49,15 +49,18 @@ model DailyStatus {
}
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?
notes String?
created_at DateTime @default(now())
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")
}