<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class CreateIndustries extends Migration
{
    public function up()
    {
        $this->forge->addField([
            "id" => [
                "type" => "INT",
                "unsigned" => true,
                "auto_increment" => true,
            ],
            "name" => ["type" => "VARCHAR", "constraint" => 120],
            "slug" => ["type" => "VARCHAR", "constraint" => 140],
            "meta_title" => ["type" => "VARCHAR", "constraint" => 180],
            "meta_description" => ["type" => "VARCHAR", "constraint" => 320],
            "hero_heading" => ["type" => "VARCHAR", "constraint" => 220],
            "hero_text" => ["type" => "TEXT"],
            "challenge_heading" => [
                "type" => "VARCHAR",
                "constraint" => 220,
            ],
            "challenge_text" => ["type" => "TEXT"],
            "primary_color" => [
                "type" => "VARCHAR",
                "constraint" => 7,
                "default" => "#142522",
            ],
            "accent_color" => [
                "type" => "VARCHAR",
                "constraint" => 7,
                "default" => "#caff62",
            ],
            "is_active" => [
                "type" => "TINYINT",
                "constraint" => 1,
                "default" => 1,
            ],
            "sort_order" => [
                "type" => "INT",
                "unsigned" => true,
                "default" => 0,
            ],
            "created_at" => ["type" => "DATETIME", "null" => true],
            "updated_at" => ["type" => "DATETIME", "null" => true],
        ]);
        $this->forge->addKey("id", true);
        $this->forge->addUniqueKey("slug");
        $this->forge->addKey("is_active");
        $this->forge->addKey("sort_order");
        $this->forge->createTable("industries", true, [
            "ENGINE" => "InnoDB",
        ]);
    }

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