fix: harden download history and attempt ledger

This commit is contained in:
Leon Tonhäuser committed 2026-08-10 16:45:40 +02:00
1 parent 510fde7afa
commit ba673ad732
19 files changed
+2287 -311

No files matched your search

+11
View File
@@ -3,6 +3,7 @@ import {
bigint,
boolean,
check,
index,
integer,
pgEnum,
pgTable,
@@ -49,6 +50,11 @@ export const usages = pgTable(
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
},
(table) => [
index("usages_editorial_created_id_idx").on(
table.editorialAccountId,
table.createdAt.desc(),
table.id.desc(),
),
check(
"usages_canonical_immich_asset_id_check",
sql`${table.immichAssetId} ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'`,
@@ -84,6 +90,11 @@ export const downloadEvents = pgTable(
legacyIntent: boolean("legacy_intent").notNull().default(false),
},
(table) => [
index("download_events_editorial_authorized_id_idx").on(
table.editorialAccountId,
table.authorizedAt.desc(),
table.id.desc(),
),
uniqueIndex("download_events_editorial_idempotency_key_unique").on(
table.editorialAccountId,
table.idempotencyKey,