Files
usenet-indexer/database/migrations/1768620764900_add_fetch_bodies_to_groups.ts
T

25 lines
777 B
TypeScript

import { BaseSchema } from '@adonisjs/lucid/schema'
/**
* Body downloads per group (CONCEPT.md D24). Identifying obfuscated articles
* costs one body download each; busy groups carry far more of them than the
* line can fetch, so they are indexed header-only (normal subjects) unless
* enabled.
*/
export default class extends BaseSchema {
protected tableName = 'groups'
async up() {
this.schema.alterTable(this.tableName, (table) => {
table.boolean('fetch_bodies').notNullable().defaultTo(false)
})
this.defer(async (db) => {
await db.rawQuery(`UPDATE groups SET fetch_bodies = true WHERE name = 'alt.binaries.test'`)
})
}
async down() {
this.schema.alterTable(this.tableName, (table) => table.dropColumn('fetch_bodies'))
}
}