import { BaseSchema } from '@adonisjs/lucid/schema' /** * Binaries that were flagged conflicted before part_conflicts existed lost * their extra articles, so splitting them only reshuffles the first article * per part number, a mix of different volumes. Mark them as never to be * split, and remove the volumes and files the first splitter run made from * them (see LOG.md, 2026-09-28). */ export default class extends BaseSchema { async up() { this.defer(async (db) => { await db.rawQuery(` WITH boundary AS ( SELECT migration_time FROM adonis_schema WHERE name LIKE '%1768620764790%' ), legacy AS ( SELECT id FROM binaries WHERE conflicted_at IS NOT NULL AND parent_binary_id IS NULL AND conflicted_at < (SELECT migration_time FROM boundary) ), instances AS ( SELECT id, file_id FROM binaries WHERE parent_binary_id IN (SELECT id FROM legacy) ), deleted_files AS ( DELETE FROM files WHERE id IN (SELECT file_id FROM instances WHERE file_id IS NOT NULL) ), deleted_instances AS ( DELETE FROM binaries WHERE id IN (SELECT id FROM instances) ) -- 'infinity': last_seen_at > split_at is never true, so SplitService skips them. UPDATE binaries SET split_at = 'infinity' WHERE id IN (SELECT id FROM legacy) `) }) } async down() { // The removed volumes were unverifiable; nothing to restore. } }