-
Notifications
You must be signed in to change notification settings - Fork 39
Open
Labels
Description
Initial state:
class Foo
{
/**
* @ORM\Column(type="text")
*/
private $content;
}php migration (2016-01-01.php)
assert($entityManager instanceof Doctrine\ORM\EntityManager);
foreach ($entityManager->getRepository(Foo::class)->findAll() as $foo) {
// ... queries db
}If we ever change the original model, for example by adding additional property
class Foo
{
/**
* @ORM\Column(type="text")
*/
private $content;
+ /**
+ * @ORM\Column(type="datetime_immutable")
+ */
+ private $createdAt;
}we will break the php migration, because Doctrine will query the database as
SELECT t0.content AS content, t0.created_at AS created_at -- ...
but the newly added column was not yet added to database when the php migration executes.
In other words, php migrations use latest meta data with Doctrine, because the model itself is not versioned (or at least the versions are not used for migration purposes).
I don't have a solution to propose, other than not using default Doctrine queries in php migrations. Even writing custom DQL/SQL queries cannot handle renamed columns etc.