<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class Createscheduleteachersettingstable extends Migration
{
    public function up()
    {
        $this->forge->addField([
            'id'                => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
            'teacher_id'        => ['type' => 'INT', 'unsigned' => true],
            'max_hours_per_day' => ['type' => 'TINYINT', 'unsigned' => true, 'null' => true,
                                    'comment' => 'NULL = pakai global default (6 jam)'],
            'notes'             => ['type' => 'VARCHAR', 'constraint' => 200, 'null' => true],
            'created_at'        => ['type' => 'DATETIME', 'null' => true],
            'updated_at'        => ['type' => 'DATETIME', 'null' => true],
        ]);
        $this->forge->addKey('id', true);
        $this->forge->addKey('teacher_id', false, true); // unique per guru
        $this->forge->createTable('schedule_teacher_settings', true);
    }

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