<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class CreateServerTable extends Migration
{
    public function up()
    {
        $this->forge->addField([
            'id' => [
                'type' => 'INT',
                'constraint' => 11,
                'unsigned' => true,
                'auto_increment' => true,
            ],
            'server_name' => [
                'type' => 'VARCHAR',
                'constraint' => 255,
            ],
            'kepemilikan_dropdown' => [
                'type' => 'VARCHAR',
                'constraint' => 255,
            ],
            'kepemilikan_lainnya' => [
                'type' => 'VARCHAR',
                'constraint' => 255,
                'null' => true,
            ],
            'serah_terima' => [
                'type' => 'DATE',
                'null' => true,
            ],
            'penanggung_jawab' => [
                'type' => 'VARCHAR',
                'constraint' => 255,
                'null' => true,
            ],
            'cpu_core' => [
                'type' => 'INT',
                'constraint' => 11,
            ],
            'ram' => [
                'type' => 'INT',
                'constraint' => 11,
            ],
            'storage' => [
                'type' => 'INT',
                'constraint' => 11,
            ],
            'status' => [
                'type' => 'VARCHAR',
                'constraint' => 50,
            ],
            'operating_system' => [
                'type' => 'VARCHAR',
                'constraint' => 255,
            ],
            'server_date' => [
                'type' => 'DATE',
            ],
            'last_evaluated' => [
                'type' => 'DATE',
            ],
            'next_maintenance' => [
                'type' => 'DATE',
            ],
            'created_at' => [
                'type' => 'DATETIME',
                'null' => true,
            ],
            'updated_at' => [
                'type' => 'DATETIME',
                'null' => true,
            ],
            'deleted_at' => [
                'type' => 'DATETIME',
                'null' => true,
            ],
        ]);

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

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