示例#1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $module = $this->argument('module');
     $moduleName = studly_case($module);
     if (isset($module)) {
         if (!$this->module->exists($module)) {
             return $this->error("Module [{$moduleName}] does not exist.");
         }
         if ($this->module->isEnabled($module)) {
             $this->seed($module);
         } elseif ($this->option('force')) {
             $this->seed($module);
         }
         return;
     } else {
         if ($this->option('force')) {
             $modules = $this->module->all();
         } else {
             $modules = $this->module->enabled();
         }
         foreach ($modules as $module) {
             $this->seed($module['slug']);
         }
     }
 }
示例#2
0
 /**
  * Get all modules.
  *
  * @return array
  */
 protected function getModules()
 {
     $modules = $this->module->all();
     $results = [];
     foreach ($modules as $module) {
         $results[] = $this->getModuleInformation($module);
     }
     return array_filter($results);
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     if (!$this->confirmToProceed()) {
         return null;
     }
     $module = $this->argument('module');
     if ($module) {
         return $this->rollback($module);
     } else {
         foreach ($this->module->all() as $module) {
             $this->rollback($module['slug']);
         }
     }
 }
 /**
  * Run migrations for the specified module.
  *
  * @param string $slug
  *
  * @return mixed
  */
 protected function migrate($slug = null)
 {
     $pretend = Arr::get($this->option(), 'pretend', false);
     if (!is_null($slug) && $this->module->exists($slug)) {
         $path = $this->getMigrationPath($slug);
         if (floatval(App::version()) > 5.1) {
             $pretend = ['pretend' => $pretend];
         }
         $this->migrator->run($path, $pretend);
         // 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) {
             if (!$this->option('quiet')) {
                 $this->line($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->option('seed')) {
             $this->call('module:seed', ['module' => $slug, '--force' => true]);
         }
     } else {
         $modules = $this->module->all();
         if (count($modules) == 0) {
             return $this->error("Your application doesn't have any modules.");
         }
         $migrationsAll = [];
         foreach ($modules as $module) {
             $path = $this->getMigrationPath($module['slug']);
             $files = $this->migrator->getMigrationFiles($path);
             $ran = $this->migrator->getRepository()->getRan();
             $migrations = array_diff($files, $ran);
             $this->migrator->requireFiles($path, $migrations);
             $migrationsAll = array_merge($migrationsAll, $migrations);
         }
         if (floatval(App::version()) > 5.1) {
             $pretend = ['pretend' => $pretend];
         }
         sort($migrationsAll);
         $this->migrator->runMigrationList($migrationsAll, $pretend);
         // 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) {
             if (!$this->option('quiet')) {
                 $this->line($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->option('seed')) {
             foreach ($modules as $module) {
                 $this->call('module:seed', ['module' => $module['slug'], '--force' => true]);
             }
         }
     }
 }
 /**
  * Get all of the migration paths.
  *
  * @return array
  */
 protected function getMigrationPaths()
 {
     $slug = $this->argument('slug');
     $paths = [];
     if ($slug) {
         $paths[] = module_path($slug, 'Database/Migrations');
     } else {
         foreach ($this->module->all() as $module) {
             $paths[] = module_path($module['slug'], 'Database/Migrations');
         }
     }
     return $paths;
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     if (!$this->confirmToProceed()) {
         return null;
     }
     $slug = $this->argument('slug');
     if (!empty($slug)) {
         if ($this->module->isEnabled($slug)) {
             return $this->reset($slug);
         } elseif ($this->option('force')) {
             return $this->reset($slug);
         }
     } else {
         if ($this->option('force')) {
             $modules = $this->module->all()->reverse();
         } else {
             $modules = $this->module->enabled()->reverse();
         }
         foreach ($modules as $module) {
             $this->reset($module['slug']);
         }
     }
 }
示例#7
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $this->prepareDatabase();
     if (!empty($this->argument('slug'))) {
         $module = $this->module->getProperties($this->argument('slug'));
         if ($this->module->isEnabled($module['slug'])) {
             return $this->migrate($module['slug']);
         } elseif ($this->option('force')) {
             return $this->migrate($module['slug']);
         } else {
             return $this->error('Nothing to migrate.');
         }
     } else {
         if ($this->option('force')) {
             $modules = $this->module->all();
         } else {
             $modules = $this->module->enabled();
         }
         foreach ($modules as $module) {
             $this->migrate($module['slug']);
         }
     }
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     if (!$this->confirmToProceed()) {
         return null;
     }
     $this->prepareDatabase();
     $module = $this->module->getProperties($this->argument('module'));
     if (!is_null($module)) {
         if ($this->module->isEnabled($module['slug'])) {
             return $this->migrate($module['slug']);
         } elseif ($this->option('force')) {
             return $this->migrate($module['slug']);
         }
     } else {
         if ($this->option('force')) {
             $modules = $this->module->all();
         } else {
             $modules = $this->module->enabled();
         }
         foreach ($modules as $module) {
             $this->migrate($module['slug']);
         }
     }
 }
示例#9
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $slug = $this->argument('slug');
     if (isset($slug)) {
         if (!$this->module->exists($slug)) {
             return $this->error('Module does not exist.');
         }
         if ($this->module->isEnabled($slug)) {
             $this->seed($slug);
         } elseif ($this->option('force')) {
             $this->seed($slug);
         }
         return;
     } else {
         if ($this->option('force')) {
             $modules = $this->module->all();
         } else {
             $modules = $this->module->enabled();
         }
         foreach ($modules as $module) {
             $this->seed($module['slug']);
         }
     }
 }