public function __invoke() { $fileScanner = new MigrationFileScanner($this->sqlDirectory); $loadMigrations = new LoadMigrations($this->pdo); $migrationsToInstall = (new Planner($fileScanner, $loadMigrations))->findMigrationsToInstall(); $runMigration = new RunMigration($this->pdo); $logMigration = new LogMigration($this->pdo); foreach ($migrationsToInstall as $migration) { try { $runMigration->run($migration); } catch (\Exception $e) { $logMigration->logFailure($migration); throw new MigrationException("Could not Execute Migration " . $migration->getFile()->getPathname(), $e); } $logMigration->logSuccess($migration); } }
public function __invoke() { $this->migrationTablePresenceConstraint->assertTableMissing(); $this->runMigration->run(new SqlFile(new \SplFileInfo(__DIR__ . "/../sql/init.sql"))); $this->migrationTablePresenceConstraint->assertTablePresent(); }