<?php defined('BASEPATH') OR exit('No direct script access allowed');

class Migration_fix_report_pesan_tracking extends CI_Migration
{
    public function up()
    {
        if (!$this->db->field_exists('state', 'report_pesan')) {
            $this->dbforge->add_column('report_pesan', [
                'state' => ['type' => 'VARCHAR', 'constraint' => 30, 'null' => true, 'after' => 'status']
            ]);
        }
        if (!$this->db->field_exists('stateid', 'report_pesan')) {
            $this->dbforge->add_column('report_pesan', [
                'stateid' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => true, 'after' => 'state']
            ]);
        }

        // DATE membuang jam kirim dan selalu dibaca sebagai 00:00.
        $this->db->query('ALTER TABLE `report_pesan` MODIFY `create_date` DATETIME NULL');
    }

    public function down()
    {
        // Tidak mengembalikan ke DATE karena akan menghilangkan informasi jam.
    }
}
