Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Doctrine Migrations, problems using custom doctrine 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?

like image 758
Victor Henriquez Avatar asked Jul 13 '12 12:07

Victor Henriquez


People also ask

What is a doctrine migration?

The Doctrine Migrations offer additional functionality on top of the database abstraction layer (DBAL) for versioning your database schema and easily deploying changes to it. It is a very easy to use and powerful tool. In order to use migrations you need to do some setup first.

What are migrations in Symfony?

Database migrations are a way to safely update your database schema both locally and on production. Instead of running the doctrine:schema:update command or applying the database changes manually with SQL statements, migrations allow to replicate the changes in your database schema in a safe manner.


1 Answers

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
like image 91
Victor Henriquez Avatar answered Sep 19 '22 03:09

Victor Henriquez