<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class AlterNews extends Migration
{
    public function up()
    {
        echo ">> ALTERNEWS DIJALANKAN\n";

        $fields = [
            'slug' => [
                'type'       => 'VARCHAR',
                'constraint' => 100,
                'unique'     => true,
                'null'       => true,
                'after'      => 'author',
            ],
        ];

        $this->forge->addColumn('news', $fields);

        // 🧩 Tambahkan bagian ini untuk melihat error MySQL
        $error = $this->db->error();
        print_r($error);
    }

    public function down()
    {
        $this->forge->dropColumn('news', 'slug');
    }
}