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

php bakery migrate:rollback missing class errors #1002

Closed
amosfolz opened this issue Jun 24, 2019 · 8 comments
Closed

php bakery migrate:rollback missing class errors #1002

amosfolz opened this issue Jun 24, 2019 · 8 comments
Assignees
Labels
confirmed bug Something isn't working
Milestone

Comments

@amosfolz
Copy link
Contributor

amosfolz commented Jun 24, 2019

Trying to run php bakery migrate:rollback will fail if there is a missing migration class, even if it is not in the last batch that was ran.

image

image

It seems it shouldn't matter if a migration class is missing unless that class is part of the last batch ran, since php bakery migrate:rollback just reverses the most recent migration. Unless migrations != batches?

@lcharette
Copy link
Member

Can you pinpoint where this exception is thrown ?

@lcharette lcharette self-assigned this Jun 25, 2019
@lcharette lcharette added the confirmed bug Something isn't working label Jun 25, 2019
@lcharette lcharette added this to the 4.2.x milestone Jun 25, 2019
@amosfolz
Copy link
Contributor Author

Can you pinpoint where this exception is thrown ?

It seems to be from this line

Rather than trying to modify anything in any of the Migrator classes, a simpler solution might be to ask the user if they want to drop the "stale" record from the database table.

@lcharette
Copy link
Member

That might be a good idea... migrate:clean ?

@amosfolz
Copy link
Contributor Author

amosfolz commented Jul 2, 2019

#0  UserFrosting\Sprinkle\Core\Database\Migrator\MigrationDependencyAnalyser->getMigrationDependencies() called at [/home/vagrant/userfrosting/app/sprinkles/core/src/Database/Migrator/MigrationRollbackDependencyAnalyser.php:66]
#1  UserFrosting\Sprinkle\Core\Database\Migrator\MigrationRollbackDependencyAnalyser->validateClassDependencies() called at [/home/vagrant/userfrosting/app/sprinkles/core/src/Database/Migrator/MigrationDependencyAnalyser.php:78]
#2  UserFrosting\Sprinkle\Core\Database\Migrator\MigrationDependencyAnalyser->analyse() called at [/home/vagrant/userfrosting/app/sprinkles/core/src/Database/Migrator/MigrationDependencyAnalyser.php:161]
#3  UserFrosting\Sprinkle\Core\Database\Migrator\MigrationDependencyAnalyser->getUnfulfillable() called at [/home/vagrant/userfrosting/app/sprinkles/core/src/Database/Migrator/Migrator.php:327]
#4  UserFrosting\Sprinkle\Core\Database\Migrator\Migrator->checkRollbackDependencies() called at [/home/vagrant/userfrosting/app/sprinkles/core/src/Database/Migrator/Migrator.php:283]
#5  UserFrosting\Sprinkle\Core\Database\Migrator\Migrator->rollbackMigrations() called at [/home/vagrant/userfrosting/app/sprinkles/core/src/Database/Migrator/Migrator.php:218]
#6  UserFrosting\Sprinkle\Core\Database\Migrator\Migrator->rollback() called at [/home/vagrant/userfrosting/app/sprinkles/core/src/Bakery/MigrateRollbackCommand.php:80]
#7  UserFrosting\Sprinkle\Core\Bakery\MigrateRollbackCommand->execute() called at [/home/vagrant/userfrosting/app/vendor/symfony/console/Command/Command.php:255]
#8  Symfony\Component\Console\Command\Command->run() called at [/home/vagrant/userfrosting/app/vendor/symfony/console/Application.php:921]
#9  Symfony\Component\Console\Application->doRunCommand() called at [/home/vagrant/userfrosting/app/vendor/symfony/console/Application.php:273]
#10 Symfony\Component\Console\Application->doRun() called at [/home/vagrant/userfrosting/app/vendor/symfony/console/Application.php:149]
#11 Symfony\Component\Console\Application->run() called at [/home/vagrant/userfrosting/app/system/Bakery/Bakery.php:82]
#12 UserFrosting\System\Bakery\Bakery->run() called at [/home/vagrant/userfrosting/bakery:35]

@amosfolz
Copy link
Contributor Author

amosfolz commented Jul 2, 2019

Okay, based off the comment I found here, it seems the intention is to actually have the rollback continue in these cases of missing classes...

@lcharette
Copy link
Member

I remember that comment... At some point there was no way to display a warning from the migrator to the CLI as the migrator could be run independently from the CLI. I think the note thing solved that issue?

As long as the warning is displayed, I guess it should be fine to skip the migration. It might still break stuff, but nothing more can be done anyway if the class doesn't exist anymore...

@amosfolz
Copy link
Contributor Author

amosfolz commented Jul 4, 2019

There might be other situations where that note is still needed but when running migrate:rollback missing classes will cause Migrator->checkRollbackDependencies() to throw an exception.

On another note, I was looking through the debug trace I posted above and I am a bit confused about something. At line 2:

#2  UserFrosting\Sprinkle\Core\Database\Migrator\MigrationDependencyAnalyser->analyse()

Inside analyse() method there is this line $this->validateClassDependencies($migration);

I would have expected this to call the method at this line inside the MigrationDependencyAnalyser class.

But if you look at the stack trace:

#1  UserFrosting\Sprinkle\Core\Database\Migrator\MigrationRollbackDependencyAnalyser->validateClassDependencies() 

It actually calls the same method but from the MigrationRollbackDependencyAnalyser

I am just curious as to why that happens here.

@lcharette
Copy link
Member

Fixed in 4.2.3 by PR #1007

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants