Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions install/migrations/update_11.0.3_to_11.0.5/entities.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@
// Fix glpi_entities.id column to use AUTO_INCREMENT instead of DEFAULT 0
// This is required for concurrent entity creation to work properly
// see #22625
// Add NO_AUTO_VALUE_ON_ZERO to allow operations on entities with id=0 (root entity)
$DB->doQuery("SET SESSION sql_mode = CONCAT(@@sql_mode, ',NO_AUTO_VALUE_ON_ZERO')");
// Add NO_AUTO_VALUE_ON_ZERO to allow operations on entities with id=0 (root entity).
// Use IF() to handle the case where @@sql_mode is empty, as CONCAT would produce a
// malformed string starting with a comma, causing the SET SESSION to fail silently.
$DB->doQuery("SET SESSION sql_mode = IF(@@sql_mode = '', 'NO_AUTO_VALUE_ON_ZERO', CONCAT(@@sql_mode, ',NO_AUTO_VALUE_ON_ZERO'))");
$DB->doQuery(
"ALTER TABLE `glpi_entities`
MODIFY `id` INT unsigned NOT NULL AUTO_INCREMENT"
Expand Down