public function up() { $this->createTable(Category::tableName(), ['id' => Schema::TYPE_PK, 'owner_id' => $this->integer(), 'status' => Schema::TYPE_SMALLINT, 'title' => Schema::TYPE_STRING, 'name' => Schema::TYPE_STRING, 'image' => Schema::TYPE_STRING, 'content' => Schema::TYPE_TEXT, 'lft' => Schema::TYPE_INTEGER, 'rgt' => Schema::TYPE_INTEGER, 'depth' => Schema::TYPE_INTEGER]); $this->createTable(CategoryToItem::tableName(), ['category_id' => Schema::TYPE_INTEGER, 'item_id' => Schema::TYPE_INTEGER]); MigrationHelper::addForeignKey(CategoryToItem::tableName(), 'category_id', Category::tableName(), 'id', 'CASCADE', 'CASCADE'); MigrationHelper::addForeignKey(CategoryToItem::tableName(), 'item_id', Item::tableName(), 'id', 'CASCADE', 'CASCADE'); }
public function down() { $this->dropTable(Item::tableName()); }