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


PHP Migrations\Migrator类代码示例

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


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

示例1: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $capsule = app('capsule');
     $connectionResolver = $capsule->getDatabaseManager();
     $repository = new DatabaseMigrationRepository($connectionResolver, 'migrations');
     if (!$repository->repositoryExists()) {
         $repository->createRepository();
     }
     $migrator = new Migrator($repository, $connectionResolver, new Filesystem());
     return $migrator->run(__DIR__ . '/../database/migrations');
 }
开发者ID:lihuibin,项目名称:notejam_blink,代码行数:11,代码来源:MigrateCommand.php

示例2: resolve

 public function resolve($file)
 {
     /* @var $class \Consolet\Migrator\Migration */
     $class = parent::resolve($file);
     $class::setSchemaOnce($this->resolveConnection(null)->getSchemaBuilder());
     return $class;
 }
开发者ID:yusukezzz,项目名称:migrator,代码行数:7,代码来源:Migrator.php

示例3: __construct

 /**
  * Returns a new TenantMigrator instance.
  * 
  * @param MigrationRepositoryInterface $repository
  * @param Resolver                     $resolver
  * @param Filesystem                   $files
  * @param TenantManager                $manager
  */
 public function __construct(MigrationRepositoryInterface $repository, Resolver $resolver, Filesystem $files, TenantManager $manager)
 {
     $this->manager = $manager;
     // There is nothing special about the TenantMigrationResolver class, so let's just new up one.
     $this->tenantMigrationResolver = new TenantMigrationResolver();
     parent::__construct($repository, $resolver, $files);
 }
开发者ID:stillat,项目名称:database,代码行数:15,代码来源:TenantMigrator.php

示例4: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     $config = (require __DIR__ . '/../config.php');
     $capsule = new Manager();
     $capsule->addConnection($config);
     $capsule->bootEloquent();
     Schema::setConnection($capsule->getConnection('default'));
     DB::setConnection($capsule->getConnection('default'));
     // run the migrations
     $migration_repo = new DatabaseMigrationRepository(Model::getConnectionResolver(), 'migrations');
     if (!$migration_repo->repositoryExists()) {
         $migration_repo->createRepository();
     }
     $migrator = new Migrator($migration_repo, Model::getConnectionResolver(), new Filesystem());
     $migrator->rollback();
     $migrator->run(__DIR__ . '/../../src/migrations');
     static::loadFixtures();
 }
开发者ID:dadleyy,项目名称:lvpress,代码行数:19,代码来源:TestCase.php

示例5: execute

 public function execute(InputInterface $input, OutputInterface $output)
 {
     $migrationsPath = APP_ROOT . 'db/migrations/';
     $c = $this->app->container();
     $migrationsTableName = 'migrations';
     $dbResolver = $c['database.manager']->getDatabaseManager();
     $filesystem = new Filesystem();
     // Get the database migrations repository (create if not existant)
     $repository = new MigrationRepo($dbResolver, $migrationsTableName);
     if (!$repository->repositoryExists()) {
         $repository->createRepository();
     }
     // Run!
     $migrator = new Migrator($repository, $dbResolver, $filesystem);
     $migrator->run($migrationsPath);
     // Show notes
     foreach ($migrator->getNotes() as $note) {
         $output->writeln(preg_replace('(<[a-zA-Z/]+>)', '', $note));
     }
     $output->writeln('');
     $output->writeln('Migrated!');
 }
开发者ID:kiasaki,项目名称:vexillum,代码行数:22,代码来源:MigrateCommand.php

示例6: fire

 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $this->migrator->setConnection($this->input->getOption('database'));
     $pretend = $this->input->getOption('pretend');
     while ($this->migrator->rollback($this->output, $pretend)) {
     }
 }
开发者ID:hochanh,项目名称:Bootsoft-Bowling,代码行数:12,代码来源:ResetCommand.php

示例7: prepareDatabase

 /**
  * Prepare the migration database for running.
  *
  * @return void
  */
 protected function prepareDatabase()
 {
     $this->migrator->setConnection($this->input->getOption('database'));
     if (!$this->migrator->repositoryExists()) {
         $options = ['--database' => $this->input->getOption('database')];
         $this->call('migrate:install', $options);
     }
 }
开发者ID:EnmanuelCode,项目名称:backend-laravel,代码行数:13,代码来源:MigrateCommand.php

示例8: fire

 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $this->migrator->setConnection($this->input->getOption('database'));
     $package = $this->input->getOption('package') ?: 'application';
     // 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');
     $path = $this->getMigrationPath();
     $this->migrator->run($this->output, $package, $path, $pretend);
 }
开发者ID:hochanh,项目名称:Bootsoft-Bowling,代码行数:16,代码来源:MigrateCommand.php

示例9: fire

 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $this->migrator->setConnection($this->input->getOption('database'));
     $pretend = $this->input->getOption('pretend');
     $this->migrator->rollback($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) {
         $this->output->writeln($note);
     }
 }
开发者ID:defra91,项目名称:levecchiecredenze.it,代码行数:17,代码来源:RollbackCommand.php

示例10: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     if (!$this->confirmToProceed()) {
         return;
     }
     $this->migrator->setConnection($this->option('database'));
     $paths = $this->getMigrationPaths();
     $this->migrator->rollback($paths, ['pretend' => $this->option('pretend'), 'step' => (int) $this->option('step')]);
     foreach ($this->migrator->getNotes() as $note) {
         $this->output->writeln($note);
     }
 }
开发者ID:caffeinated,项目名称:modules,代码行数:17,代码来源:ModuleMigrateRollbackCommand.php

示例11: fire

 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     if (!$this->confirmToProceed()) {
         return;
     }
     $this->migrator->setConnection($this->option('database'));
     $this->migrator->rollback($this->getMigrationPaths(), ['pretend' => $this->option('pretend'), 'step' => (int) $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) {
         $this->output->writeln($note);
     }
 }
开发者ID:mark86092,项目名称:laravel-framework,代码行数:19,代码来源:RollbackCommand.php

示例12: runDown

 /**
  * Run "down" a migration instance. (Overridden)
  *
  * @param  object $migration
  * @param  bool   $pretend
  * @return void
  */
 protected function runDown($migration, $pretend)
 {
     $migrations = [$migration->migration];
     // Retrieve migration path and throw exception if it doesn't exist
     $path = $this->getMigrationPath(true);
     $this->requireFiles($path, $migrations);
     parent::runDown($migration, $pretend);
 }
开发者ID:singularity321,项目名称:Arty,代码行数:15,代码来源:Migrator.php

示例13: prepareDatabase

 /**
  * Prepare the migration database for running.
  */
 private function prepareDatabase()
 {
     if ($database = $this->getStringOption('database')) {
         $this->migrator->setConnection($database);
     }
     if (!$this->migrator->repositoryExists()) {
         $this->call('migrate:install', ['--database' => $database]);
     }
 }
开发者ID:arcanedev,项目名称:moduly,代码行数:12,代码来源:MigrateCommand.php

示例14: 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

示例15: run

 public function run($path, $pretend = false)
 {
     parent::run($path, $pretend);
     $key = Config::get('database.default');
     $database = Config::get('database.connections.' . $key . '.database');
     $this->note('<info>Generating schema for: ' . $database . '</info>');
     $builder = new Builder();
     $builder->convert($database);
     $builder->write();
 }
开发者ID:kreitje,项目名称:l4-schemad-migrations,代码行数:10,代码来源:Migrator.php


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