使用自定义教义类型的问题

使用自定义教义类型的问题

本文介绍了教义迁移,使用自定义教义类型的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Symfony2 + Doctrine2构建应用程序。我的应用程序需要存储地理空间数据,所以我写了适当的原则扩展。所有的工作都很好,应用程序已经在生产环境中运行了很长时间。



现在我必须添加一些新功能,我需要更新数据库而不删除所有的数据。我想了解使用DoctrineMigrationBundle,但是当我运行时:

  $ php app / console doctrine:migrations:status 

我收到此错误:

  [Doctrine\DBAL\DBALException] 
未知的数据库类型请求点,
Doctrine\DBAL\Platforms\MySqlPlatform可能不支持

这是我config.yml的相关部分:

 #Doctrine配置
doctrine:
dbal:
驱动程序:%database_driver%
主机:%database_host%
port:%database_port%
dbname:%database_name%
用户:%database_user%
密码:%database_password%
字符集:UTF8
类型:
点:App \EngineBundle\DoctrineExtensions\PointType

自定义类型点已被映射那么我做错了什么?

解决方案

我回答自己的问题,似乎问题是DoctrineMigrations还需要一个映射自定义类型。所以config.yml应该如下所示:

 #Doctrine Configuration 
doctrine:
dbal:
驱动程序:%database_driver%
主机:%database_host%
端口:%database_port%
dbname:%database_name%
用户:%database_user%
密码: %database_password%
字符集:UTF8
类型:
点:App \EngineBundle\DoctrineExtensions\PointType
mapping_types:
点:点


I'm building a application using Symfony2 + Doctrine2. My application needs to store geospatial data, so I wrote the proper doctrine extensions. All is working pretty good and the app have been running in a production enviroment for a long time.

Now I have to add some new features and I need to update the database without deleting all the data. I thougth about using the DoctrineMigrationBundle but when I run:

$ php app/console doctrine:migrations:status

I got this error:

[Doctrine\DBAL\DBALException]
  Unknown database type point requested,
  Doctrine\DBAL\Platforms\MySqlPlatform may not
  support it.

This is the relevant section of my 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

The custom type 'point' has been mapped, so what am I doing wrong?

解决方案

I answer my own question, it seems the problem is DoctrineMigrations also needs a mapping for the custom type. So the config.yml should look like this:

# 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

这篇关于教义迁移,使用自定义教义类型的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 11:35