migrations
migrations copied to clipboard
Migration files are not reloaded
Version 3.5.5
In a Symfony command, I call Doctrine commands. I create a migrations file and immediately execute it.
$this->getApplication()->find('doctrine:migrations:diff')->run(new StringInput(''), $output);
// ...
$this->getApplication()->find('doctrine:migrations:execute')->run(new StringInput("versions $lastMigrationsClass"), $output);
I get
In MigrationClassNotFound.php line 15:
Migration class "DoctrineMigrations\Version20230213092010" was not found?
But it works, when I run both commands separately over the terminal. Meaning each terminal request boots the console application form new.
I debugged and saw that the loaded migration files misses the new migration file, but it exists in the filesystem. I see that vendor/doctrine/migrations/lib/Doctrine/Migrations/FilesystemMigrationsRepository.php
Loads the migration files only once.
private function loadMigrationsFromDirectories(): void
{
$migrationDirectories = $this->migrationDirectories;
if ($this->migrationsLoaded) {
return;
}
$this->migrationsLoaded = true;
Why is this reload of migrations guarded by an early return? Can’t the migrations just be reloaded?
Current behavior
Migration files are not reloaded internally.
Expected behavior
Migration files should be reloaded internally.
same problem.
What's the use case for doing this over using doctrine:schema:update
?
As I wrote here: I'm not sure if this is an issue worth fixing. The generated migration is not meant to be executed immediately, but to be reviewed and adjusted by a human being.