A release can have several candidates of a kind (two RAR sets): keyed by
(release, kind) both landed in one upsert ("ON CONFLICT DO UPDATE
command cannot affect row a second time"), and the batch was lost.
release_inspections is keyed by candidate now; the first run's results
are cleared and probed again. A random-named file's yEnc name is often
its random name: an inner name equal to the release's name is dropped.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
21 lines
1.1 KiB
TypeScript
21 lines
1.1 KiB
TypeScript
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)`)
|
|
}
|
|
}
|