Running php app/console doctrine:migrations:diff
generates a new migration class as required to translate the current database schema to that specified by changes to entities.
This example shows such a generated class for creating a 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 the generated migration is tied to a specific database server, that being MySQL in this instance.
I'd like to use an in-memory sqlite database in test environments due to the (expected) performance benefits reducing test execution time.
I could take the above generated SQL and translate that into $table = $schema->createTable(); $table->addColumn();
equivalents, however doing so is both time consuming and invites the introduction of errors due to a poor human translation of SQL to code.
Can the doctrine:migrations:diff command create platform-agnostic migration code instead of the above platform-specific SQL?