<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class Enfant extends Migration
{
    public function up()
    {
        //
        //
        $this->forge->addField([
            'id'             => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
            'nom'            => ['type' => 'VARCHAR', 'constraint' => 100],
            'prenom'         => ['type' => 'VARCHAR', 'constraint' => 100],
            'age'            => ['type' => 'INT'],
            'sexe'           => ['type' => 'ENUM("h","f")'],
            'type_parent'    => ['type' => 'ENUM("père","mère","tuteur")'],
            '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', true); // Primary key
        $this->forge->addForeignKey('id_personnel', 'personnel', 'id', 'CASCADE', 'CASCADE');
        $this->forge->createTable('enfant');
    }

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