import BaseSchema from '@ioc:Adonis/Lucid/Schema'

export default class extends BaseSchema {
    protected tableName = 'collections'

    public async up() {
        this.schema.createTable(this.tableName, (table) => {
            table.increments('id')
            table.datetime('created_at', { useTz: true })
            table.datetime('updated_at', { useTz: true })
            table.integer('user_id').unsigned().references('users.id').onDelete('CASCADE')
            table.integer('series_id').unsigned().references('series.id').onDelete('CASCADE')
            table.integer('cur_ep_num').unsigned().notNullable()
            table.integer('cur_ep_id').unsigned().references('episodes.id').onDelete('CASCADE')
        })
    }

    public async down() {
        this.schema.dropTable(this.tableName)
    }
}
