Symfony2 - Can the doctrine: migrations: diff create DB agnostic code instead of SQL?

Running php app/console doctrine:migrations:diff generates a new migration class necessary to translate the current database schema to the value indicated by the changes for the objects.

This example shows the generated class to create the fos_user table:

 class Version20120712145445 extends AbstractMigration { public function up(Schema $schema) { $this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql"); $this->addSql("CREATE TABLE fos_user (id INT AUTO_INCREMENT NOT NULL, ...); } public function down(Schema $schema) { $this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql"); $this->addSql("DROP TABLE fos_user"); } } 

As you can see, this generated migration is bound to a specific database server, which is MySQL in this case.

I would like to use the in-memory sqlite database in test environments because of the (expected) performance benefits that shorten the test execution time.

I could take the above SQL code and translate it into the equivalents of $table = $schema->createTable(); $table->addColumn(); $table = $schema->createTable(); $table->addColumn(); , however, it takes so long and requires errors due to poor translation of the SQL language into code.

Can the: migrations: diff command doctrine generate platform agnostic migration code instead of the platform specific SQL platform above?

+4
source share
2 answers

No, this is not possible with current versions. If you need agnostic database migrations, you should take a look at LiquiBase for migration. There is also a Symfony2 package for LiquiBase LiquibaseBundle

+3
source

There is currently no support for other database migration tools, but they plan to support some database management tools.

see doctrine: DBAL-602 this ticket is a query function to support LiquiBase, DBDeploy, and phinx for doctrine migration.

+2
source

All Articles