<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class CrearDatosInstitucion extends Migration
{
    public function up()
    {
        $this->forge->addField([
            'datins_id' => [
                'type' => 'INT',
                'unsigned' => true,
                'auto_increment' => true,
                'null' => false,
            ],
            'datins_razon_social' => [
                'type' => 'VARCHAR',
                'constraint' => 250,
                'null' => false,
            ],
            'datins_ubigeo' => [
                'type' => 'VARCHAR',
                'constraint' => 150,
                'null' => false,
            ],
            'datins_direccion' => [
                'type' => 'VARCHAR',
                'constraint' => 150,
                'null' => false,
            ],
            'datins_logo' => [
                'type' => 'VARCHAR',
                'constraint' => 150,
                'null' => true,
            ],
            'created_at timestamp default current_timestamp',
            'updated_at timestamp default current_timestamp on update current_timestamp'
        ]);

        $this->forge->addKey("datins_id", true);
        $this->forge->addForeignKey('datins_ubigeo', 'ubigeo_peru_districts', 'id');
        $this->forge->createTable("datos_institucion");
    }
    public function down()
    {
        $this->forge->dropTable("datos_institucion", true);
    }
}
