<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class CreateCiSessionsTable extends Migration
{
    public function up(): void
    {
        $fields = [
            'id' => [
                'type'       => 'VARCHAR',
                'constraint' => 128,
            ],
            'ip_address' => [
                'type'       => 'VARCHAR',
                'constraint' => 45,
            ],
            'timestamp' => [
                'type'    => 'INT',
                'default' => 0,
            ],
            'data' => [
                'type' => 'BLOB',
            ],
        ];

        $this->forge->addField($fields);
        $this->forge->addKey('id');
        $this->forge->addKey('timestamp');
        $this->forge->createTable('ci_sessions', true, ['ENGINE' => 'InnoDB']);
    }

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