<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class CreateClients extends Migration
{
    public function up()
    {
        $this->forge->addField([
            "id" => [
                "type" => "INT",
                "unsigned" => true,
                "auto_increment" => true,
            ],
            "first_name" => ["type" => "VARCHAR", "constraint" => 100],
            "last_name" => ["type" => "VARCHAR", "constraint" => 100],
            "email" => ["type" => "VARCHAR", "constraint" => 190],
            "mobile" => ["type" => "VARCHAR", "constraint" => 40],
            "address" => ["type" => "TEXT"],
            "created_at" => ["type" => "DATETIME", "null" => true],
            "updated_at" => ["type" => "DATETIME", "null" => true],
        ]);
        $this->forge->addKey("id", true);
        $this->forge->addUniqueKey("email");
        $this->forge->addKey(["last_name", "first_name"]);
        $this->forge->addKey("created_at");
        $this->forge->createTable("clients", true);
    }

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