<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class CreateLearningDeviceKktpTable extends Migration
{
    public function up()
    {
        $this->forge->addField([
            'id' => [
                'type'           => 'BIGINT',
                'unsigned'       => true,
                'auto_increment' => true,
            ],
            'learning_device_id' => [
                'type'       => 'BIGINT',
                'unsigned'   => true,
            ],
            'tp_id' => [
                'type'       => 'BIGINT',
                'unsigned'   => true,
            ],
            'indicators' => [
                'type' => 'TEXT',
                'null' => true,
            ],
            'rubric_bimbingan' => [
                'type' => 'TEXT',
                'null' => true,
            ],
            'rubric_cukup' => [
                'type' => 'TEXT',
                'null' => true,
            ],
            'rubric_baik' => [
                'type' => 'TEXT',
                'null' => true,
            ],
            'rubric_sangat_baik' => [
                'type' => 'TEXT',
                'null' => true,
            ],
            'created_at' => [
                'type' => 'DATETIME',
                'null' => true,
            ],
            'updated_at' => [
                'type' => 'DATETIME',
                'null' => true,
            ],
        ]);
        
        $this->forge->addKey('id', true);
        $this->forge->addForeignKey('learning_device_id', 'learning_devices', 'id', 'CASCADE', 'CASCADE');
        $this->forge->addForeignKey('tp_id', 'learning_device_tps', 'id', 'CASCADE', 'CASCADE');
        
        // Buat tabel
        $this->forge->createTable('learning_device_kktps');
    }

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