31 lines
974 B
TypeScript
31 lines
974 B
TypeScript
import { BaseSchema } from '@adonisjs/lucid/schema'
|
|
|
|
/**
|
|
* yEnc CRCs of body-derived articles, so split volumes can be verified
|
|
* without downloading them (CONCEPT.md D20): the combined part CRCs of a
|
|
* volume must equal the whole-file crc32 in its last part.
|
|
*/
|
|
export default class extends BaseSchema {
|
|
async up() {
|
|
for (const tableName of ['parts', 'part_conflicts']) {
|
|
this.schema.alterTable(tableName, (table) => {
|
|
table.string('pcrc32', 8)
|
|
// Decoded length of the part (=ypart end - begin + 1).
|
|
table.integer('part_size')
|
|
// Whole-file CRC32, when the poster included it (usually in the last part).
|
|
table.string('file_crc32', 8)
|
|
})
|
|
}
|
|
}
|
|
|
|
async down() {
|
|
for (const tableName of ['parts', 'part_conflicts']) {
|
|
this.schema.alterTable(tableName, (table) => {
|
|
table.dropColumn('pcrc32')
|
|
table.dropColumn('part_size')
|
|
table.dropColumn('file_crc32')
|
|
})
|
|
}
|
|
}
|
|
}
|