Doctrine Migrations, problems using custom doctrin

2019-04-08 07:42发布

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?

1条回答
三岁会撩人
2楼-- · 2019-04-08 08:09

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
查看更多
登录 后发表回答