<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class SousMenu extends Migration
{
    public function up()
    {
        //
        $this->forge->addField([
            'id_sous_menu'          => ['type' => 'INT', 'unsigned' => true,'auto_increment' => true],
            'libelle'               => ['type' => 'VARCHAR', 'constraint' => 150],
            'id_menu'               => ['type' => 'INT', 'unsigned' => true, 'null' => false],
            'created_at'            => ['type' => 'DATETIME', 'null' => true],
            'updated_at'            => ['type' => 'DATETIME', 'null' => true],
            'deleted_at'            => ['type' => 'DATETIME', 'null' => true],
        ]);
        
        $this->forge->addKey('id_sous_menu', true); // Primary key
        $this->forge->addForeignKey('id_menu', 'sys_menu', 'id_menu', 'CASCADE', 'CASCADE');
        $this->forge->createTable('sys_sous_menu');
    }

    public function down()
    {
        //
        $this->forge->dropTable('sys_sous_menu');
    }
}

