<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class AddIsArchivedToTips extends Migration
{
    public function up()
    {
        // Check if column already exists
        if (!$this->db->fieldExists('is_archived', 'tips')) {
            $this->forge->addColumn('tips', [
                'is_archived' => [
                    'type' => 'TINYINT',
                    'constraint' => 1,
                    'default' => 0,
                    'null' => false,
                    'comment' => '0=active, 1=archived',
                ],
            ]);
        }
    }

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

