import { BaseSchema } from '@adonisjs/lucid/schema' /** * The merge by inner name (app/services/par2_merger.ts, InnerStemMerger): * obfuscated uploads post each file under a subject name of its own, but the * yEnc name inside its first article shares a random stem with the rest of * the upload ("[1/7] - "471044d8…"" holds "bX147zx8I0oEgj7nzFCiorCT0ps2jEcb.7z.001"; * hep, hephaestus, gyges: 31,000 one-file releases; LOG.md 2026-10-12 (32)). * - An index over a lone inspection's stem: the yEnc name up to its first dot, when 16–64 letters and digits. * - release_merges: which kind of merge (par2 or inner), and room for a stem in set_id. */ export default class extends BaseSchema { static disableTransactions = true async up() { this.schema.raw( `CREATE INDEX CONCURRENTLY IF NOT EXISTS release_inspections_inner_stem_idx ON release_inspections ((substring(result->>'yencName' from '^([A-Za-z0-9]{16,64})\\.'))) WHERE kind = 'lone'` ) this.schema.raw(`CREATE INDEX CONCURRENTLY IF NOT EXISTS release_inspections_created_idx ON release_inspections (created_at)`) this.schema.raw(`ALTER TABLE release_merges ALTER COLUMN set_id TYPE varchar(64)`) this.schema.raw(`ALTER TABLE release_merges ADD COLUMN IF NOT EXISTS via varchar(8) NOT NULL DEFAULT 'par2'`) } async down() { this.schema.raw(`DROP INDEX CONCURRENTLY IF EXISTS release_inspections_inner_stem_idx`) this.schema.raw(`DROP INDEX CONCURRENTLY IF EXISTS release_inspections_created_idx`) this.schema.raw(`ALTER TABLE release_merges DROP COLUMN IF EXISTS via`) } }