<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class CrearTablaSubModulo extends Migration
{
    public function up()
    {
        $this->forge->addField([
            'sumo_id' => [
                'type' => 'INT',
                'unsigned' => true,
                'auto_increment' => true,
                'null' => false,
            ],
            'sumo_descripcion' => [
                'type' => 'VARCHAR',
                'constraint' => 150,
                'null' => false,
            ],
            'sumo_enlace' => [
                'type' => 'VARCHAR',
                'constraint' => 150,
                'null' => false,
            ],
            'sumo_orden' => [
                'type' => 'INT',
                'null' => false,
            ],
            'sumo_estado' => [
                'type' => 'BOOL',
                'null' => false,
            ],
            'modu_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("sumo_id",true);
        $this->forge->addForeignKey('modu_id', 'modulo', 'modu_id');
        $this->forge->createTable("sub_modulo");
    }

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