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

after migrating artisan migrate:refresh causes Fatal Error #44

Open
brianvice opened this issue Jan 27, 2016 · 3 comments
Open

after migrating artisan migrate:refresh causes Fatal Error #44

brianvice opened this issue Jan 27, 2016 · 3 comments

Comments

@brianvice
Copy link

To reproduce from new laravel 5.2 project:

php artisan make:auth
php artisan migrate
php artisan inventory:install
php artisan migrate:refresh

Fatal Error:

[Symfony\Component\Debug\Exception\FatalThrowableError]
Fatal error: Class 'CreateInventoryAssembliesTable' not found

Stacktrace:

[2016-01-27 09:36:01] local.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError: 
Fatal error: Class 'CreateInventoryAssembliesTable' not found in 
/home/vagrant/Code/InventoryManagement/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:336

#0 /home/vagrant/Code/InventoryManagement/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php(227): Illuminate\Database\Migrations\Migrator->resolve('create_inventor...')
#1 /home/vagrant/Code/InventoryManagement/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php(206): Illuminate\Database\Migrations\Migrator->runDown(Object(stdClass), false)
#2 /home/vagrant/Code/InventoryManagement/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/ResetCommand.php(69): Illuminate\Database\Migrations\Migrator->reset(false)
#3 [internal function]: Illuminate\Database\Console\Migrations\ResetCommand->fire()
#4 /home/vagrant/Code/InventoryManagement/vendor/laravel/framework/src/Illuminate/Container/Container.php(507): call_user_func_array(Array, Array)
#5 /home/vagrant/Code/InventoryManagement/vendor/laravel/framework/src/Illuminate/Console/Command.php(169): Illuminate\Container\Container->call(Array)
#6 /home/vagrant/Code/InventoryManagement/vendor/symfony/console/Command/Command.php(256): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArrayInput), Object(Illuminate\Console\OutputStyle))
#7 /home/vagrant/Code/InventoryManagement/vendor/laravel/framework/src/Illuminate/Console/Command.php(155): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArrayInput), Object(Illuminate\Console\OutputStyle))
#8 /home/vagrant/Code/InventoryManagement/vendor/laravel/framework/src/Illuminate/Console/Command.php(185): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArrayInput), Object(Illuminate\Console\OutputStyle))
#9 /home/vagrant/Code/InventoryManagement/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/RefreshCommand.php(45): Illuminate\Console\Command->call('migrate:reset', Array)
#10 [internal function]: Illuminate\Database\Console\Migrations\RefreshCommand->fire()
#11 /home/vagrant/Code/InventoryManagement/vendor/laravel/framework/src/Illuminate/Container/Container.php(507): call_user_func_array(Array, Array)
#12 /home/vagrant/Code/InventoryManagement/vendor/laravel/framework/src/Illuminate/Console/Command.php(169): Illuminate\Container\Container->call(Array)
#13 /home/vagrant/Code/InventoryManagement/vendor/symfony/console/Command/Command.php(256): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /home/vagrant/Code/InventoryManagement/vendor/laravel/framework/src/Illuminate/Console/Command.php(155): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 /home/vagrant/Code/InventoryManagement/vendor/symfony/console/Application.php(787): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 /home/vagrant/Code/InventoryManagement/vendor/symfony/console/Application.php(186): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Database\Console\Migrations\RefreshCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 /home/vagrant/Code/InventoryManagement/vendor/symfony/console/Application.php(117): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 /home/vagrant/Code/InventoryManagement/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(107): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#19 /home/vagrant/Code/InventoryManagement/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#20 {main}  
@brianvice
Copy link
Author

I found a solution to the problem:

I had to rename the laravel provided users and password_resets migrations to reflect a date prior to the migrations provided by the inventory package. Afterwards running composer dump-autoload cleared out any cached migration paths. At this point I can run migrate:refresh (I do this in behat tests for example). I can't explain the original error here though. For this reason, I'll leave this issue open. Otherwise, thanks for creating this very useful package!

@stevebauman
Copy link
Collaborator

Yup you're right, this is a bug. Apologies for the long response.

To avoid this issue, I'd personally recommend publishing the migrations (using vendor:publish) instead of the supplied command.

I could change publish method to rename the migration file names on the fly to use the current date, but this could also be an issue since using vendor:publish a second time would generate the migrations all over again due to the continuously different file names.

@brianvice
Copy link
Author

Thanks for your reply. I would have to try setting the package up again from a fresh install to know for sure, but I believe that I have to do a vendor:publish before running the provided command anyway. Again, I'm not sure what causes the Fatal Error to be thrown because of the missing class, but I think a fix for the migration issues would be to rename the migrations as they are copied over. The problem you mention with the constantly changing migration file names, I think would be remedied by a composer dump-autoload.

Some googling didn't lead me to any concrete answers to the problem, but a couple threads on the laravel repo mention making the migrations configurable through your config file. This thread laravel/framework#3265 for example discusses table name conflicts in packages. The suggestion is to make the table names configurable. Maybe it is possible to hook in here as well.

If I come up with something I'll make a PR.

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

2 participants