mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-24 22:34:24 +02:00
Rename MigrationHook
-> DbMigrationHook
This commit is contained in:
parent
ce89d4a7cb
commit
26cae8b882
@ -3,7 +3,7 @@
|
||||
|
||||
namespace Icinga\Controllers;
|
||||
|
||||
use Icinga\Application\Hook\MigrationHook;
|
||||
use Icinga\Application\Hook\DbMigrationHook;
|
||||
use Icinga\Application\MigrationManager;
|
||||
use Icinga\Exception\IcingaException;
|
||||
use Zend_Controller_Plugin_ErrorHandler;
|
||||
@ -103,7 +103,7 @@ class ErrorController extends ActionController
|
||||
// safely unset this.
|
||||
$this->setParam('error_handler', null);
|
||||
$this->forward('hint', 'migrations', 'default', [
|
||||
MigrationHook::MIGRATION_PARAM => $moduleName
|
||||
DbMigrationHook::MIGRATION_PARAM => $moduleName
|
||||
]);
|
||||
|
||||
return;
|
||||
|
@ -5,7 +5,7 @@
|
||||
namespace Icinga\Controllers;
|
||||
|
||||
use Exception;
|
||||
use Icinga\Application\Hook\MigrationHook;
|
||||
use Icinga\Application\Hook\DbMigrationHook;
|
||||
use Icinga\Application\Icinga;
|
||||
use Icinga\Application\MigrationManager;
|
||||
use Icinga\Common\Database;
|
||||
@ -57,10 +57,10 @@ class MigrationsController extends CompatController
|
||||
$migrateListForm->setRenderDatabaseUserChange(! $mm->validateDatabasePrivileges());
|
||||
|
||||
$migrateGlobalForm = new MigrationForm();
|
||||
$migrateGlobalForm->getAttributes()->set('name', sprintf('migrate-%s', MigrationHook::ALL_MIGRATIONS));
|
||||
$migrateGlobalForm->getAttributes()->set('name', sprintf('migrate-%s', DbMigrationHook::ALL_MIGRATIONS));
|
||||
|
||||
if ($canApply && $mm->hasPendingMigrations()) {
|
||||
$migrateGlobalForm->addElement('submit', sprintf('migrate-%s', MigrationHook::ALL_MIGRATIONS), [
|
||||
$migrateGlobalForm->addElement('submit', sprintf('migrate-%s', DbMigrationHook::ALL_MIGRATIONS), [
|
||||
'required' => true,
|
||||
'label' => $this->translate('Migrate All'),
|
||||
'title' => $this->translate('Migrate all pending migrations')
|
||||
@ -103,9 +103,9 @@ class MigrationsController extends CompatController
|
||||
// The forwarded request doesn't modify the original server query string, but adds the migration param to the
|
||||
// request param instead. So, there is no way to access the migration param other than via the request instance.
|
||||
/** @var ?string $module */
|
||||
$module = $this->getRequest()->getParam(MigrationHook::MIGRATION_PARAM);
|
||||
$module = $this->getRequest()->getParam(DbMigrationHook::MIGRATION_PARAM);
|
||||
if ($module === null) {
|
||||
throw new MissingParameterException(t('Required parameter \'%s\' missing'), MigrationHook::MIGRATION_PARAM);
|
||||
throw new MissingParameterException(t('Required parameter \'%s\' missing'), DbMigrationHook::MIGRATION_PARAM);
|
||||
}
|
||||
|
||||
$mm = MigrationManager::instance();
|
||||
@ -134,7 +134,7 @@ class MigrationsController extends CompatController
|
||||
public function migrationAction(): void
|
||||
{
|
||||
/** @var string $name */
|
||||
$name = $this->params->getRequired(MigrationHook::MIGRATION_PARAM);
|
||||
$name = $this->params->getRequired(DbMigrationHook::MIGRATION_PARAM);
|
||||
|
||||
$this->addTitleTab($this->translate('Migration'));
|
||||
$this->getTabs()->disableLegacyExtensions();
|
||||
@ -215,7 +215,7 @@ class MigrationsController extends CompatController
|
||||
if ($pressedButton) {
|
||||
$name = substr($pressedButton->getName(), 8);
|
||||
switch ($name) {
|
||||
case MigrationHook::ALL_MIGRATIONS:
|
||||
case DbMigrationHook::ALL_MIGRATIONS:
|
||||
if ($mm->applyAll($elevatedPrivileges)) {
|
||||
Notification::success($this->translate('Applied all migrations successfully'));
|
||||
} else {
|
||||
|
@ -740,7 +740,7 @@ abstract class ApplicationBootstrap
|
||||
*/
|
||||
protected function registerApplicationHooks(): self
|
||||
{
|
||||
Hook::register('migration', DbMigration::class, DbMigration::class);
|
||||
Hook::register('DbMigration', DbMigration::class, DbMigration::class);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ use stdClass;
|
||||
*
|
||||
* `{IcingaApp,Module}::baseDir()/schema/{mysql,pgsql}-upgrades`
|
||||
*/
|
||||
abstract class MigrationHook implements Countable
|
||||
abstract class DbMigrationHook implements Countable
|
||||
{
|
||||
use Translation;
|
||||
|
@ -6,7 +6,7 @@ namespace Icinga\Application;
|
||||
|
||||
use Countable;
|
||||
use Generator;
|
||||
use Icinga\Application\Hook\MigrationHook;
|
||||
use Icinga\Application\Hook\DbMigrationHook;
|
||||
use Icinga\Exception\NotFoundError;
|
||||
use Icinga\Module\Setup\Utils\DbTool;
|
||||
use Icinga\Module\Setup\WebWizard;
|
||||
@ -21,7 +21,7 @@ final class MigrationManager implements Countable
|
||||
{
|
||||
use Translation;
|
||||
|
||||
/** @var array<string, MigrationHook> All pending migration hooks */
|
||||
/** @var array<string, DbMigrationHook> All pending migration hooks */
|
||||
protected $pendingMigrations;
|
||||
|
||||
/** @var MigrationManager */
|
||||
@ -48,7 +48,7 @@ final class MigrationManager implements Countable
|
||||
/**
|
||||
* Get all pending migrations
|
||||
*
|
||||
* @return array<string, MigrationHook>
|
||||
* @return array<string, DbMigrationHook>
|
||||
*/
|
||||
public function getPendingMigrations(): array
|
||||
{
|
||||
@ -83,11 +83,11 @@ final class MigrationManager implements Countable
|
||||
*
|
||||
* @param string $module
|
||||
*
|
||||
* @return MigrationHook
|
||||
* @return DbMigrationHook
|
||||
*
|
||||
* @throws NotFoundError When there are no pending migrations matching the given module name
|
||||
*/
|
||||
public function getMigration(string $module): MigrationHook
|
||||
public function getMigration(string $module): DbMigrationHook
|
||||
{
|
||||
if (! $this->hasMigrations($module)) {
|
||||
throw new NotFoundError('There are no pending migrations matching the given name: %s', $module);
|
||||
@ -116,7 +116,7 @@ final class MigrationManager implements Countable
|
||||
public function applyByName(string $module): bool
|
||||
{
|
||||
$migration = $this->getMigration($module);
|
||||
if ($migration->isModule() && $this->hasMigrations(MigrationHook::DEFAULT_MODULE)) {
|
||||
if ($migration->isModule() && $this->hasMigrations(DbMigrationHook::DEFAULT_MODULE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -126,14 +126,14 @@ final class MigrationManager implements Countable
|
||||
/**
|
||||
* Apply the given migration hook
|
||||
*
|
||||
* @param MigrationHook $hook
|
||||
* @param DbMigrationHook $hook
|
||||
* @param ?array<string, string> $elevateConfig
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function apply(MigrationHook $hook, array $elevateConfig = null): bool
|
||||
public function apply(DbMigrationHook $hook, array $elevateConfig = null): bool
|
||||
{
|
||||
if ($hook->isModule() && $this->hasMigrations(MigrationHook::DEFAULT_MODULE)) {
|
||||
if ($hook->isModule() && $this->hasMigrations(DbMigrationHook::DEFAULT_MODULE)) {
|
||||
Logger::error(
|
||||
'Please apply the Icinga Web pending migration(s) first or apply all the migrations instead'
|
||||
);
|
||||
@ -166,7 +166,7 @@ final class MigrationManager implements Countable
|
||||
*/
|
||||
public function applyAll(array $elevateConfig = null): bool
|
||||
{
|
||||
$default = MigrationHook::DEFAULT_MODULE;
|
||||
$default = DbMigrationHook::DEFAULT_MODULE;
|
||||
if ($this->hasMigrations($default)) {
|
||||
$migration = $this->getMigration($default);
|
||||
if (! $this->apply($migration, $elevateConfig)) {
|
||||
@ -189,7 +189,7 @@ final class MigrationManager implements Countable
|
||||
*
|
||||
* @param bool $modules
|
||||
*
|
||||
* @return Generator<MigrationHook>
|
||||
* @return Generator<DbMigrationHook>
|
||||
*/
|
||||
public function yieldMigrations(bool $modules = false): Generator
|
||||
{
|
||||
@ -297,8 +297,8 @@ final class MigrationManager implements Countable
|
||||
{
|
||||
$this->pendingMigrations = [];
|
||||
|
||||
/** @var MigrationHook $hook */
|
||||
foreach (Hook::all('migration') as $hook) {
|
||||
/** @var DbMigrationHook $hook */
|
||||
foreach (Hook::all('DbMigration') as $hook) {
|
||||
if (empty($hook->getMigrations())) {
|
||||
continue;
|
||||
}
|
||||
@ -366,7 +366,7 @@ final class MigrationManager implements Countable
|
||||
public function toArray(): array
|
||||
{
|
||||
$framework = [];
|
||||
$serialize = function (MigrationHook $hook): array {
|
||||
$serialize = function (DbMigrationHook $hook): array {
|
||||
$serialized = [
|
||||
'name' => $hook->getName(),
|
||||
'module' => $hook->getModuleName(),
|
||||
|
@ -4,13 +4,13 @@
|
||||
|
||||
namespace Icinga\Application\ProvidedHook;
|
||||
|
||||
use Icinga\Application\Hook\MigrationHook;
|
||||
use Icinga\Application\Hook\DbMigrationHook;
|
||||
use Icinga\Common\Database;
|
||||
use Icinga\Model\Schema;
|
||||
use ipl\Orm\Query;
|
||||
use ipl\Sql\Connection;
|
||||
|
||||
class DbMigration extends MigrationHook
|
||||
class DbMigration extends DbMigrationHook
|
||||
{
|
||||
use Database {
|
||||
getDb as public getPublicDb;
|
||||
|
@ -6,7 +6,7 @@ namespace Icinga\Web\Widget\ItemList;
|
||||
|
||||
use Generator;
|
||||
use Icinga\Application\Hook\Common\DbMigrationStep;
|
||||
use Icinga\Application\Hook\MigrationHook;
|
||||
use Icinga\Application\Hook\DbMigrationHook;
|
||||
use Icinga\Application\MigrationManager;
|
||||
use Icinga\Forms\MigrationForm;
|
||||
use ipl\I18n\Translation;
|
||||
@ -19,7 +19,7 @@ class MigrationList extends BaseItemList
|
||||
|
||||
protected $baseAttributes = ['class' => 'item-list'];
|
||||
|
||||
/** @var Generator<MigrationHook> */
|
||||
/** @var Generator<DbMigrationHook> */
|
||||
protected $data;
|
||||
|
||||
/** @var ?MigrationForm */
|
||||
@ -31,7 +31,7 @@ class MigrationList extends BaseItemList
|
||||
/**
|
||||
* Create a new migration list
|
||||
*
|
||||
* @param Generator<MigrationHook>|array<DbMigrationStep|MigrationHook> $data
|
||||
* @param Generator<DbMigrationHook>|array<DbMigrationStep|DbMigrationHook> $data
|
||||
*
|
||||
* @param ?MigrationForm $form
|
||||
*/
|
||||
@ -82,7 +82,7 @@ class MigrationList extends BaseItemList
|
||||
$this->getAttributes()->add('class', 'file-list');
|
||||
}
|
||||
|
||||
/** @var MigrationHook $data */
|
||||
/** @var DbMigrationHook $data */
|
||||
foreach ($this->data as $data) {
|
||||
/** @var MigrationFileListItem|MigrationListItem $item */
|
||||
$item = new $itemClass($data, $this);
|
||||
@ -105,7 +105,7 @@ class MigrationList extends BaseItemList
|
||||
);
|
||||
|
||||
$mm = MigrationManager::instance();
|
||||
if ($data->isModule() && $mm->hasMigrations(MigrationHook::DEFAULT_MODULE)) {
|
||||
if ($data->isModule() && $mm->hasMigrations(DbMigrationHook::DEFAULT_MODULE)) {
|
||||
$migrateButton->getAttributes()
|
||||
->set('disabled', true)
|
||||
->set(
|
||||
|
@ -5,7 +5,7 @@
|
||||
namespace Icinga\Web\Widget\ItemList;
|
||||
|
||||
use Icinga\Application\Hook\Common\DbMigrationStep;
|
||||
use Icinga\Application\Hook\MigrationHook;
|
||||
use Icinga\Application\Hook\DbMigrationHook;
|
||||
use ipl\Html\Attributes;
|
||||
use ipl\Html\BaseHtmlElement;
|
||||
use ipl\Html\Contract\FormElement;
|
||||
@ -29,7 +29,7 @@ class MigrationListItem extends BaseListItem
|
||||
/** @var ?FormElement */
|
||||
protected $migrateButton;
|
||||
|
||||
/** @var MigrationHook Just for type hint */
|
||||
/** @var DbMigrationHook Just for type hint */
|
||||
protected $item;
|
||||
|
||||
/**
|
||||
@ -124,7 +124,7 @@ class MigrationListItem extends BaseListItem
|
||||
sprintf($this->translate('Show all %d migrations'), $this->item->count()),
|
||||
Url::fromPath(
|
||||
'migrations/migration',
|
||||
[MigrationHook::MIGRATION_PARAM => $this->item->getModuleName()]
|
||||
[DbMigrationHook::MIGRATION_PARAM => $this->item->getModuleName()]
|
||||
),
|
||||
[
|
||||
'data-base-target' => '_next',
|
||||
|
Loading…
x
Reference in New Issue
Block a user