<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class CrearMatricula extends Migration
{
    public function up()
    {
        $this->forge->addField([
            'mat_id' => [
                'type' => 'INT',
                'unsigned' => true,
                'auto_increment' => true,
                'null' => false,
            ],
            'alum_id' => [
                'type' => 'INT',
                'unsigned' => true,
                'null' => false,
            ],
            'peraca_id' => [
                'type' => 'INT',
                'unsigned' => true,
                'null' => false,
            ],
            'mat_estado' => [
                'type' => 'BOOL',
                'null' => false,
            ],
            'created_at timestamp default current_timestamp',
            'updated_at timestamp default current_timestamp on update current_timestamp'
        ]);

        $this->forge->addKey("mat_id",true);
        $this->forge->addForeignKey('alum_id', 'alumno', 'alum_id');
        $this->forge->addForeignKey('peraca_id', 'periodo_academico', 'peraca_id');
        $this->forge->createTable("matricula");
    }

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