/** * Runs the migration. * * @param string $migration_file Migration file. * @param MigrationContext $context Migration context. * * @return void * @throws \LogicException When an empty migration is discovered. */ public function run($migration_file, MigrationContext $context) { $sqls = file_get_contents($migration_file); $sqls = array_filter(preg_split('/;\\s+/', $sqls)); if (!$sqls) { throw new \LogicException('The "' . basename($migration_file) . '" migration contains no SQL statements.'); } $db = $context->getDatabase(); foreach ($sqls as $sql) { $db->perform($sql); } }
/** * Deletes migrations. * * @param array $migrations Migrations. * * @return void */ protected function deleteMigrations(array $migrations) { if (!$migrations) { return; } $sql = 'DELETE FROM Migrations WHERE Name IN (:names)'; $this->_context->getDatabase()->perform($sql, array('names' => $migrations)); }