<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;
use CodeIgniter\Database\Config;

class HomeMenu extends Migration
{
    
    public function up()
    {
        // Define the schema for the 'email_settings' table
        $this->forge->addField([
            'hvm_uid' => [
                'type'       => 'VARCHAR',
                'constraint' => 50,
                'null'       => false,
            ],
            'hvm_name' => [
                'type'       => 'VARCHAR',
                'constraint' => 50,
                'null'       => false,
            ],
            'hvm_url' => [
                'type'       => 'VARCHAR',
                'constraint' => 255,
                'null'       => false,
            ],
            'hvm_img' => [
                'type'       => 'VARCHAR',
                'constraint' => 255,
                'null'       => false,
            ],
            'hvm_sl' => [
                'type'       => 'int',
                'constraint' => 2,
                'unsigned'   => true, 
                // 'auto_increment' => true,
                'null'       => false,
            ],
            'hvm_user' => [
                'type'       => 'VARCHAR',
                'constraint' => 30,
                'null'       => false,
            ],
            'hvm_update' => [
                'type' => 'TIMESTAMP',
                'null' => false,
            ],
        ]);

        // Add a primary key
        $this->forge->addPrimaryKey('hvm_uid');

        // Set the table's charset and collation
        $this->forge->createTable('tbl_hvmenu', true, [
            'ENGINE' => 'InnoDB',
            'DEFAULT CHARSET' => 'utf8mb4',
            'COLLATE' => 'utf8mb4_general_ci',
        ]);
    }


    
    public function down()
    {
        // $db = \Config\Database::connect();

        // $sql = "UPDATE tbl_role_menu SET mnu_url = ? where mnu_uid='d8698c96'";
        // $mnu_url = 'admin/inventory/inventry/invref'; 
        // $db->query($sql, [$mnu_url]);

        // $sql = "UPDATE tbl_role_menu SET mnu_url = ? where mnu_uid='d8698df8'";
        // $mnu_url = 'admin/inventory/inventry/invreflist'; 
        // $db->query($sql, [$mnu_url]);

        // $sql = "UPDATE tbl_role_menu SET mnu_url = ? where mnu_uid=' '";
        // $mnu_url = 'admin/inventory/inventry/invref'; 
        // $db->query($sql, [$mnu_url]);
    }
}
