Beispiel #1
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     try {
         parent::fire();
     } catch (PDOException $e) {
         if (!isset($e->errorInfo[1]) || $e->errorInfo[1] != 1050) {
             throw $e;
         }
         $this->info('Migration table already exists');
     }
     $this->checkMigrationDirectory();
 }
 protected function getOptions()
 {
     return array_merge(parent::getOptions(), [['tenant', null, InputOption::VALUE_OPTIONAL, 'The tenant(s) to apply migrations on; use {true|5,8}']]);
 }
 /**
  * Create a new migration install command instance.
  * Overridden to add Core reference.
  *
  * @param MigrationRepositoryInterface $repository
  * @param CoreInterface                $core
  */
 public function __construct(MigrationRepositoryInterface $repository, CoreInterface $core)
 {
     parent::__construct($repository);
     $this->core = $core;
 }
Beispiel #4
0
 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;
     };
 }