<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class AddPointsBalanceAndPointsUsed extends Migration
{
    public function up(): void
    {
        $this->forge->addColumn('users', [
            'points_balance' => [
                'type'       => 'INT',
                'constraint' => 11,
                'unsigned'   => true,
                'default'    => 0,
                'after'      => 'role',
            ],
        ]);

        $this->forge->addColumn('orders', [
            'points_used' => [
                'type'       => 'INT',
                'constraint' => 11,
                'unsigned'   => true,
                'default'    => 0,
                'after'      => 'total_amount',
            ],
        ]);
    }

    public function down(): void
    {
        $this->forge->dropColumn('users', 'points_balance');
        $this->forge->dropColumn('orders', 'points_used');
    }
}
