<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class AddWaliUserIdToClassesTable extends Migration
{
    public function up()
    {
        $this->forge->addColumn('classes', [
            'wali_user_id' => [
                'type'       => 'INT',
                'constraint' => 11,
                'unsigned'   => true,
                'null'       => true,
                'after'      => 'grade',
            ],
        ]);
        $this->forge->addForeignKey('wali_user_id', 'users', 'id', 'SET NULL', 'CASCADE', 'classes_wali_user_id_fk');
    }

    public function down()
    {
        $this->forge->dropForeignKey('classes', 'classes_wali_user_id_fk');
        $this->forge->dropColumn('classes', 'wali_user_id');
    }
}
