-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Rename getStubPath to stubPath * Require illuminate/console * Consistency with Laravel stubs * Get migrations * Consistency with Laravel commands * Use random_bytes instead of uniqid * Update dates comparision order in test
- Loading branch information
Showing
14 changed files
with
318 additions
and
258 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,110 +1,83 @@ | ||
<?php namespace Vinelab\NeoEloquent\Console\Migrations; | ||
<?php | ||
|
||
|
||
namespace Vinelab\NeoEloquent\Console\Migrations; | ||
|
||
use Illuminate\Console\ConfirmableTrait; | ||
use Illuminate\Database\Migrations\Migrator; | ||
use Symfony\Component\Console\Input\InputOption; | ||
|
||
class MigrateCommand extends BaseCommand { | ||
|
||
class MigrateCommand extends BaseCommand | ||
{ | ||
use ConfirmableTrait; | ||
|
||
/** | ||
* {@inheritDoc} | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $name = 'neo4j:migrate'; | ||
protected $signature = 'neo4j:migrate {--database= : The database connection to use.} | ||
{--force : Force the operation to run when in production.} | ||
{--path= : The path of migrations files to be executed.} | ||
{--pretend : Dump the SQL queries that would be run.} | ||
{--seed : Indicates if the seed task should be re-run.} | ||
{--step : Force the migrations to be run so they can be rolled back individually.}'; | ||
|
||
/** | ||
* {@inheritDoc} | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Run the database migrations'; | ||
|
||
/** | ||
* The migrator instance. | ||
* | ||
* @var \Vinelab\NeoEloquent\Migrations\Migrator | ||
* @var \Illuminate\Database\Migrations\Migrator | ||
*/ | ||
protected $migrator; | ||
|
||
/** | ||
* The path to the packages directory (vendor). | ||
*/ | ||
protected $packagePath; | ||
|
||
/** | ||
* @param \Vinelab\NeoEloquent\Migrations\Migrator $migrator | ||
* @param string $packagePath | ||
* @param \Illuminate\Database\Migrations\Migrator $migrator | ||
* @return void | ||
*/ | ||
public function __construct(Migrator $migrator, $packagePath) | ||
public function __construct(Migrator $migrator) | ||
{ | ||
parent::__construct(); | ||
|
||
$this->migrator = $migrator; | ||
$this->packagePath = $packagePath; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
* Execute the console command. | ||
* | ||
* @return void | ||
*/ | ||
public function fire() | ||
public function handle() | ||
{ | ||
if ( ! $this->confirmToProceed()) | ||
{ | ||
if (! $this->confirmToProceed()) { | ||
return; | ||
} | ||
|
||
// The pretend option can be used for "simulating" the migration and grabbing | ||
// the SQL queries that would fire if the migration were to be run against | ||
// a database for real, which is helpful for double checking migrations. | ||
$pretend = $this->input->getOption('pretend'); | ||
$this->migrator->setConnection($this->option('database')); | ||
|
||
$path = $this->getMigrationPath(); | ||
|
||
$this->migrator->setConnection($this->input->getOption('database')); | ||
$this->migrator->run($path, [ | ||
'pretend' => $pretend, | ||
'step' => $this->input->getOption('step'), | ||
// 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) | ||
{ | ||
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->input->getOption('seed')) | ||
{ | ||
if ($this->option('seed')) { | ||
$this->call('db:seed', ['--force' => true]); | ||
} | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
protected function getOptions() | ||
{ | ||
return array( | ||
array('bench', null, InputOption::VALUE_OPTIONAL, 'The name of the workbench to migrate.', null), | ||
|
||
array('database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'), | ||
|
||
array('force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'), | ||
|
||
array('path', null, InputOption::VALUE_OPTIONAL, 'The path to migration files.', null), | ||
|
||
array('package', null, InputOption::VALUE_OPTIONAL, 'The package to migrate.', null), | ||
|
||
array('pretend', null, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run.'), | ||
|
||
array('seed', null, InputOption::VALUE_NONE, 'Indicates if the seed task should be re-run.'), | ||
|
||
array('step', null, InputOption::VALUE_NONE, 'Force the migrations to be run so they can be rolled back individually.'), | ||
); | ||
} | ||
|
||
} |
Oops, something went wrong.