39 lines
1.4 KiB
TypeScript
39 lines
1.4 KiB
TypeScript
import { BaseSchema } from '@adonisjs/lucid/schema'
|
|
|
|
/**
|
|
* A release is one download: the files of one post (archive volumes, par2
|
|
* set, nfo). See lib/release/release_key.ts and CONCEPT.md (D16).
|
|
*/
|
|
export default class extends BaseSchema {
|
|
protected tableName = 'releases'
|
|
|
|
async up() {
|
|
this.schema.createTable(this.tableName, (table) => {
|
|
table.bigIncrements('id')
|
|
table.string('release_key', 40).notNullable().unique()
|
|
table.text('name').notNullable()
|
|
// Null for obfuscated posts, whose poster is random per article.
|
|
table.text('poster')
|
|
// Number of files announced by the [i/M] subject counter, if any.
|
|
table.integer('file_total')
|
|
table.jsonb('groups').notNullable()
|
|
table.timestamp('posted_at', { useTz: true })
|
|
table.timestamp('first_seen_at', { useTz: true }).notNullable()
|
|
table.timestamp('last_seen_at', { useTz: true }).notNullable()
|
|
})
|
|
|
|
this.schema.alterTable('binaries', (table) => {
|
|
table.bigInteger('release_id').references('releases.id').onDelete('SET NULL').index()
|
|
})
|
|
this.schema.alterTable('files', (table) => {
|
|
table.bigInteger('release_id').references('releases.id').onDelete('SET NULL').index()
|
|
})
|
|
}
|
|
|
|
async down() {
|
|
this.schema.alterTable('files', (table) => table.dropColumn('release_id'))
|
|
this.schema.alterTable('binaries', (table) => table.dropColumn('release_id'))
|
|
this.schema.dropTable(this.tableName)
|
|
}
|
|
}
|