25 lines
806 B
TypeScript
25 lines
806 B
TypeScript
import { BaseSchema } from '@adonisjs/lucid/schema'
|
|
|
|
/**
|
|
* NZBs posted to Usenet are read into releases (CONCEPT.md D26): the archive
|
|
* password they may carry, and a lookup of files by their first segment.
|
|
*/
|
|
export default class extends BaseSchema {
|
|
async up() {
|
|
this.schema.alterTable('releases', (table) => {
|
|
// From <meta type="password"> of a posted NZB; passed on in our NZBs.
|
|
table.text('password')
|
|
})
|
|
this.defer(async (db) => {
|
|
await db.rawQuery(`CREATE INDEX IF NOT EXISTS files_first_segment_idx ON files ((message_ids->'1'->>'id'))`)
|
|
})
|
|
}
|
|
|
|
async down() {
|
|
this.defer(async (db) => {
|
|
await db.rawQuery('DROP INDEX IF EXISTS files_first_segment_idx')
|
|
})
|
|
this.schema.alterTable('releases', (table) => table.dropColumn('password'))
|
|
}
|
|
}
|