I'm currently setting up doctrine-migrations for a symfony project. I'm wondering why the auto generated migrations use direct SQL-Statements. These ones for example restrict it to mysql and INNODB-enginge (since it's my local environment). But the database environment the project it will run in might differ.
Why does it not let the entity manager handle this kind of stuff ?
E.g. in the up-function it will generated something like:
$this->addSql('CREATE TABLE tag (id INT AUTO_INCREMENT NOT NULL, category_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, is_active TINYINT(1) DEFAULT \'1\' NOT NULL, INDEX IDX_389B78312469DE2 (category_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
Why does it not use the schemaTool ? like:
$schemaTool = new SchemaTool($em);
$metaData = $em->getClassMetadata($className);
if ($this->sm->tablesExist(array($metaData->getTableName())) == true) {
$this->write("Table already exists :" . $className);
}
else{
$schemaTool->createSchema([
$metaData
]);
}
This way it would not be depending on my DB-Settings. Am i missing something ? or are there mayor downsides to let the schemaTool take care of it or use the entitymanager for the data-migration at all?