<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class AddRazorpayAndAuthFieldsToRegistrations extends Migration
{
    public function up()
    {
        $fields = [
            'password' => [
                'type'       => 'VARCHAR',
                'constraint' => '255',
                'null'       => true,
                'after'      => 'phone'
            ],
            'razorpay_order_id' => [
                'type'       => 'VARCHAR',
                'constraint' => '255',
                'null'       => true,
                'after'      => 'status'
            ],
            'razorpay_payment_id' => [
                'type'       => 'VARCHAR',
                'constraint' => '255',
                'null'       => true,
                'after'      => 'razorpay_order_id'
            ],
            'razorpay_signature' => [
                'type'       => 'VARCHAR',
                'constraint' => '255',
                'null'       => true,
                'after'      => 'razorpay_payment_id'
            ]
        ];
        $this->forge->addColumn('registrations', $fields);

        $modifyFields = [
            'batch' => [
                'type'       => 'VARCHAR',
                'constraint' => '100',
                'null'       => true
            ]
        ];
        $this->forge->modifyColumn('registrations', $modifyFields);
    }

    public function down()
    {
        $this->forge->dropColumn('registrations', ['password', 'razorpay_order_id', 'razorpay_payment_id', 'razorpay_signature']);
    }
}
