forge->addField([ 'id' => ['type'=>'INT','unsigned'=>true,'auto_increment'=>true], 'user_id' => ['type'=>'INT','unsigned'=>true,'null'=>false], 'role_name' => ['type'=>'VARCHAR','constraint'=>64,'null'=>true], 'date' => ['type'=>'DATE','null'=>false], 'semester' => ['type'=>'VARCHAR','constraint'=>32,'null'=>false], 'school_year' => ['type'=>'VARCHAR','constraint'=>16,'null'=>false], 'status' => ['type'=>'ENUM','constraint'=>['present','absent','late'],'null'=>false,'default'=>'present'], 'reason' => ['type'=>'VARCHAR','constraint'=>255,'null'=>true], 'created_at' => ['type'=>'DATETIME','null'=>true], 'updated_at' => ['type'=>'DATETIME','null'=>true], 'created_by' => ['type'=>'INT','unsigned'=>true,'null'=>true], 'updated_by' => ['type'=>'INT','unsigned'=>true,'null'=>true], ]); $this->forge->addKey('id', true); $this->forge->addUniqueKey(['user_id','date','semester','school_year']); $this->forge->addForeignKey('user_id','users','id','CASCADE','CASCADE'); $this->forge->createTable('staff_attendance', true); } public function down() { $this->forge->dropTable('staff_attendance', true); } }