2012-07-13 95 views
6

我正在使用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 

定制类型'点'已被映射,所以我做错了什么?

+0

我在synfony 3与postgres和我得到这个错误,你知道我该怎么解决它?我在config.yml中没有类型:[Doctrine \ DBAL \ DBALException] 请求未知的数据库类型点,Doctrine \ DBAL \ Platforms \ PostgreSQL92Platform可能不支持它。 – 2017-09-21 14:55:54

回答

12

我回答我自己的问题,看来问题是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 
+0

非常感谢,这节省了我一些头痛:-)不幸的是,这在使用映射到相同SQL本机的多个自定义类型时存在问题。我有两种类型,enumA和enumB,它们都映射到ENUM(...)。学说可以忽略(DC2Type:enumA)评论。 : - / – xrstf 2012-09-19 21:39:33