<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class TypeAction extends Migration
{
    public function up()
    {
        //
        $this->forge->addField([
            'id_type_action'        => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
            'id_sous_menu'          => ['type' => 'INT', 'unsigned' => true,      'null' => false],
            'id_personnel'          => ['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_type_action', true); // Primary key
        $this->forge->addForeignKey('id_sous_menu', 'sys_sous_menu', 'id_sous_menu', 'CASCADE', 'CASCADE'); 
        $this->forge->addForeignKey('id_personnel', 'personnel', 'id', 'CASCADE', 'CASCADE'); // Primary key
        $this->forge->createTable('sys_type_action');
    }

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