当前位置: 首页>>代码示例>>PHP>>正文


PHP Migrator::getMigrationFiles方法代码示例

本文整理汇总了PHP中Illuminate\Database\Migrations\Migrator::getMigrationFiles方法的典型用法代码示例。如果您正苦于以下问题:PHP Migrator::getMigrationFiles方法的具体用法?PHP Migrator::getMigrationFiles怎么用?PHP Migrator::getMigrationFiles使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Database\Migrations\Migrator的用法示例。


在下文中一共展示了Migrator::getMigrationFiles方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: migrate

 /**
  * 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]);
             }
         }
     }
 }
开发者ID:samoilenkoevgeniy,项目名称:modules,代码行数:67,代码来源:ModuleMigrateCommand.php

示例2: reset

 /**
  * Run the migration reset for the specified module.
  *
  * @param  string $slug
  * @return mixed
  */
 protected function reset($slug)
 {
     $this->migrator->setconnection($this->input->getOption('database'));
     $pretend = $this->input->getOption('pretend');
     $migrationPath = $this->getMigrationPath($slug);
     $migrations = $this->migrator->getMigrationFiles($migrationPath);
     if (count($migrations) == 0) {
         return $this->error('Nothing to rollback.');
     }
     // We need to reverse these migrations so that they are "downed" in reverse
     // to what they run on "up". It lets us backtrack through the migrations
     // and properly reverse the entire database schema operation that originally
     // ran.
     foreach ($migrations as $migration) {
         $this->info('Migration: ' . $migration);
         $this->runDown($slug, $migration, $pretend);
     }
 }
开发者ID:cloud5ideas,项目名称:appkit,代码行数:24,代码来源:MigrateResetModuleCommand.php

示例3: fire

 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     if ($this->manager->getMigrationBehavior() == 'only') {
         foreach ($this->manager->getTenantMigrations() as $migrationName) {
             $this->info($migrationName);
         }
     } else {
         // This bit of code will get all of the migrations from the file system and load them into
         // an array. After the migration files are in the array, we will get the actual class name
         // from the migration file.
         $path = $this->getMigrationPath();
         $files = $this->migrator->getMigrationFiles($path);
         $migrations = array();
         foreach ($files as $file) {
             $migrations[] = $this->tenantMigrationResolver->resolveMigrationName($file);
         }
         $migrations = array_diff($migrations, $this->manager->getTenantMigrations());
         foreach ($migrations as $migrationName) {
             $this->info($migrationName);
         }
     }
 }
开发者ID:stillat,项目名称:database,代码行数:27,代码来源:MigrationsCommand.php

示例4: reset

 /**
  * Run the migration reset for the specified module.
  *
  * Migrations should be reset in the reverse order that they were
  * migrated up as. This ensures the database is properly reversed
  * without conflict.
  *
  * @param  string $slug
  * @return mixed
  */
 protected function reset($slug)
 {
     $this->migrator->setconnection($this->input->getOption('database'));
     $pretend = $this->input->getOption('pretend');
     $migrationPath = $this->getMigrationPath($slug);
     $migrations = array_reverse($this->migrator->getMigrationFiles($migrationPath));
     if (count($migrations) == 0) {
         return $this->error('Nothing to rollback.');
     }
     foreach ($migrations as $migration) {
         $this->info('Migration: ' . $migration);
         $this->runDown($slug, $migration, $pretend);
     }
 }
开发者ID:mubassirhayat,项目名称:modules,代码行数:24,代码来源:ModuleMigrateResetCommand.php

示例5: reset

 /**
  * Run the migration reset for the specified module.
  *
  * Migrations should be reset in the reverse order that they were
  * migrated up as. This ensures the database is properly reversed
  * without conflict.
  *
  * @param  string  $slug
  */
 protected function reset($slug)
 {
     if ($this->getStringOption('database')) {
         $this->migrator->setconnection($this->getStringOption('database'));
     }
     $pretend = $this->getBooleanOption('pretend');
     $migrationPath = $this->getMigrationPath($slug);
     $migrations = array_reverse($this->migrator->getMigrationFiles($migrationPath));
     if (count($migrations)) {
         foreach ($migrations as $migration) {
             $this->info('Migration: ' . $migration);
             $this->runDown($slug, $migration, $pretend);
         }
     } else {
         $this->error('Nothing to rollback.');
     }
 }
开发者ID:arcanedev,项目名称:moduly,代码行数:26,代码来源:MigrateResetCommand.php

示例6: getAllMigrationFiles

 /**
  * Get all of the migration files.
  *
  * @param  string  $path
  * @return array
  */
 protected function getAllMigrationFiles($path)
 {
     return $this->migrator->getMigrationFiles($path);
 }
开发者ID:nix9,项目名称:laracasts,代码行数:10,代码来源:StatusCommand.php

示例7: getAllMigrationFiles

 /**
  * Get all of the migration files.
  *
  * @return array
  */
 protected function getAllMigrationFiles()
 {
     return $this->migrator->getMigrationFiles($this->getMigrationPath());
 }
开发者ID:sellerlabs,项目名称:illuminated,代码行数:9,代码来源:StatusCommand.php

示例8: getAllMigrationFiles

 /**
  * Get all of the migration files.
  *
  * @return array
  */
 protected function getAllMigrationFiles()
 {
     return $this->migrator->getMigrationFiles($this->laravel['path.database'] . '/migrations');
 }
开发者ID:Alivop,项目名称:framework,代码行数:9,代码来源:StatusCommand.php

示例9: addModuleToReset

 /**
  * Reset migrations on a single module
  *
  * @param ModuleContainerInterface $module
  *
  * @return $this
  */
 public function addModuleToReset(ModuleContainerInterface $module)
 {
     $path = $module->getPath(['database', 'migrations']);
     $this->migrator->requireFiles($path, $this->migrator->getMigrationFiles($path));
     return $this;
 }
开发者ID:aselushat,项目名称:module-loader,代码行数:13,代码来源:ModulesInstaller.php

示例10: resetModule

 /**
  * Reset migrations on a single module
  *
  * @param ModuleContainer $module
  * @return $this
  */
 public function resetModule(ModuleContainer $module)
 {
     $path = $module->getPath(['database', 'migrations']);
     $this->_migrator->requireFiles($path, $this->_migrator->getMigrationFiles($path));
     return $this;
 }
开发者ID:BlueCatTAT,项目名称:kodicms-laravel,代码行数:12,代码来源:ModuleInstaller.php

示例11: resetMigrations

 /**
  * Reset the migrations for the extension with an
  * optional customized path.
  *
  * @param  string  $path
  * @return void
  */
 protected function resetMigrations($path = null)
 {
     if (!isset(static::$migrator)) {
         return;
     }
     $path = $path ?: $this->getMigrationsPath();
     $files = static::$migrator->getMigrationFiles($path);
     $repository = static::$migrator->getRepository();
     // Get an array of migration names which will be
     // reset
     $migrations = array_intersect(array_reverse($repository->getRan()), $files);
     // Loop through the migrations we have to rollback
     foreach ($migrations as $migration) {
         // Let the migrator resolve the migration instance
         $instance = static::$migrator->resolve($migration);
         // And we'll call the down method on the migration
         $instance->down();
         // Now we need to manipulate what the migrator does to
         // delete a migration.
         $migrationClass = new \StdClass();
         $migrationClass->migration = $migration;
         $repository->delete($migrationClass);
     }
 }
开发者ID:sohailaammarocs,项目名称:lfc,代码行数:31,代码来源:Extension.php


注:本文中的Illuminate\Database\Migrations\Migrator::getMigrationFiles方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。