versione pre-stable
This commit is contained in:
+20
-27
@@ -31,14 +31,15 @@ function plugin_urbackup_install_process(): bool
|
||||
plugin_urbackup_install_create_initial_schema($migration);
|
||||
|
||||
plugin_urbackup_install_update_configs_table($migration);
|
||||
plugin_urbackup_install_update_assettypes_table($migration);
|
||||
|
||||
// Convert old assettype configurations to GLPI 11 capacity system
|
||||
plugin_urbackup_install_convert_assettypes_to_capacities($migration);
|
||||
|
||||
plugin_urbackup_install_update_servers_table($migration);
|
||||
plugin_urbackup_install_update_serverassets_table($migration);
|
||||
plugin_urbackup_install_update_profiles_table($migration);
|
||||
|
||||
// Drop tables that are no longer used (replaced by Profile::registerRights() and Capacity system)
|
||||
plugin_urbackup_install_drop_legacy_tables($migration);
|
||||
|
||||
$migration->executeMigration();
|
||||
|
||||
@@ -61,10 +62,8 @@ function plugin_urbackup_install_create_initial_schema(Migration $migration): vo
|
||||
|
||||
$required_tables = [
|
||||
'glpi_plugin_urbackup_configs',
|
||||
'glpi_plugin_urbackup_assettypes',
|
||||
'glpi_plugin_urbackup_servers',
|
||||
'glpi_plugin_urbackup_serverassets',
|
||||
'glpi_plugin_urbackup_profiles',
|
||||
];
|
||||
|
||||
$missing_table_found = false;
|
||||
@@ -264,6 +263,7 @@ function plugin_urbackup_install_update_servers_table(Migration $migration): voi
|
||||
$migration->addKey($table, 'entities_id');
|
||||
$migration->addKey($table, 'locations_id');
|
||||
$migration->addKey($table, 'is_active');
|
||||
$migration->addKey($table, ['locations_id', 'is_active'], 'location_active');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -298,46 +298,39 @@ function plugin_urbackup_install_update_serverassets_table(Migration $migration)
|
||||
'after' => 'itemtype',
|
||||
]);
|
||||
|
||||
$migration->addField($table, 'date_creation', 'timestamp');
|
||||
$migration->addField($table, 'date_mod', 'timestamp');
|
||||
|
||||
$migration->addKey($table, 'plugin_urbackup_servers_id');
|
||||
$migration->addKey($table, ['itemtype', 'items_id'], 'item');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update profiles table.
|
||||
* Drop legacy tables that are no longer used.
|
||||
*
|
||||
* @param Migration $migration Migration instance
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function plugin_urbackup_install_update_profiles_table(Migration $migration): void
|
||||
function plugin_urbackup_install_drop_legacy_tables(Migration $migration): void
|
||||
{
|
||||
global $DB;
|
||||
|
||||
// glpi_plugin_urbackup_profiles was replaced by Profile::registerRights() in 0.5.0
|
||||
$table = 'glpi_plugin_urbackup_profiles';
|
||||
|
||||
if (!$DB->tableExists($table)) {
|
||||
return;
|
||||
if ($DB->tableExists($table)) {
|
||||
$migration->displayMessage(__('Dropping legacy glpi_plugin_urbackup_profiles table', 'urbackup'));
|
||||
$DB->queryOrDie("DROP TABLE IF EXISTS `$table`");
|
||||
}
|
||||
|
||||
$migration->addField($table, 'profiles_id', 'integer', [
|
||||
'value' => 0,
|
||||
'after' => 'id',
|
||||
]);
|
||||
// glpi_plugin_urbackup_assettypes was replaced by GLPI 11 Capacity system in 0.6.0
|
||||
$table2 = 'glpi_plugin_urbackup_assettypes';
|
||||
if ($DB->tableExists($table2)) {
|
||||
$migration->displayMessage(__('Dropping legacy glpi_plugin_urbackup_assettypes table', 'urbackup'));
|
||||
$DB->queryOrDie("DROP TABLE IF EXISTS `$table2`");
|
||||
}
|
||||
|
||||
$migration->addField($table, 'rightname', 'string', [
|
||||
'value' => '',
|
||||
'after' => 'profiles_id',
|
||||
]);
|
||||
|
||||
$migration->addField($table, 'rights', 'integer', [
|
||||
'value' => 0,
|
||||
'after' => 'rightname',
|
||||
]);
|
||||
|
||||
$migration->addField($table, 'date_creation', 'timestamp');
|
||||
$migration->addField($table, 'date_mod', 'timestamp');
|
||||
|
||||
$migration->addKey($table, ['profiles_id', 'rightname'], 'profile_right');
|
||||
$migration->displayMessage(__('Legacy tables dropped successfully', 'urbackup'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user