<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class CrearTablaDetallePerfil extends Migration
{
    public function up()
    {
        $this->forge->addField([
            'depe_id' => [
                'type' => 'INT',
                'unsigned' => true,
                'auto_increment' => true,
                'null' => false,
            ],
            'depe_estado' => [
                'type' => 'BOOL',
                'null' => false,
            ],
            'sumo_id' => [
                'type' => 'INT',
                'unsigned' => true,
                'null' => false,
            ],
            'perf_id' => [
                'type' => 'INT',
                'unsigned' => true,
                'null' => false,
            ],
            'created_at timestamp default current_timestamp',
            'updated_at timestamp default current_timestamp on update current_timestamp'
        ]);

        $this->forge->addKey("depe_id",true);
        $this->forge->addForeignKey('sumo_id', 'sub_modulo', 'sumo_id');
        $this->forge->addForeignKey('perf_id', 'perfil', 'perf_id');
        $this->forge->createTable("detalle_perfil");
    }

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