<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class CreateClientsTable extends Migration
{
    public function up()
    {
        $this->forge->addField([
            'id' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true],
            'nombre' => ['type' => 'VARCHAR', 'constraint' => 200],
            'contrato' => ['type' => 'VARCHAR', 'constraint' => 80, 'null' => true],
            'direccion' => ['type' => 'TEXT', 'null' => true],
            'contacto_nombre' => ['type' => 'VARCHAR', 'constraint' => 160, 'null' => true],
            'contacto_email' => ['type' => 'VARCHAR', 'constraint' => 160, 'null' => true],
            'contacto_telefono' => ['type' => 'VARCHAR', 'constraint' => 40, 'null' => true],
            'notas' => ['type' => 'TEXT', 'null' => true],
            'created_at' => ['type' => 'DATETIME', 'null' => true],
            'updated_at' => ['type' => 'DATETIME', 'null' => true],
        ]);
        $this->forge->addKey('id', true);
        $this->forge->addKey('nombre');
        $this->forge->createTable('clients');
    }

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