import { BaseSchema } from '@adonisjs/lucid/schema' /** * One "ancient" range a group, articles 1 … (its first range − 1): what had expired on the server before the * group was planned (the planner cuts from the low watermark). Status 'ancient': nothing to fetch, never leased, * so the tiling is complete from article 1 and the span below the low watermark is on record (user, 2026-10-28). * Planner.historyRows adds it for groups planned from now on. */ export default class extends BaseSchema { async up() { this.schema.raw( `INSERT INTO ranges (group_id, start_id, end_id, next_id, priority, status) SELECT group_id, 1, min(start_id) - 1, 1, 0, 'ancient' FROM ranges GROUP BY group_id HAVING min(start_id) > 1` ) } async down() { this.schema.raw(`DELETE FROM ranges WHERE status = 'ancient'`) } }