forge->addField([ 'id' => [ 'type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true, ], 'category_id' => [ 'type' => 'INT', 'constraint' => 11, 'unsigned' => true, ], 'code' => [ 'type' => 'VARCHAR', 'constraint' => 20, 'null' => true, ], 'title' => [ 'type' => 'VARCHAR', 'constraint' => 255, ], 'description' => [ 'type' => 'TEXT', 'null' => true, ], 'score' => [ 'type' => 'INT', 'constraint' => 11, 'default' => 0, ], 'is_active' => [ 'type' => 'TINYINT', 'constraint' => 1, 'default' => 1, ], 'created_at' => [ 'type' => 'DATETIME', 'null' => true, ], 'updated_at' => [ 'type' => 'DATETIME', 'null' => true, ], ]); $this->forge->addKey('id', true); $this->forge->addForeignKey('category_id', 'violation_categories', 'id', 'CASCADE', 'CASCADE', 'violations_category_fk'); $this->forge->createTable('violations'); } public function down() { $this->forge->dropForeignKey('violations', 'violations_category_fk'); $this->forge->dropTable('violations'); } }