From 6e25c05d8942e2c2c8cfcea0229601d2d4f0e99e Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Sun, 7 Oct 2018 16:45:11 +0200 Subject: [PATCH] Migrations: cleanup --- library/Director/Db/Migration.php | 20 ++++++++++++-------- library/Director/Db/Migrations.php | 1 - 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/library/Director/Db/Migration.php b/library/Director/Db/Migration.php index cd78350a..56851219 100644 --- a/library/Director/Db/Migration.php +++ b/library/Director/Db/Migration.php @@ -3,8 +3,8 @@ namespace Icinga\Module\Director\Db; use Exception; -use Icinga\Exception\IcingaException; use Icinga\Module\Director\Data\Db\DbConnection; +use RuntimeException; class Migration { @@ -27,21 +27,25 @@ class Migration /** * @param DbConnection $connection * @return $this - * @throws IcingaException */ public function apply(DbConnection $connection) { /** @var \Zend_Db_Adapter_Pdo_Abstract $db */ $db = $connection->getDbAdapter(); - // TODO: this is fagile and depends on accordingly written schema files: - $queries = preg_split('/[\n\s\t]*\;[\n\s\t]+/s', $this->sql, -1, PREG_SPLIT_NO_EMPTY); + // TODO: this is fragile and depends on accordingly written schema files: + $queries = preg_split( + '/[\n\s\t]*\;[\n\s\t]+/s', + $this->sql, + -1, + PREG_SPLIT_NO_EMPTY + ); if (empty($queries)) { - throw new IcingaException( + throw new RuntimeException(sprintf( 'Migration %d has no queries', $this->version - ); + )); } try { @@ -53,12 +57,12 @@ class Migration } } } catch (Exception $e) { - throw new IcingaException( + throw new RuntimeException(sprintf( 'Migration %d failed (%s) while running %s', $this->version, $e->getMessage(), $query - ); + )); } return $this; diff --git a/library/Director/Db/Migrations.php b/library/Director/Db/Migrations.php index c8e06044..31b7eafa 100644 --- a/library/Director/Db/Migrations.php +++ b/library/Director/Db/Migrations.php @@ -86,7 +86,6 @@ class Migrations /** * @return $this - * @throws \Icinga\Exception\IcingaException */ public function applyPendingMigrations() {