Ejemplo n.º 1
0
 /**
  * Generate a report of the status of migrations.
  *
  * @return StatusReport
  */
 public function generateReport()
 {
     $migrations = $this->batch->getExpanded();
     $ran = [];
     if ($this->repository->repositoryExists()) {
         $ran = $this->repository->getRan();
     }
     return new StatusReport($migrations, $ran);
 }
 /**
  * Generate Migrations
  *
  * @param  string $method Create Tables or Foreign Keys ['create', 'foreign_keys']
  * @param  array  $tables List of tables to create migrations for
  * @throws MethodNotFoundException
  * @return void
  */
 protected function generate($method, $tables)
 {
     if ($method == 'create') {
         $function = 'getFields';
         $prefix = 'create';
     } elseif ($method = 'foreign_keys') {
         $function = 'getForeignKeyConstraints';
         $prefix = 'add_foreign_keys_to';
         $method = 'table';
     } else {
         throw new MethodNotFoundException($method);
     }
     foreach ($tables as $table) {
         $this->migrationName = $prefix . '_' . $table . '_table';
         $this->method = $method;
         $this->table = $table;
         $this->fields = $this->schemaGenerator->{$function}($table);
         if ($this->fields) {
             parent::fire();
             if ($this->log) {
                 $file = $this->datePrefix . '_' . $this->migrationName;
                 $this->repository->log($file, $this->batch);
             }
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * Creates a new database schema.
  * 
  * @param  string $schemaName
  * @return bool
  */
 public function createSchema($schemaName)
 {
     $schema = $this->schemaDriver->createSchema($schemaName);
     $this->repository->setSource($schemaName);
     $this->repository->createRepository();
     return $schema;
 }
Ejemplo n.º 4
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $this->repository->setSource($this->input->getOption('database'));
     $this->repository->createRepository();
     $this->info("Migration table created successfully.");
 }
Ejemplo n.º 5
0
 /**
  * Determine if the migration repository exists.
  *
  * @return bool
  */
 public function repositoryExists()
 {
     return $this->repository->repositoryExists();
 }
 public function testMigratorOnlyExecutesCustomMigration()
 {
     $this->migrator->setMigrationType('custom');
     $this->migrationRepository->expects($this->once())->method('getNextBatchNumber')->willReturn(1);
     $default = $this->getMockBuilder('\\DefaultTestMigration')->setMethods(array('up'))->getMock();
     $default->expects($this->never())->method('up');
     $custom = $this->getMockBuilder('\\CustomTestMigration')->setMethods(array('up'))->getMock();
     $custom->expects($this->once())->method('up');
     $this->setMigrationResolves(array(array('2015_03_05_012633_default_test_migration', $default), array('2015_03_05_012634_custom_test_migration', $custom)));
     $this->migrator->runMigrationList($this->migrationList);
 }