<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class CreateUserTipsterSelectionsTable extends Migration
{
    public function up()
    {
        $this->forge->addField([
            'id' => [
                'type' => 'INT',
                'constraint' => 11,
                'unsigned' => true,
                'auto_increment' => true,
            ],
            'msisdn' => [
                'type' => 'VARCHAR',
                'constraint' => 20,
                'null' => false,
                'comment' => 'User phone number',
            ],
            'tipster' => [
                'type' => 'VARCHAR',
                'constraint' => 255,
                'null' => false,
                'comment' => 'Selected tipster name',
            ],
            'created_at' => [
                'type' => 'DATETIME',
                'null' => false,
            ],
        ]);

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

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