mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-28 08:14:04 +02:00
Migrations: cleanup
This commit is contained in:
parent
e16d7865c7
commit
db72931c1e
@ -25,10 +25,6 @@ class DashboardController extends ActionController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws \Icinga\Exception\ConfigurationError
|
|
||||||
* @throws \Icinga\Exception\Http\HttpNotFoundException
|
|
||||||
*/
|
|
||||||
public function indexAction()
|
public function indexAction()
|
||||||
{
|
{
|
||||||
if ($this->getRequest()->isGet()) {
|
if ($this->getRequest()->isGet()) {
|
||||||
|
@ -11,10 +11,6 @@ class IndexController extends DashboardController
|
|||||||
{
|
{
|
||||||
protected $hasDeploymentEndpoint;
|
protected $hasDeploymentEndpoint;
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws \Icinga\Exception\ConfigurationError
|
|
||||||
* @throws \Icinga\Exception\Http\HttpNotFoundException
|
|
||||||
*/
|
|
||||||
public function indexAction()
|
public function indexAction()
|
||||||
{
|
{
|
||||||
if ($this->Config()->get('db', 'resource')) {
|
if ($this->Config()->get('db', 'resource')) {
|
||||||
|
@ -24,8 +24,14 @@ class Migration
|
|||||||
$this->sql = $sql;
|
$this->sql = $sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param DbConnection $connection
|
||||||
|
* @return $this
|
||||||
|
* @throws IcingaException
|
||||||
|
*/
|
||||||
public function apply(DbConnection $connection)
|
public function apply(DbConnection $connection)
|
||||||
{
|
{
|
||||||
|
/** @var \Zend_Db_Adapter_Pdo_Abstract $db */
|
||||||
$db = $connection->getDbAdapter();
|
$db = $connection->getDbAdapter();
|
||||||
|
|
||||||
// TODO: this is fagile and depends on accordingly written schema files:
|
// TODO: this is fagile and depends on accordingly written schema files:
|
||||||
|
@ -5,6 +5,7 @@ namespace Icinga\Module\Director\Db;
|
|||||||
use DirectoryIterator;
|
use DirectoryIterator;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Icinga\Application\Icinga;
|
use Icinga\Application\Icinga;
|
||||||
|
use Icinga\Exception\ProgrammingError;
|
||||||
use Icinga\Module\Director\Data\Db\DbConnection;
|
use Icinga\Module\Director\Data\Db\DbConnection;
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
|
|
||||||
@ -67,6 +68,9 @@ class Migrations
|
|||||||
return count($this->listPendingMigrations());
|
return count($this->listPendingMigrations());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Migration[]
|
||||||
|
*/
|
||||||
public function getPendingMigrations()
|
public function getPendingMigrations()
|
||||||
{
|
{
|
||||||
$migrations = array();
|
$migrations = array();
|
||||||
@ -80,6 +84,10 @@ class Migrations
|
|||||||
return $migrations;
|
return $migrations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return $this
|
||||||
|
* @throws \Icinga\Exception\IcingaException
|
||||||
|
*/
|
||||||
public function applyPendingMigrations()
|
public function applyPendingMigrations()
|
||||||
{
|
{
|
||||||
foreach ($this->getPendingMigrations() as $migration) {
|
foreach ($this->getPendingMigrations() as $migration) {
|
||||||
@ -171,7 +179,15 @@ class Migrations
|
|||||||
|
|
||||||
protected function getSchemaDir($sub = null)
|
protected function getSchemaDir($sub = null)
|
||||||
{
|
{
|
||||||
$dir = $this->getModuleDir('/schema');
|
try {
|
||||||
|
$dir = $this->getModuleDir('/schema');
|
||||||
|
} catch (ProgrammingError $e) {
|
||||||
|
throw new RuntimeException(
|
||||||
|
'Unable to detect the schema directory for this module',
|
||||||
|
0,
|
||||||
|
$e
|
||||||
|
);
|
||||||
|
}
|
||||||
if ($sub === null) {
|
if ($sub === null) {
|
||||||
return $dir;
|
return $dir;
|
||||||
} else {
|
} else {
|
||||||
@ -179,6 +195,11 @@ class Migrations
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $sub
|
||||||
|
* @return string
|
||||||
|
* @throws ProgrammingError
|
||||||
|
*/
|
||||||
protected function getModuleDir($sub = '')
|
protected function getModuleDir($sub = '')
|
||||||
{
|
{
|
||||||
return Icinga::app()->getModuleManager()->getModuleDir(
|
return Icinga::app()->getModuleManager()->getModuleDir(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user