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

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

    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('id')
                .inTable('users')
                .onDelete('CASCADE')
            table.decimal('amount', 19, 4)
            table.enum('status', ['pending', 'success', 'failed'])
            table.string('transaction_id').nullable()
            table.datetime('pay_time', { useTz: true }).nullable()
        })
    }

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