import { BaseSchema } from '@adonisjs/lucid/schema' /** * Listed spots (D29) were only read from their overview: no description, no * NZB, so neither a password in the spot's text nor the NZB's own * `` was known (LOG.md 2026-10-08 (10)). nzb_read_at: * when the spot's article and NZB were read for that (SpotService.readListing), * also set while a reader holds it. The index finds the ones still to read, * newest first. */ export default class extends BaseSchema { async up() { await this.db.rawQuery(`ALTER TABLE spots ADD COLUMN IF NOT EXISTS nzb_read_at timestamptz`) await this.db.rawQuery( `CREATE INDEX IF NOT EXISTS spots_listing_unread_idx ON spots (posted_at DESC) WHERE status = 'listed' AND nzb_read_at IS NULL` ) } async down() { await this.db.rawQuery(`DROP INDEX IF EXISTS spots_listing_unread_idx`) await this.db.rawQuery(`ALTER TABLE spots DROP COLUMN IF EXISTS nzb_read_at`) } }