A spot older than what the catalog has indexed (the spotter's first backfill reaches back ~3 months) matched nothing and would have become a release of its own, a duplicate once the history pass builds the upload. Unmatched spots are matched again in turns (rematched_at) for 30 days; the 24 h before a standalone release count from the inspection; a later match deletes the spot's own release and links the header pass's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
22 lines
1.0 KiB
TypeScript
22 lines
1.0 KiB
TypeScript
import { BaseSchema } from '@adonisjs/lucid/schema'
|
|
|
|
/**
|
|
* Unmatched spots are matched again in turns (`rematched_at`), for 30 days after their inspection, also once they
|
|
* became a release of their own: the header pass may build their releases later (a spot's history before the
|
|
* catalog's), and then the spot moves to that release (LOG.md 2026-10-13 (45)).
|
|
*/
|
|
export default class extends BaseSchema {
|
|
async up() {
|
|
this.schema.raw(`ALTER TABLE spots ADD COLUMN IF NOT EXISTS rematched_at timestamptz`)
|
|
// Inspected before the inspector set it (2026-10-13).
|
|
this.schema.raw(`UPDATE spots SET matched = 0 WHERE status = 'inspected' AND matched IS NULL`)
|
|
this.schema.raw(`DROP INDEX IF EXISTS spots_unmatched_idx`)
|
|
this.schema.raw(`CREATE INDEX IF NOT EXISTS spots_unmatched_idx ON spots (coalesce(rematched_at, inspected_at)) WHERE status = 'inspected' AND matched = 0`)
|
|
}
|
|
|
|
async down() {
|
|
this.schema.raw(`DROP INDEX IF EXISTS spots_unmatched_idx`)
|
|
this.schema.raw(`ALTER TABLE spots DROP COLUMN IF EXISTS rematched_at`)
|
|
}
|
|
}
|