我正在使用 Symfony2 + Doctrine2 构建一个应用程序。我的应用程序需要存储地理空间数据,因此我编写了适当的学说扩展。一切都运行得很好,并且该应用程序已经在生产环境中运行了很长时间。
现在我必须添加一些新功能,并且需要更新数据库而不删除所有数据。我考虑过使用 DoctrineMigrationBundle 但当我运行时:
$ php app/console doctrine:migrations:status
我收到这个错误:
[Doctrine\DBAL\DBALException]
Unknown database type point requested,
Doctrine\DBAL\Platforms\MySqlPlatform may not
support it.
这是我的 config.yml 的相关部分:
# 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:
point: App\EngineBundle\DoctrineExtensions\PointType
自定义类型“点”已被映射,那么我做错了什么?
我回答我自己的问题,看来问题是 DoctrineMigrations 还需要自定义类型的映射。所以 config.yml 应该是这样的:
# 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:
point: App\EngineBundle\DoctrineExtensions\PointType
mapping_types:
point: point
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)