forge->addField([ 'id' => [ 'type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true, ], 'nis' => [ 'type' => 'VARCHAR', 'constraint' => '50', 'unique' => true, ], 'name' => [ 'type' => 'VARCHAR', 'constraint' => '255', ], 'class_id' => [ 'type' => 'INT', 'constraint' => 11, 'unsigned' => true, ], 'created_at' => [ 'type' => 'DATETIME', 'null' => true, ], 'updated_at' => [ 'type' => 'DATETIME', 'null' => true, ], ]); $this->forge->addKey('id', true); $this->forge->addKey('class_id'); $this->forge->addForeignKey('class_id', 'classes', 'id', 'CASCADE', 'CASCADE'); $this->forge->createTable('students'); } public function down() { $this->forge->dropTable('students'); } }