<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class CreateRewardsTable extends Migration
{
    public function up()
    {
        $this->forge->addField([
            'id' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true],
            'name' => ['type' => 'VARCHAR', 'constraint' => 150],
            'item_id' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true],
            'discount_type' => ['type' => 'VARCHAR', 'constraint' => 10],
            'discount_value' => ['type' => 'INT', 'constraint' => 11],
            'points_required' => ['type' => 'INT', 'constraint' => 11],
            'is_active' => ['type' => 'TINYINT', 'constraint' => 1, 'default' => 1],
            'created_at' => ['type' => 'DATETIME', 'null' => true],
        ]);
        $this->forge->addKey('id', true);
        $this->forge->createTable('rewards');
    }

    public function down()
    {
        $this->forge->dropTable('rewards', true);
    }
}
