forge->addField([ 'id' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true], 'item_name' => ['type' => 'VARCHAR', 'constraint' => 255], 'category_id' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true], 'updated_at' => ['type' => 'DATETIME', 'null' => true], ]); $this->forge->addKey('id', true); // Znormalizowana nazwa pozycji jest kluczem uczenia (jedno mapowanie na nazwe). $this->forge->addUniqueKey('item_name'); $this->forge->addForeignKey('category_id', 'categories', 'id', 'CASCADE', 'CASCADE'); $this->forge->createTable('receipt_category_map', true, ['ENGINE' => 'InnoDB']); } public function down(): void { $this->forge->dropTable('receipt_category_map', true); } }