3
votes

I want to use doctrine migrations in my non-symfony project, so I got the phar standalone from https://github.com/doctrine/migrations. I configured everything properly (db-configuration and configuration) and then when doing "migrations:status" I get the error:

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

Now there are many resources on how to fix this in the context of a symfony app (for instance http://wildlyinaccurate.com/doctrine-2-resolving-unknown-database-type-enum-requested) but where can I put this type mapping in this case? Should I extract the .phar, put the code in it (where?) and then re-package it? (how?)

3
You need to use migrations and setup the CLI on your own. Start from cloning github.com/doctrine/migrations and installing via composer. After that, customize your CLI runner to setup the connection according to your own needs. - Ocramius
In way which Ocramius suggests extra options wouldn't work (--db-config, --configuration). It's well known bug. - Igor Vizma

3 Answers

7
votes

I have tried something for Zend framework and it worked:

Open ./vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php Search for function initializeDoctrineTypeMappings() create an entry for enum as,

'enum' => 'string'

Worked like charm !

0
votes

That problem resolved in this fork
https://github.com/dyadyavasya/migrations

By default Doctrine does not map the MySQL enum type to a Doctrine type. This is because Enums contain state (their allowed values) and Doctrine types don’t.

Use fork at link and you can register MySQL ENUMs to map to Doctrine strings. This way Doctrine always resolves ENUMs to Doctrine strings.

migrations.yml

name: Doctrine Sandbox Migrations
migrations_namespace: DoctrineMigrations
table_name: doctrine_migration_versions
migrations_directory: /path/to/migrations/classes/DoctrineMigrations
mapping_types:
    enum: string

More information - https://github.com/dyadyavasya/migrations#migrationsyml

-1
votes

What Ocramius said:

You need to use migrations and setup the CLI on your own. Start from cloning github.com/doctrine/migrations and installing via composer. After that, customize your CLI runner to setup the connection according to your own needs.