CrestApps / laravel-code-generator

An efficient Laravel code generator, saving time by automating the creation of resources such as views, controllers, routes, migrations, languages, and form-requests. Highly flexible and customizable, it includes a cross-browser compatible template and client-side validation for application modernization.
https://laravel-code-generator.crestapps.com
MIT License
738 stars 158 forks source link

Error on migrate-all #99

Closed leaderit closed 5 years ago

leaderit commented 5 years ago

Environment:

Description:

error on migrate-all

Steps/Commands To Reproduce:

bash-3.2$ ./artisan migrate-all

Symfony\Component\Debug\Exception\FatalThrowableError : Call to undefined method Illuminate\Database\Migrations\Migrator::getNotes()

at /Users/vg/devel/web/www/lit-serts/vendor/crestapps/laravel-code-generator/src/Commands/Migrations/MigrateAllCommand.php:56 52| 53| // Once the migrator has run we will grab the note output and send it out to 54| // the console screen, since the migrator itself functions without having 55| // any instances of the OutputInterface contract passed into the class.

56| foreach ($this->migrator->getNotes() as $note) { 57| $this->output->writeln($note); 58| } 59| 60| // Finally, if the "seed" option has been given, we will re-run the database

Exception trace:

1 CrestApps\CodeGenerator\Commands\Migrations\MigrateAllCommand::handle() /Users/vg/devel/web/www/lit-serts/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29

2 call_user_func_array([]) /Users/vg/devel/web/www/lit-serts/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29

Please use the argument -v to see more details.

Content Of The Resource-File:

Corrected By:

public function handle()
{
    if (!$this->confirmToProceed()) {
        return;
    }

    $this->prepareDatabase();

$this->migrator->setOutput($this->output);
// Next, we will check to see if a path option has been defined. If it has // we will use the path relative to the root of this installation folder // so that migrations may be run for any path within the applications. $this->migrator->run($this->getMigrationPaths(), [ 'pretend' => $this->option('pretend'), 'step' => $this->option('step'), ]);

    // Once the migrator has run we will grab the note output and send it out to
    // the console screen, since the migrator itself functions without having
    // any instances of the OutputInterface contract passed into the class.

// foreach ($this->migrator->getNotes() as $note) { // $this->output->writeln($note); // }

    // Finally, if the "seed" option has been given, we will re-run the database
    // seed task to re-populate the database, which is convenient when adding
    // a migration and a seed at the same time, as it is only this command.
    if ($this->option('seed')) {
        $this->call('db:seed', ['--force' => true]);
    }
}
DariusJu commented 5 years ago

Fixed:

The core migration commands at Laravel 5.7 have been updated to set the output instance on the migrator class. If you were overriding or extending the migration commands, you should remove references to $this->migrator->getNotes() and use $this->migrator->setOutput($this->output) instead.

Changes in folder "vendor\crestapps\laravel-code-generator\src\Commands\Migrations\" MigrateAllCommand.php ResetAllCommand.php RollbackAllCommand.php

// Fixed:

//$this->migrator->run($this->getMigrationPaths(), [
$this->migrator->setOutput($this->output)->run($this->getMigrationPaths(), [

//$this->migrator->reset(
$this->migrator->setOutput($this->output)->reset(

//$this->migrator->rollback(
$this->migrator->setOutput($this->output)->rollback(
....

//comment/remove this:
// foreach ($this->migrator->getNotes() as $note) {
//     $this->output->writeln($note);
// }
MikeAlhayek commented 5 years ago

Thank you for reporting this issue! This issue has been addressed and now part of the v2.2.13 release. Please upgrade your package to fix the issue