<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class CreateSchoolSettingsTable extends Migration
{
    public function up()
    {
        $this->forge->addField([
            'id'               => ['type' => 'BIGINT', 'unsigned' => true, 'auto_increment' => true],
            'school_name'      => ['type' => 'VARCHAR', 'constraint' => 200],
            'npsn'             => ['type' => 'VARCHAR', 'constraint' => 20, 'null' => true],
            'nss'              => ['type' => 'VARCHAR', 'constraint' => 20, 'null' => true],
            'school_type'      => ['type' => 'ENUM', 'constraint' => ['RA', 'MI', 'MTs', 'MA', 'MAK'], 'default' => 'MTs'],
            'address'          => ['type' => 'TEXT', 'null' => true],
            'village'          => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => true],
            'district'         => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => true],
            'city'             => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => true],
            'province'         => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => true],
            'postal_code'      => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
            'phone'            => ['type' => 'VARCHAR', 'constraint' => 20, 'null' => true],
            'email'            => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => true],
            'website'          => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => true],
            'principal_name'   => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => true],
            'principal_nip'    => ['type' => 'VARCHAR', 'constraint' => 30, 'null' => true],
            'logo'             => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
            'accreditation'    => ['type' => 'ENUM', 'constraint' => ['A', 'B', 'C', 'Belum'], 'default' => 'Belum'],
            'created_at'       => ['type' => 'DATETIME', 'null' => true],
            'updated_at'       => ['type' => 'DATETIME', 'null' => true],
        ]);
        $this->forge->addPrimaryKey('id');
        $this->forge->createTable('school_settings');
    }

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