-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add old_id and new_id col in glpi_logs table #19160
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
Co-authored-by: Romain B. <[email protected]>
$DB->tableExists(self::getTable()) | ||
&& $DB->fieldExists(self::getTable(), 'old_id') | ||
&& $DB->fieldExists(self::getTable(), 'new_id') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This condition has been added to fix the following error that appeared during the migration from 0.85.x to 0.90.0:
MySQL query error: Unknown column 'old_id' in 'INSERT INTO' (1054) in SQL query "INSERT INTO `glpi_logs` (`items_id`, `itemtype`, `itemtype_link`, `linked_action`, `user_name`, `date_mod`, `id_search_option`, `old_value`, `new_value`, `old_id`, `new_id`) VALUES ('1', 'Config', '', '0', '', '2025-03-07 15:13:08', '1', 'palette ', 'auror', NULL, NULL)".
IMHO, migrations are not supposed to log anything. The following patch would fix this error, but it is probably not the only one required.
diff --git a/install/migrations/update_0.85.x_to_0.90.0.php b/install/migrations/update_0.85.x_to_0.90.0.php
index 112c8cc6eb..55c619b3f2 100644
--- a/install/migrations/update_0.85.x_to_0.90.0.php
+++ b/install/migrations/update_0.85.x_to_0.90.0.php
@@ -74,16 +74,18 @@ function update085xto0900()
}
// Add Color selector
- Config::setConfigurationValues('core', ['palette' => 'auror']);
+ $migration->addConfig(['palette' => 'auror']);
$migration->addField("glpi_users", "palette", "char(20) DEFAULT NULL");
// add layout config
- Config::setConfigurationValues('core', ['layout' => 'lefttab']);
+ $migration->addConfig(['layout' => 'lefttab']);
$migration->addField("glpi_users", "layout", "char(20) DEFAULT NULL");
// add timeline config
- Config::setConfigurationValues('core', ['ticket_timeline' => 1]);
- Config::setConfigurationValues('core', ['ticket_timeline_keep_replaced_tabs' => 0]);
+ $migration->addConfig([
+ 'ticket_timeline' => 1,
+ 'ticket_timeline_keep_replaced_tabs' => 0,
+ ]);
$migration->addField("glpi_users", "ticket_timeline", "tinyint DEFAULT NULL");
$migration->addField("glpi_users", "ticket_timeline_keep_replaced_tabs", "tinyint DEFAULT NULL");
I am rarely comfortable with having to patch old migrations, but I do not like having these kinds of conditions either. @trasher What is your opinion about this ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hum... I do not like to change old migrations neither, but I do agree it should not log anything.
Since alternative solution seems tricky; and the migration fix is quite light; I'd be OK for this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This patch does not solve the problem :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are working on a patch that would remove usages of CommonDBTM::add()
/CommonDBTM::update()
in migrations. I would like to see if we can achieve that in order to remove this condition.
$DB->tableExists(self::getTable()) | ||
&& $DB->fieldExists(self::getTable(), 'old_id') | ||
&& $DB->fieldExists(self::getTable(), 'new_id') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are working on a patch that would remove usages of CommonDBTM::add()
/CommonDBTM::update()
in migrations. I would like to see if we can achieve that in order to remove this condition.
Checklist before requesting a review
Please delete options that are not relevant.
Description
Add two
new_id
andold_id
columns to theglpi_logs
table to optimize table searches