/**
  * Migrate the jobs database for testing.
  */
 public function migrateJobsDatabase()
 {
     $this->migrationsRepository = $this->app->make('migration.repository');
     $this->migrationsRepository->createRepository();
     $migrator = new StructuredMigrator($this->migrationsRepository, $this->app->make('db'), new JobsMigrationBatch());
     $migrator->run();
 }
 protected function init()
 {
     $firstUp = !Schema::hasTable('migrations');
     if ($firstUp) {
         $this->_repository->createRepository();
         $this->output('Migration table created successfully.');
     }
 }
 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');
 }
 /**
  * @param boolean $createIfNotExists
  * @return Migrator
  */
 protected function getMigrator($createIfNotExists = false)
 {
     if ($this->_migrator) {
         return $this->_migrator;
     }
     $capsule = app('capsule');
     $connectionResolver = $capsule->getDatabaseManager();
     $repository = new DatabaseMigrationRepository($connectionResolver, 'migrations');
     if ($createIfNotExists && !$repository->repositoryExists()) {
         $repository->createRepository();
     }
     return $this->_migrator = new Migrator($repository, $connectionResolver, new Filesystem());
 }
 /**
  * Get ran migrations.
  *
  * @return array
  */
 public function getRan($namespace = null)
 {
     if ($addon = $this->getAddon()) {
         return $this->table()->orderBy('batch', 'asc')->orderBy('migration', 'asc')->where('migration', 'LIKE', '%' . $addon->getNamespace() . '%')->pluck('migration')->all();
     }
     return parent::getRan();
 }
Beispiel #6
0
 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();
 }
Beispiel #7
0
 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!');
 }
Beispiel #8
0
 protected function createMigrator()
 {
     $app = App::getInstance();
     //The module's migration table name is : ps_modulename_migrations
     $repo = new DatabaseMigrationRepository($app['db'], $this->name . '_migrations');
     if (!$repo->repositoryExists()) {
         $repo->createRepository();
     }
     $this->migrator = new Migrator($repo, $app['db'], $app['files']);
     $this->migrationPath = _PS_MODULE_DIR_ . $this->name . '/updates';
 }