我使用Symfony 4.1
在配置完SonataMediaBundle和SonataClassificationBundle后,请同时安装它们。 并且您要执行命令
php bin /控制台学说:schema:update --force
您收到此错误
The table with name 'shop.classification__collection' already exists.
与所有其他分类表(例如类别和标签)相同 如果您尝试将classification__collection实体中的表的名称更改为classification_collection
您将收到类似
的第二个错误 An exception occurred while executing 'CREATE UNIQUE INDEX tag_collection ON classification__collection (slug, context):
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes
答案 0 :(得分:0)
我最近遇到了这个问题,并找到了解决方法。
问题在这里解决
https://github.com/sonata-project/SonataClassificationBundle/issues/407
您只需要通过分类删除在App / Entity中创建的实体,或者将类重新映射到sonata.yaml和sonata_classification.yaml中的App / Entity
如果您删除了“应用程序/实体”中的实体,请将以下配置添加到您的sonata.yaml和sonata_classification.yaml
/ ** sonata_classification.yaml ** /
sonata_classification:
class:
tag: App\Application\Sonata\ClassificationBundle\Entity\Tag
category: App\Application\Sonata\ClassificationBundle\Entity\Category
media: App\Application\Sonata\MediaBundle\Entity\Media
collection: App\Application\Sonata\ClassificationBundle\Entity\Collection
context: App\Application\Sonata\ClassificationBundle\Entity\Context
/ ** sonata.yaml ** /
class:
media: App\Application\Sonata\MediaBundle\Entity\Media
gallery: App\Application\Sonata\MediaBundle\Entity\Gallery
gallery_has_media: App\Application\Sonata\MediaBundle\Entity\GalleryHasMedia
category: App\Application\Sonata\ClassificationBundle\Entity\Category