/** * 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); }
/** * Run the outstanding migrations at a given path. * * @param string $path * @param bool $pretend * @return void */ public function run($path, $pretend = false) { $this->notes = array(); $this->requireFiles($path, $files = $this->getMigrationFiles($path)); // Once we grab all of the migration files for the path, we will compare them // against the migrations that have already been run for this package then // run all of the oustanding migrations against the database connection. $ran = $this->repository->getRan(); $migrations = array_diff($files, $ran); $this->runMigrationList($migrations, $pretend); }
/** * Run the outstanding migrations at a given path. * * @param bool $pretend * */ public function run($pretend = false) { $this->notes = []; $this->batch->validate(); $defined = $this->batch->getExpanded(); // Once we discovered all the migrations in the batch, we will compare // them against the migrations that have already been run for this // package then run each of the outstanding migrations against a // database connection. $ran = $this->repository->getRan(); $migrations = array_diff($defined, $ran); $this->runMigrationList($migrations, $pretend); }
/** * Rolls all of the currently applied migrations back. * * @param bool $pretend * @return int */ public function reset($pretend = false) { $this->notes = []; $migrations = array_reverse($this->repository->getRan()); if (count($migrations) == 0) { $this->note('<info>Nothing to rollback.</info>'); return count($migrations); } foreach ($migrations as $migration) { $this->runDown((object) ['migration' => $migration], $pretend); } return count($migrations); }
/** * Rolls all of the currently applied migrations back. * * @param bool $pretend * @return int */ public function reset($pretend = false) { if (!isset($this->migration)) { $this->note('<info>No migration name.</info>'); } $this->notes = []; $migrationList = array_reverse($this->repository->getRan()); $count = count($migrationList); if ($count === 0) { $this->note('<info>Nothing to rollback.</info>'); } elseif (!in_array($this->migration, $migrationList)) { $this->note('<info>No such migration ran ever or is already reset.</info>'); } else { $this->runDown((object) ['migration' => $this->migration], $pretend); } return $count; }
/** * Rolls all of the currently applied migrations back. * * @param array|string $paths * @param bool $pretend * @return array */ public function reset($paths = [], $pretend = false) { $this->notes = []; $rolledBack = []; $files = $this->getMigrationFiles($paths); // Next, we will reverse the migration list so we can run them back in the // correct order for resetting this database. This will allow us to get // the database back into its "empty" state ready for the migrations. $migrations = array_reverse($this->repository->getRan()); $count = count($migrations); if ($count === 0) { $this->note('<info>Nothing to rollback.</info>'); } else { $this->requireFiles($files); // Next we will run through all of the migrations and call the "down" method // which will reverse each migration in order. This will get the database // back to its original "empty" state and will be ready for migrations. foreach ($migrations as $migration) { $rolledBack[] = $files[$migration]; $this->runDown($files[$migration], (object) ['migration' => $migration], $pretend); } } return $rolledBack; }