Skip to content

Commit

Permalink
Merge pull request #22 from Batisska/@andrianov/in_microservice_chang…
Browse files Browse the repository at this point in the history
…ed_the_migration_path

in microservice changed the migration path
  • Loading branch information
Mulkave authored May 10, 2021
2 parents 4120430 + 147a265 commit 4a51a07
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Console/Commands/MigrationMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function handle()
$service = $this->argument('service');
$migration = $this->argument('migration');

$path = $this->relativeFromReal($this->findServicePath(Str::service($service)) . "/database/migrations");
$path = $this->findMigrationPath(Str::service($service));

$output = shell_exec('php artisan make:migration '.$migration.' --path='.$path);

Expand All @@ -53,7 +53,7 @@ protected function getArguments()
{
return [
['migration', InputArgument::REQUIRED, 'The migration\'s name.'],
['service', InputArgument::REQUIRED, 'The service in which the migration should be generated.'],
['service', InputArgument::OPTIONAL, 'The service in which the migration should be generated.'],
];
}
}
15 changes: 15 additions & 0 deletions src/Finder.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,21 @@ public function findServicePath($service)
return (!$service) ? app_path() : $this->findServicesRootPath(). DS . $service;
}

/**
* Find the path to the directory of the given service name.
* In the case of a microservice service installation this will be app path.
*
* @param string $service
*
* @return string
*/
public function findMigrationPath($service)
{
return (!$service) ?
'database/migrations' :
$this->relativeFromReal($this->findServicesRootPath(). DS . $service . "/database/migrations");
}

/**
* Find the features root path in the given service.
*
Expand Down

0 comments on commit 4a51a07

Please sign in to comment.