Files
usenet-indexer/database/migrations/1770000000700_create_probe_candidates.ts
T

26 lines
916 B
TypeScript

import { BaseSchema } from '@adonisjs/lucid/schema'
/**
* The probe queue (REBUILD.md, part 6): per release the few articles phase 2
* should read. Phase 1 only fills it.
*/
export default class extends BaseSchema {
async up() {
this.schema.createTable('probe_candidates', (table) => {
table.bigIncrements('id')
table.bigInteger('release_id').notNullable()
table.string('kind', 8).notNullable()
table.text('message_id').notNullable()
table.text('file').notNullable()
table.string('status', 8).notNullable().defaultTo('waiting')
table.timestamp('created_at', { useTz: true }).notNullable().defaultTo(this.now())
table.unique(['release_id', 'kind', 'message_id'])
})
this.schema.raw(`CREATE INDEX probe_candidates_waiting_idx ON probe_candidates (id) WHERE status = 'waiting'`)
}
async down() {
this.schema.dropTable('probe_candidates')
}
}