<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class CreateAnggota extends Migration
{
    public function up()
    {
        $this->forge->addField([
          'id' => [
    'type'           => 'INT',
    'constraint'     => 11,
    'unsigned'       => true,
    'auto_increment' => true,
],
            'nama' => [
                'type'       => 'VARCHAR',
                'constraint' => 100,
            ],
            'nisn' => [
                'type'       => 'VARCHAR',
                'constraint' => 20,
                'null'       => true,
            ],
            'jenis' => [
                'type'       => 'ENUM',
                'constraint' => ['Siswa','Guru'],
            ],
            'kelas' => [
                'type'       => 'VARCHAR',
                'constraint' => 20,
                'null'       => true,
            ],
            'alamat' => [
                'type' => 'TEXT',
                'null' => true,
            ],
            'foto' => [
                'type'       => 'VARCHAR',
                'constraint' => 255,
                'default'    => 'default.png',
            ],
            'created_at DATETIME DEFAULT CURRENT_TIMESTAMP',
            'updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'
        ]);

        $this->forge->addKey('id', true);
        $this->forge->createTable('anggota');
    }

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