Dan*_*Dan 5 symfony symfony-sonata
我在我的Symfony 2应用程序上安装了几个Sonata软件包(用户,管理员等),但在使用它们一段时间后,我觉得我不喜欢它们并想要删除它们.
我已经更新了我的composer.json和AppKernel.php文件,删除了与Sonata有关的任何内容.我还删除了所有相关的路由,配置和安全文件条目.但是,我现在无法更新我的数据库架构.
每当我运行一个时,我会收到以下错误:
[Doctrine\DBAL\DBALException]
Unknown column type "json" requested. Any Doctrine type that you use has to
be registered with \Doctrine\DBAL\Types\Type::addType(). You can get a lis
t of all the known types with \Doctrine\DBAL\Types\Type::getTypeMap(). If t
his error occurs during database introspection then you might have forgot t
o register all database types for a Doctrine Type. Use AbstractPlatform#reg
isterDoctrineTypeMapping() or have your custom types implement Type#getMapp
edDatabaseTypes(). If the type name is empty you might have a problem with
the cache or forgot some mapping information.
Run Code Online (Sandbox Code Playgroud)
我知道这是来自其中一个Sonata捆绑包的Doctrine配置:
# Doctrine Configuration doctrine:
dbal:
driver: %database_driver%
host: %database_host%
port: %database_port%
dbname: %database_name%
user: %database_user%
password: %database_password%
charset: UTF8
#types:
# json: Sonata\Doctrine\Types\JsonType
Run Code Online (Sandbox Code Playgroud)
正如你所看到的,我已经评论过这一点,我仍然继续得到错误.
我无法追踪仍然被引用的地方.
我和大多数人一样有同样的问题.以前安装SonataAdminBundle时遇到了问题,但如果您安装SonataAdminBundle并且无法正常工作,那可能就是问题所在.如果是这种情况,请看这个链接:https: //github.com/sonata-project/SonataAdminBundle/issues/811
在我的情况下,以及大多数其他人在这里,这发生在删除SonataAdminBundle时,由于某种原因,它像一股难闻的气味一样徘徊.我尝试删除数据库并在其他不起作用的东西中再次恢复它.
所以下面的黑客似乎得到了#Protrine配置
doctrine:
dbal:
...
types: #this is about this line and line below
json: \Doctrine\DBAL\Types\StringType
Run Code Online (Sandbox Code Playgroud)
绝对不是一个完美的解决方法,但应该让事情回到原来的样子,直到你真正需要JsonType,然后你可以引入类型.
当我从实体中删除字段并删除类型定义本身时,我收到此错误(不同的列类型)。在我引入类型定义并仅删除该字段后,没有错误。我进行了架构更新,然后我可以一起删除类型。
也许对您来说更好的解决方案是完全删除数据库并从头开始执行doctrine:schema:update。