Files
usenet-indexer/database/migrations/1768620764760_add_par2_matching.ts
T

34 lines
1.2 KiB
TypeScript

import { BaseSchema } from '@adonisjs/lucid/schema'
/**
* Par2-based grouping of obfuscated posts (CONCEPT.md D16): the par2 file
* list of a release, and the exact file size of body-derived binaries to
* match against it.
*/
export default class extends BaseSchema {
async up() {
this.schema.alterTable('binaries', (table) => {
// Exact file size from =ybegin; only known for body-derived binaries.
table.bigInteger('size').index()
})
this.schema.alterTable('releases', (table) => {
// How the release was recognised: subject, stem, weak-stem or par2.
table.string('source', 16)
})
this.schema.createTable('release_files', (table) => {
table.bigInteger('release_id').notNullable().references('releases.id').onDelete('CASCADE')
table.string('par2_file_id', 32).notNullable()
table.text('name').notNullable()
table.bigInteger('size').notNullable().index()
table.string('md5_16k', 32).notNullable()
table.primary(['release_id', 'par2_file_id'])
})
}
async down() {
this.schema.dropTable('release_files')
this.schema.alterTable('releases', (table) => table.dropColumn('source'))
this.schema.alterTable('binaries', (table) => table.dropColumn('size'))
}
}