import { BaseSchema } from '@adonisjs/lucid/schema' /** * Segments (articles) of a binary. The primary key makes re-ingesting the * same range a no-op. */ export default class extends BaseSchema { protected tableName = 'parts' async up() { this.schema.createTable(this.tableName, (table) => { table.bigInteger('binary_id').notNullable().references('binaries.id').onDelete('CASCADE') table.integer('number').notNullable() table.text('message_id').notNullable() table.integer('bytes').notNullable() table.bigInteger('article_number') table.primary(['binary_id', 'number']) }) } async down() { this.schema.dropTable(this.tableName) } }