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

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

    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').notNullable()
            table.decimal('amount', 19, 6).notNullable()
            table.string('type').notNullable()
            table.string('description').nullable()
            table.decimal('balance', 19, 6).notNullable()
            table.decimal('last_balance', 19, 6).notNullable()
            table.integer('series_id').nullable()
            table.integer('episode_id').nullable()
        })
    }

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