<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class AddBuilderTicketIdToTransactions extends Migration
{
    public function up()
    {
        if (!$this->db->fieldExists('builder_ticket_id', 'transactions')) {
            $this->forge->addColumn('transactions', [
                'builder_ticket_id' => [
                    'type' => 'INT',
                    'constraint' => 11,
                    'null' => true,
                    'after' => 'plan_id',
                ],
            ]);
        }
    }

    public function down()
    {
        if ($this->db->fieldExists('builder_ticket_id', 'transactions')) {
            $this->forge->dropColumn('transactions', 'builder_ticket_id');
        }
    }
}
