<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class CreatePointsLogTable extends Migration
{
    public function up()
    {
        $this->forge->addField([
            'id' => [
                'type' => 'INT',
                'constraint' => 11,
                'unsigned' => true,
                'auto_increment' => true,
            ],
            'msisdn' => [
                'type' => 'VARCHAR',
                'constraint' => 15,
            ],
            'points' => [
                'type' => 'INT',
                'constraint' => 11,
            ],
            'reason' => [
                'type' => 'TEXT',
                'null' => true,
            ],
            'created_at' => [
                'type' => 'DATETIME',
                'null' => false,
            ],
        ]);

        $this->forge->addKey('id', true);
        $this->forge->addKey('msisdn');
        $this->forge->createTable('points_log');
    }

    public function down()
    {
        $this->forge->dropTable('points_log');
    }
} 