Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration files are not reloaded #1318

Open
fabpico opened this issue Feb 13, 2023 · 3 comments
Open

Migration files are not reloaded #1318

fabpico opened this issue Feb 13, 2023 · 3 comments

Comments

@fabpico
Copy link

fabpico commented Feb 13, 2023

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.

@sunchuo
Copy link

sunchuo commented Apr 14, 2024

same problem.

@greg0ire
Copy link
Member

What's the use case for doing this over using doctrine:schema:update?

@derrabus
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants