import { BaseSchema } from '@adonisjs/lucid/schema' /** One inspection per probe candidate: a release can have several of a kind (two RAR sets). */ export default class extends BaseSchema { async up() { this.schema.raw(`DELETE FROM release_inspections`) this.schema.raw(`ALTER TABLE release_inspections DROP CONSTRAINT release_inspections_pkey`) this.schema.raw(`ALTER TABLE release_inspections ADD COLUMN candidate_id bigint NOT NULL`) this.schema.raw(`ALTER TABLE release_inspections ADD PRIMARY KEY (release_id, candidate_id)`) // Their results went with the deleted rows: probed again. this.schema.raw(`UPDATE probe_candidates SET status = 'waiting' WHERE status = 'done'`) this.schema.raw(`UPDATE releases SET passworded = NULL, inner_name = NULL, inspected_at = NULL WHERE inspected_at IS NOT NULL`) } async down() { this.schema.raw(`ALTER TABLE release_inspections DROP CONSTRAINT release_inspections_pkey`) this.schema.raw(`ALTER TABLE release_inspections DROP COLUMN candidate_id`) this.schema.raw(`ALTER TABLE release_inspections ADD PRIMARY KEY (release_id, kind)`) } }