/** * Execute the console command. * * @return mixed */ public function fire() { if ($this->input->getOption('fallback')) { parent::fire(); return; } $name = $this->validateMigrationName(); $files = $this->readMigrationFiles(); $name = $this->setUniqueMigrationName($name, $files); // start: Original Laravel code $table = $this->input->getOption('table'); $create = $this->input->getOption('create'); if (!$table && is_string($create)) { $table = $create; } // Now we are ready to write the migration out to disk. Once we've written // the migration out, we will dump-autoload for the entire framework to // make sure that the migrations are registered by the class loaders. $this->writeMigration($name, $table, $create); $this->composer->dumpAutoloads(); // end: Original Laravel code }
/** * Execute the console command. */ public function fire() { $this->dispatch(new ConfigureCreator($this, $this->input, $this->creator)); $this->creator->setInput($this->input); parent::fire(); }
/** * Create a new migration install command instance. * * @param brunojk\LaravelRethinkdb\Migrations\MigrationCreator $creator * @param \Illuminate\Support\Composer $composer * * @return void */ public function __construct(MigrationCreator $creator, Composer $composer) { parent::__construct($creator, $composer); }
protected function registerDefaultContainerItems() { $this->container['migration-table'] = 'migrations'; $this->container['migrations-path'] = null; $this->container['environment'] = function ($c) { global $argv; $environment = 'production'; if (!empty($argv[2]) && preg_match('/--database=(.*?)$/si', $argv[2], $matches)) { $environment = $matches[1]; unset($argv[2]); } return $environment; }; $this->container['db-config'] = function ($c) { require_once $c['config-path'] . $c['environment'] . '.php'; return ['driver' => 'mysql', 'host' => $db['host'], 'database' => $db['database'], 'username' => $db['username'], 'password' => $db['password'], 'charset' => 'utf8', 'prefix' => '', 'collation' => 'utf8_general_ci', 'schema' => 'public']; }; $this->container['filesystem'] = function ($c) { return new \Illuminate\Filesystem\Filesystem(); }; $this->container['composer'] = function ($c) { $composer = new \Illuminate\Support\Composer($c['filesystem']); return $composer; }; $this->container['builder'] = function ($c) { $builder = new \Illuminate\Database\Schema\Builder($c['connection']); return $builder; }; $this->container['connection'] = function ($c) { $manager = new \Illuminate\Database\Capsule\Manager(); $manager->addConnection($c['db-config']); $manager->setAsGlobal(); $manager->bootEloquent(); return $manager->getConnection('default'); }; $this->container['resolver'] = function ($c) { $r = new \Illuminate\Database\ConnectionResolver([$c['environment'] => $c['connection']]); $r->setDefaultConnection($c['environment']); return $r; }; $this->container['migration-repo'] = function ($c) { return new \Illuminate\Database\Migrations\DatabaseMigrationRepository($c['resolver'], $c['migration-table']); }; $this->container['migration-creator'] = function ($c) { return new \Illuminate\Database\Migrations\MigrationCreator($c['filesystem']); }; $this->container['migrator'] = function ($c) { return new \Illuminate\Database\Migrations\Migrator($c['migration-repo'], $c['resolver'], $c['filesystem']); }; $this->container['install-command'] = function ($c) { $command = new Migrations\InstallCommand($c['migration-repo']); $command->setLaravel(new FakeLaravel($command, $c['migrations-path'])); return $command; }; $this->container['migrate-make-command'] = function ($c) { $command = new Migrations\MigrateMakeCommand($c['migration-creator'], $c['composer']); $command->setLaravel(new FakeLaravel($command, $c['migrations-path'])); return $command; }; $this->container['migrate-command'] = function ($c) { $command = new Migrations\MigrateCommand($c['migrator']); $command->setLaravel(new FakeLaravel($command, $c['migrations-path'])); return $command; }; }
/** * Get the console command arguments. * * @return array */ protected function getArguments() { return array_merge(parent::getArguments(), [['name', InputArgument::REQUIRED, 'The name of the migration.'], ['module', InputArgument::OPTIONAL, 'The name of module will be used.']]); }