<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class AttendanceSolution extends Migration
{

    public function up()
    {
        $fields = [
            'id' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true],
            'nama' => ['type' => 'VARCHAR',  'constraint' => 255],
            'ip' => ['type' => 'CHAR', 'constraint' => 64,],
            'port' => ['type' => 'CHAR', 'constraint' => 64, 'default' => 4370],
            'commKey' => ['type' => 'CHAR', 'constraint' => 64, 'default' => 4370],
            'is_connected' => ['type' => 'ENUM',  'constraint' => ['1', '0'], 'default' => '0'],
            'is_active' => ['type' => 'ENUM',  'constraint' => ['1', '0'], 'default' => '0'],
            'disconnected_at' => ['type' => 'INT',  'constraint' => 11, 'null' => true],
            'sync_at' => ['type' => 'INT',  'constraint' => 11, 'null' => true],
            'updated_at' => ['type' => 'INT',  'constraint' => 11],
            'created_at' => ['type' => 'INT',  'constraint' => 11],
        ];
        $this->forge->addField($fields);
        $this->forge->addKey('id', true);
        $this->forge->createTable('attendance_solution_device', true);
    }

    public function down()
    {
        // drop constraints first to prevent errors
        $this->forge->dropTable('attendance_solution_device', true);
    }
}
