InfyOmLabs / laravel-generator

API and Admin Panel CRUD Generator for Laravel.
https://www.infyom.com/open-source
MIT License
3.78k stars 802 forks source link

Changing path migration #672

Closed annettaws closed 5 years ago

annettaws commented 5 years ago

Hi, i changed the path.migration config value. The migrations file are correctly created on the specified folder but the table are not created. The command migrate don't take the value of the specified path.

file src/Commands/BaseCommand.php

public function performPostActions($runMigration = false) .... if ($runMigration) { $this->call('migrate'); ....

How can i fix? I tried to put the arguments like this:

$this->call('migrate',['--path' => base_path('database/migrations/moduoles/'), '--force' => true]);

But still not working;

annettaws commented 5 years ago

I solved with this code and by adding an other config value ( path.migrate ):

src/Commands/BaseCommand.php

public function performPostActions($runMigration = false) { if ($this->commandData->getOption('save')) { $this->saveSchemaFile(); }

    if ($runMigration) {
        $path = config('infyom.laravel_generator.path.migrate','/database/migrations/');
        if ($this->commandData->getOption('forceMigrate')) {
            $this->call('migrate',
                ['--path' => $path, '--force' => true]);
        } elseif (!$this->commandData->getOption('fromTable') and !$this->isSkip('migration')) {
            $requestFromConsole = (php_sapi_name() == 'cli') ? true : false;
            if ($this->commandData->getOption('jsonFromGUI') && $requestFromConsole) {
                $this->call('migrate',
                    ['--path' => $path, '--force' => true]);
            } elseif ($requestFromConsole && $this->confirm("\nDo you want to migrate database? [y|N]", false)) {
                $this->call('migrate',
                    ['--path' => $path, '--force' => true]);
            }
        }
    }
    if (!$this->isSkip('dump-autoload')) {
        $this->info('Generating autoload files');
        $this->composer->dumpOptimized();
    }
}