diff --git a/database/migrations/1768620765190_release_totals_per_statement.ts b/database/migrations/1768620765190_release_totals_per_statement.ts index 62a7a73..345d737 100644 --- a/database/migrations/1768620765190_release_totals_per_statement.ts +++ b/database/migrations/1768620765190_release_totals_per_statement.ts @@ -22,8 +22,11 @@ import { BaseSchema } from '@adonisjs/lucid/schema' export default class extends BaseSchema { async up() { const q = (sql: string) => this.db.rawQuery(sql) - // Swapping triggers locks files and its partitions: give up rather than queue every writer behind it. + // Swapping triggers locks files and its partitions. Taken first and in one statement: a + // DROP TRIGGER later in the transaction deadlocked with ingest (2026-10-06). Give up rather + // than queue every writer behind it for long. await q(`SET LOCAL lock_timeout = '2min'`) + await q(`LOCK TABLE files, release_files IN ACCESS EXCLUSIVE MODE`) // Built CONCURRENTLY by hand on homelab (2026-10-06); IF NOT EXISTS keeps that one. await q(`CREATE INDEX IF NOT EXISTS release_files_release_size_idx ON release_files (release_id, size)`)