Skip to content
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

fix migration update #375

Merged
merged 2 commits into from
Feb 28, 2024
Merged

fix migration update #375

merged 2 commits into from
Feb 28, 2024

Conversation

Rom1-B
Copy link
Contributor

@Rom1-B Rom1-B commented Feb 28, 2024

ref !31826

Fix error message during plugin update (since #372) :

SQL Error "1062": Duplicate entry '0-PluginOrderOrder-1' for key 'unicity' in query "UPDATE `glpi_displaypreferences` SET `itemtype` = 'PluginOrderOrder' WHERE `itemtype` = '3150'"
In DBmysql.php line 1535:
update itemtype of table glpi_displaypreferences for PluginOrderOrder - Erreur durant l'éxecution de la requête : UPDATE `glpi_displaypreferences` SET `itemtype` = 'PluginOrderOrder' WHERE `itemtype` = '3150' - L'erreur est Duplicate entry '0-PluginOrderOrder-1' for key 'unicity'

Copy link
Contributor

@AdrienClairembault AdrienClairembault left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes looks good to me (checking the table seems necessary) but I don't see how it would fix the specific error you mentioned.

If $table doesn't exist, shouldn't we get the Unable to rename table %1$s (%2$s) to %3$s (%4$s)! error instead (which is not the same error that in your description). ?

image

@stonebuzz
Copy link
Contributor

@AdrienClairembault

below, there is displayPref migration if $domigration_itemtypes = true

 
           //Only migrate itemtypes when it's only necessary, otherwise it breaks upgrade procedure !
            if ($domigration_itemtypes) {
                Plugin::migrateItemType(
                    [3150 => 'PluginOrderOrder'],
                    ["glpi_savedsearches", "glpi_savedsearches_users",
                        "glpi_displaypreferences", "glpi_documents_items",
                        "glpi_infocoms", "glpi_logs", "glpi_tickets"
                    ],
                    []
                );
            }

without the check $DB->tableExists('glpi_plugin_order') the migration of displayPref is constantly executed

@Rom1-B
Copy link
Contributor Author

Rom1-B commented Feb 28, 2024

When the update renames the table, this block is executed (it was never executed before the previous PR mentioned).

image

As there is a uniqueness key on users_id, itemtype and num, it raises the error when trying to replace '3150' with 'PluginOrderOrder', as the key with PluginOrderOrder already exists.

@Rom1-B Rom1-B merged commit c391303 into pluginsGLPI:main Feb 28, 2024
3 checks passed
@Rom1-B Rom1-B deleted the support_31826 branch February 28, 2024 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants