import { BaseSchema } from '@adonisjs/lucid/schema' /** * The pending ladder (REBUILD.md decision f, 2026-10-26): what the prober needs to work pending_releases cheapest * first and to learn which signatures never name anything. * - pending_releases: `file_total` (the counter's, for the catalog row once named), `inspections` (what each probe * showed, by kind), `named` (the usable name a probe found; status 4 until the namer moved it into the catalog). * Status: 0 waiting, 1 named and in the catalog, 2 discarded (its signature's verdict), 3 exhausted (every * target probed, no name), 4 named, awaiting the move, 9 taken by a running prober. * - pending_signatures: per (tool, group, poster) how many pending releases were probed to the end and how many * got a name; `dropped` once probed ≥ PENDING_MIN_PROBES and named ≤ PENDING_MAX_NAMED of them (voyager 2's * garbage learner, LOG.md 2026-10-08 (5)). The poster '' row is the tool's and group's together. */ export default class extends BaseSchema { async up() { this.schema.raw(`ALTER TABLE pending_releases ADD COLUMN IF NOT EXISTS file_total integer`) this.schema.raw( `ALTER TABLE pending_releases ADD COLUMN IF NOT EXISTS inspections jsonb NOT NULL DEFAULT '[]'` ) this.schema.raw(`ALTER TABLE pending_releases ADD COLUMN IF NOT EXISTS named varchar(255)`) // The ladder's claim: the oldest waiting ones; the namer's: the named ones. this.schema.raw( `CREATE INDEX IF NOT EXISTS pending_releases_waiting_idx ON pending_releases (created_at) WHERE status = 0` ) this.schema.raw( `CREATE INDEX IF NOT EXISTS pending_releases_naming_idx ON pending_releases (probed_at) WHERE status = 4` ) this.schema.raw(` CREATE TABLE pending_signatures ( tool varchar(16) NOT NULL, group_id integer NOT NULL, poster text NOT NULL DEFAULT '', probed integer NOT NULL DEFAULT 0, named integer NOT NULL DEFAULT 0, dropped boolean NOT NULL DEFAULT false, updated_at timestamptz NOT NULL DEFAULT now(), PRIMARY KEY (tool, group_id, poster) )`) } async down() { this.schema.raw(`DROP TABLE IF EXISTS pending_signatures`) this.schema.raw(`DROP INDEX IF EXISTS pending_releases_naming_idx`) this.schema.raw(`DROP INDEX IF EXISTS pending_releases_waiting_idx`) this.schema.raw(`ALTER TABLE pending_releases DROP COLUMN IF EXISTS named`) this.schema.raw(`ALTER TABLE pending_releases DROP COLUMN IF EXISTS inspections`) this.schema.raw(`ALTER TABLE pending_releases DROP COLUMN IF EXISTS file_total`) } }