import { BaseSchema } from '@adonisjs/lucid/schema' /** * When a group's articles were posted, sampled from the news server (ranges:dates; app/services/group_dates.ts), and * from those each range's estimated posting date, so ranges can be chosen by era: ranges:capture --from --to marks a * posting-time window of every group for the corpus (voyager 3's test data; REBUILD.md, corpus). `stored_at`: the * range is complete in the corpus (the prefetcher saw its range.json), so the corpus fill skips it without looking. */ export default class extends BaseSchema { async up() { this.schema.raw(` CREATE TABLE IF NOT EXISTS group_dates ( group_id integer NOT NULL REFERENCES groups (id) ON DELETE CASCADE, article bigint NOT NULL, posted_at timestamptz NOT NULL, PRIMARY KEY (group_id, article) )`) this.schema.raw(`ALTER TABLE ranges ADD COLUMN IF NOT EXISTS est_date timestamptz`) this.schema.raw(`ALTER TABLE ranges ADD COLUMN IF NOT EXISTS stored_at timestamptz`) } async down() { this.schema.raw(`ALTER TABLE ranges DROP COLUMN IF EXISTS stored_at`) this.schema.raw(`ALTER TABLE ranges DROP COLUMN IF EXISTS est_date`) this.schema.raw(`DROP TABLE IF EXISTS group_dates`) } }