diff --git a/database/migrations/1770000004600_release_inspections_on_hdd.ts b/database/migrations/1770000004600_release_inspections_on_hdd.ts index e79028a..b801cbb 100644 --- a/database/migrations/1770000004600_release_inspections_on_hdd.ts +++ b/database/migrations/1770000004600_release_inspections_on_hdd.ts @@ -1,24 +1,12 @@ import { BaseSchema } from '@adonisjs/lucid/schema' /** - * release_inspections' rows on the HDD (pg_default), its indexes staying in the catalog's tablespace (default_tablespace: - * nvme on homelab). It's the prober's output, appended to and read a release at a time (the judge, the web's release - * page): 40% of the NVMe's growth while probing, 4.6 GB of it, with the probe backlog needing more than the NVMe had left - * (LOG.md 2026-10-18 (79)). Homelab moved it by hand (prober, merger and judge stopped); a no-op where it's there - * already, or without a default tablespace (tests). + * Was: release_inspections' rows on the HDD (pg_default), for the NVMe's room during the probe backlog (LOG.md + * 2026-10-18 (79)). The judge's fake rule reads all of it every round: on the HDD that took 17–18 min, was ~3 + * (LOG.md 2026-10-19 (81)). Migration 4800 moves it back; nothing here now. */ export default class extends BaseSchema { - async up() { - this.defer(async (db) => { - const { rows: setting } = await db.rawQuery(`SELECT current_setting('default_tablespace') AS target`) - if (!setting[0].target) return - const { rows } = await db.rawQuery( - `SELECT 1 FROM pg_class c LEFT JOIN pg_tablespace t ON t.oid = c.reltablespace - WHERE c.relname = 'release_inspections' AND c.relkind = 'r' AND coalesce(t.spcname, 'pg_default') <> 'pg_default'` - ) - if (rows.length > 0) await db.rawQuery(`ALTER TABLE release_inspections SET TABLESPACE pg_default`) - }) - } + async up() {} async down() {} } diff --git a/database/migrations/1770000004800_release_inspections_on_nvme.ts b/database/migrations/1770000004800_release_inspections_on_nvme.ts new file mode 100644 index 0000000..b412d29 --- /dev/null +++ b/database/migrations/1770000004800_release_inspections_on_nvme.ts @@ -0,0 +1,25 @@ +import { BaseSchema } from '@adonisjs/lucid/schema' + +/** + * release_inspections back in the catalog's tablespace (default_tablespace: nvme on homelab), where migration 4600 had + * moved it to the HDD: the judge's fake rule reads all of it every round, 17–18 min on the HDD, ~3 on the NVMe (LOG.md + * 2026-10-19 (81)). Homelab moved it by hand (prober, merger and judge stopped); a no-op where it's there already, or + * without a default tablespace (tests). + */ +export default class extends BaseSchema { + async up() { + this.defer(async (db) => { + const { rows: setting } = await db.rawQuery(`SELECT current_setting('default_tablespace') AS target`) + const target = setting[0].target + if (!target) return + const { rows } = await db.rawQuery( + `SELECT 1 FROM pg_class c LEFT JOIN pg_tablespace t ON t.oid = c.reltablespace + WHERE c.relname = 'release_inspections' AND c.relkind = 'r' AND coalesce(t.spcname, 'pg_default') <> ?`, + [target] + ) + if (rows.length > 0) await db.rawQuery(`ALTER TABLE release_inspections SET TABLESPACE ${target}`) + }) + } + + async down() {} +}