<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class CrearAlumno extends Migration
{
    public function up()
    {
        $this->forge->addField([
            'alum_id' => [
                'type' => 'INT',
                'unsigned' => true,
                'auto_increment' => true,
                'null' => false,
            ],
            'pers_id' => [
                'type' => 'INT',
                'unsigned' => true,
                'null' => false,
            ],
            'alum_codigo' => [
                'type' => 'VARCHAR',
                'constraint' => 150,
                'null' => false,
            ],
            'alum_estado' => [
                'type' => 'BOOL',
                'null' => false,
            ],
            'created_at timestamp default current_timestamp',
            'updated_at timestamp default current_timestamp on update current_timestamp'
        ]);

        $this->forge->addKey("alum_id",true);
        $this->forge->addForeignKey('pers_id', 'persona', 'pers_id');
        $this->forge->createTable("alumno");
    }

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