glpi-project / glpi

GLPI is a Free Asset and IT Management Software package, Data center management, ITIL Service Desk, licenses tracking and software auditing.
https://glpi-project.org
GNU General Public License v3.0
4.36k stars 1.3k forks source link

Database inconsistencies after migration to glpi 10.0.1 #11824

Closed jackburton79 closed 2 years ago

jackburton79 commented 2 years ago

Code of Conduct

Is there an existing issue for this?

Version

10.0.1

Bug description

After migrating to glpi 10.0.1, the system showed a message saying the database is inconsistent. I ran php bin/console glpi:database:check_schema_integrity and:

La tabella "glpi_itils_projects" differisce dallo schema.
--- Original
+++ New
@@ @@
 CREATE TABLE `glpi_itils_projects` (
   `id` int NOT NULL AUTO_INCREMENT,
-  `items_id` int NOT NULL DEFAULT 0,
+  `changes_id` int NOT NULL DEFAULT 0,
   `itemtype` varchar(100) NOT NULL DEFAULT '',
   `projects_id` int NOT NULL DEFAULT 0,
   PRIMARY KEY (`id`),
-  UNIQUE KEY `unicity` (`itemtype`,`items_id`,`projects_id`),
   KEY `projects_id` (`projects_id`)
 )

How do I fix this ?

Relevant log output

No response

Page URL

No response

Steps To reproduce

No response

Your GLPI setup information

Informazioni sul sistema, l'installazione e la configurazione
GLPI 10.0.1 ( => /usr/local/share/glpitest)
Installation mode: TARBALL
Current language:it_IT

Server
 
Operating system: Linux group 5.3.18-150300.59.68-default #1 SMP Wed May 4 11:29:09 UTC 2022 (ea30951) x86_64
PHP 7.4.6 apache2handler (Core, PDO, Phar, Reflection, SPL, SimpleXML, Zend OPcache, apache2handler, apcu, bcmath, bz2, ctype,
    curl, date, dom, exif, fileinfo, filter, gd, gettext, hash, iconv, intl, json, ldap, libxml, mbstring, memcached, mysqli,
    mysqlnd, openssl, pcre, pdo_mysql, pdo_sqlite, posix, session, snmp, soap, sockets, sodium, sqlite3, standard, tokenizer, xml,
    xmlreader, xmlrpc, xmlwriter, xsl, zip, zlib)
Setup: max_execution_time="30" memory_limit="128M" post_max_size="101M" safe_mode="" session.save_handler="files"
    upload_max_filesize="8M" 
Software: Apache ()
    Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.63 Safari/537.36 Edg/102.0.1245.33
Server Software: MariaDB package
    Server Version: 10.5.15-MariaDB
    Server SQL Mode: STRICT_TRANS_TABLES
    Parameters: glpi-test@localhost/glpi-test
    Host info: Localhost via UNIX socket

PHP version (7.4.6) is supported.
Sessions configuration is OK.
Allocated memory is sufficient.
mysqli extension is installed.
Following extensions are installed: dom, fileinfo, json, simplexml.
curl extension is installed.
gd extension is installed.
intl extension is installed.
libxml extension is installed.
zlib extension is installed.
The constant SODIUM_CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NPUBBYTES is present.
Database engine version (10.5.15) is supported.
The log file has been created successfully.
Write access to /usr/local/share/glpitest/files/_cache has been validated.
Write access to /usr/local/share/glpitest/config has been validated.
Write access to /usr/local/share/glpitest/files/_cron has been validated.
Write access to /usr/local/share/glpitest/files has been validated.
Write access to /usr/local/share/glpitest/files/_dumps has been validated.
Write access to /usr/local/share/glpitest/files/_graphs has been validated.
Write access to /usr/local/share/glpitest/files/_lock has been validated.
Write access to /usr/local/share/glpitest/files/_pictures has been validated.
Write access to /usr/local/share/glpitest/files/_plugins has been validated.
Write access to /usr/local/share/glpitest/files/_rss has been validated.
Write access to /usr/local/share/glpitest/files/_sessions has been validated.
Write access to /usr/local/share/glpitest/files/_tmp has been validated.
Write access to /usr/local/share/glpitest/files/_uploads has been validated.
Web access to files directory is protected
exif extension is installed.
ldap extension is installed.
openssl extension is installed.
zip extension is installed.
bz2 extension is installed.
Zend OPcache extension is installed.
Following extensions are installed: ctype, iconv, mbstring, sodium.
Write access to /usr/local/share/glpitest/marketplace has been validated.
Timezones seems loaded in database.

GLPI constants
 
GLPI_ROOT: /usr/local/share/glpitest
GLPI_CONFIG_DIR: /usr/local/share/glpitest/config
GLPI_VAR_DIR: /usr/local/share/glpitest/files
GLPI_MARKETPLACE_DIR: /usr/local/share/glpitest/marketplace
GLPI_USE_CSRF_CHECK: 1
GLPI_CSRF_EXPIRES: 7200
GLPI_CSRF_MAX_TOKENS: 100
GLPI_USE_IDOR_CHECK: 1
GLPI_IDOR_EXPIRES: 7200
GLPI_ALLOW_IFRAME_IN_RICH_TEXT: 
GLPI_TELEMETRY_URI: https://telemetry.glpi-project.org
GLPI_INSTALL_MODE: TARBALL
GLPI_NETWORK_MAIL: glpi@teclib.com
GLPI_NETWORK_SERVICES: https://services.glpi-network.com
GLPI_MARKETPLACE_ALLOW_OVERRIDE: 1
GLPI_MARKETPLACE_MANUAL_DOWNLOADS: 1
GLPI_USER_AGENT_EXTRA_COMMENTS: 
GLPI_DISABLE_ONLY_FULL_GROUP_BY_SQL_MODE: 1
GLPI_AJAX_DASHBOARD: 1
GLPI_CALDAV_IMPORT_STATE: 0
GLPI_DEMO_MODE: 0
GLPI_CENTRAL_WARNINGS: 1
GLPI_DOC_DIR: /usr/local/share/glpitest/files
GLPI_CACHE_DIR: /usr/local/share/glpitest/files/_cache
GLPI_CRON_DIR: /usr/local/share/glpitest/files/_cron
GLPI_DUMP_DIR: /usr/local/share/glpitest/files/_dumps
GLPI_GRAPH_DIR: /usr/local/share/glpitest/files/_graphs
GLPI_LOCAL_I18N_DIR: /usr/local/share/glpitest/files/_locales
GLPI_LOCK_DIR: /usr/local/share/glpitest/files/_lock
GLPI_LOG_DIR: /usr/local/share/glpitest/files/_log
GLPI_PICTURE_DIR: /usr/local/share/glpitest/files/_pictures
GLPI_PLUGIN_DOC_DIR: /usr/local/share/glpitest/files/_plugins
GLPI_RSS_DIR: /usr/local/share/glpitest/files/_rss
GLPI_SESSION_DIR: /usr/local/share/glpitest/files/_sessions
GLPI_TMP_DIR: /usr/local/share/glpitest/files/_tmp
GLPI_UPLOAD_DIR: /usr/local/share/glpitest/files/_uploads
GLPI_INVENTORY_DIR: /usr/local/share/glpitest/files/_inventories
GLPI_NETWORK_REGISTRATION_API_URL: https://services.glpi-network.com/api/registration/
GLPI_MARKETPLACE_PLUGINS_API_URI: https://services.glpi-network.com/api/glpi-plugins/
GLPI_I18N_DIR: /usr/local/share/glpitest/locales
GLPI_VERSION: 10.0.1
GLPI_SCHEMA_VERSION: 10.0.1@a130db99c7d9b131c2e2ea59fe0d6260fe93d831
GLPI_MARKETPLACE_PRERELEASES: 
GLPI_MIN_PHP: 7.4.0
GLPI_MAX_PHP: 8.2.0
GLPI_YEAR: 2022

Libraries
 
htmlawed/htmlawed version 1.2.6 in (/usr/local/share/glpitest/vendor/htmlawed/htmlawed)
phpmailer/phpmailer version 6.6.0 in (/usr/local/share/glpitest/vendor/phpmailer/phpmailer/src)
simplepie/simplepie version 1.5.8 in (/usr/local/share/glpitest/vendor/simplepie/simplepie/library)
tecnickcom/tcpdf version 6.4.4 in (/usr/local/share/glpitest/vendor/tecnickcom/tcpdf)
michelf/php-markdown in (/usr/local/share/glpitest/vendor/michelf/php-markdown/Michelf)
true/punycode in (/usr/local/share/glpitest/vendor/true/punycode/src)
iamcal/lib_autolink in (/usr/local/share/glpitest/vendor/iamcal/lib_autolink)
sabre/dav in (/usr/local/share/glpitest/vendor/sabre/dav/lib/DAV)
sabre/http in (/usr/local/share/glpitest/vendor/sabre/http/lib)
sabre/uri in (/usr/local/share/glpitest/vendor/sabre/uri/lib)
sabre/vobject in (/usr/local/share/glpitest/vendor/sabre/vobject/lib)
laminas/laminas-i18n in (/usr/local/share/glpitest/vendor/laminas/laminas-i18n/src)
laminas/laminas-servicemanager in (/usr/local/share/glpitest/vendor/laminas/laminas-servicemanager/src)
monolog/monolog in (/usr/local/share/glpitest/vendor/monolog/monolog/src/Monolog)
sebastian/diff in (/usr/local/share/glpitest/vendor/sebastian/diff/src)
donatj/phpuseragentparser in (/usr/local/share/glpitest/vendor/donatj/phpuseragentparser/src/UserAgent)
elvanto/litemoji in (/usr/local/share/glpitest/vendor/elvanto/litemoji/src)
symfony/console in (/usr/local/share/glpitest/vendor/symfony/console)
scssphp/scssphp in (/usr/local/share/glpitest/vendor/scssphp/scssphp/src)
laminas/laminas-mail in (/usr/local/share/glpitest/vendor/laminas/laminas-mail/src/Protocol)
laminas/laminas-mime in (/usr/local/share/glpitest/vendor/laminas/laminas-mime/src)
rlanvin/php-rrule in (/usr/local/share/glpitest/vendor/rlanvin/php-rrule/src)
blueimp/jquery-file-upload in (/usr/local/share/glpitest/vendor/blueimp/jquery-file-upload/server/php)
ramsey/uuid in (/usr/local/share/glpitest/vendor/ramsey/uuid/src)
psr/log in (/usr/local/share/glpitest/vendor/psr/log/Psr/Log)
psr/simple-cache in (/usr/local/share/glpitest/vendor/psr/simple-cache/src)
psr/cache in (/usr/local/share/glpitest/vendor/psr/cache/src)
league/csv in (/usr/local/share/glpitest/vendor/league/csv/src)
mexitek/phpcolors in (/usr/local/share/glpitest/vendor/mexitek/phpcolors/src/Mexitek/PHPColors)
guzzlehttp/guzzle in (/usr/local/share/glpitest/vendor/guzzlehttp/guzzle/src)
guzzlehttp/psr7 in (/usr/local/share/glpitest/vendor/guzzlehttp/psr7/src)
glpi-project/inventory_format in (/usr/local/share/glpitest/vendor/glpi-project/inventory_format/lib/php)
wapmorgan/unified-archive in (/usr/local/share/glpitest/vendor/wapmorgan/unified-archive/src)
paragonie/sodium_compat in (/usr/local/share/glpitest/vendor/paragonie/sodium_compat/src)
symfony/cache in (/usr/local/share/glpitest/vendor/symfony/cache)
html2text/html2text in (/usr/local/share/glpitest/vendor/html2text/html2text/src)
symfony/css-selector in (/usr/local/share/glpitest/vendor/symfony/css-selector)
symfony/dom-crawler in (/usr/local/share/glpitest/vendor/symfony/dom-crawler)
twig/twig in (/usr/local/share/glpitest/vendor/twig/twig/src)
twig/string-extra in (/usr/local/share/glpitest/vendor/twig/string-extra)
symfony/polyfill-ctype not found
symfony/polyfill-iconv not found
symfony/polyfill-mbstring not found
symfony/polyfill-php80 in (/usr/local/share/glpitest/vendor/symfony/polyfill-php80)
symfony/polyfill-php81 in (/usr/local/share/glpitest/vendor/symfony/polyfill-php81)

LDAP directories
 
Server: 'ldap://uddc1.iacpud.local', Port: '389', BaseDN: 'OU=AterUsers,DC=IACPUD,DC=LOCAL', Connection filter:
        '(&(objectClass=user)(objectCategory=person)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))', RootDN: 'LDAPSearchUser',
        Use TLS: none

SQL replicas
 
Not active

Notifications
 
Way of sending emails: SMTP (anonymous@smtp.iacpud.local)

Plugins list
 
    accounts             Name: Accounts                       Version: 3.0.2      State: Enabled
    additionalalerts     Name: Altre notifiche                Version: 2.4.0      State: Enabled
    barcode              Name: Barcode                        Version: 2.7.0      State: Enabled
    printercounters      Name: Contatori della stampante      Version: 2.0.0      State: Enabled
    dashboard            Name: Dashboard                      Version: 0.9.6      State: Not installed
    datainjection        Name: Data injection                 Version: 2.11.1     State: Enabled
    databases            Name: Databases                      Version: 2.3.0      State: Installed / not activated
    addressing           Name: Indirizzamento IP              Version: 3.0.0      State: Installed / not activated
    room                 Name: Locali                         Version: 3.1.3      State: Enabled
    mailanalyzer         Name: Mail Analyzer                  Version: 1.6.0      State: Not installed
    mreporting           Name: More Reporting                 Version: 1.8.0      State: Installed / not activated
    ocsinventoryng       Name: OCS Inventory NG               Version: 2.0.0      State: Enabled
    reports              Name: Report                         Version: 1.12.0     State: Installed / not activated
    reservation          Name: Reservation                    Version: 2.3.3      State: Not installed
    screenshot           Name: Screenshot                     Version: 2.0.0      State: Not installed
    shellcommands        Name: Shell Commands                 Version: 4.0.1      State: Enabled
    pdf                  Name: Stampa in PDF                  Version: 1.7.0      State: Installed / not activated
    ticketcleaner        Name: Ticket Cleaner                 Version: 2.1.0      State: Installed / not activated
    useditemsexport      Name: Used items export              Version: 2.5.0      State: Installed / not activated
    treeview             Name: Visualizzazione struttura      Version: 1.10.0     State: Enabled
    webapplications      Name: Web applications               Version: 4.0.1      State: Enabled

Anything else?

No response

cconard96 commented 2 years ago

A new feature was added with 10.0.1 to try and catch issues with the database schema as we noticed some users (mostly from very old versions) had not had all the expected migrations done.

In this case, I don't understand how that table would have those columns. The table was added in 9.4.0 and has kept the same columns. It never should have had a changes_id column.

Can you verify from the database itself which columns the table has to rule out an issue with the schema checker?

jackburton79 commented 2 years ago

Table definition: image

In production, where we still have glpi 9.5.7, the table looks correct: image

cconard96 commented 2 years ago

Was the production database used in testing the 10.0/10.0.1 update?

If so, there may be something very wrong with the migration scripts.

jackburton79 commented 2 years ago

Was the production database used in testing the 10.0/10.0.1 update?

If so, there may be something very wrong with the migration scripts.

Yes, the production database was used to create the testing installation around glpi 9.0, if I remember correctly. Later, the two installation were always updated independently.

cconard96 commented 2 years ago

Apparently glpi_itils_projects was originally named glpi_changes_projects and was renamed in 9.4. Somehow, your test instance renamed the table without changing the columns.

The manual migrations needed:

ALTER TABLE glpi_itils_projects RENAME COLUMN changes_id TO items_id;
ALTER TABLE glpi_itils_projects ADD COLUMN `itemtype` varchar(100) NOT NULL DEFAULT '' AFTER `id`;
UPDATE glpi_itils_projects SET `itemtype` = "Change";
ALTER TABLE glpi_itils_projects ADD UNIQUE `unicity` (`itemtype`, `items_id`, `projects_id`);

This will rename the changes_id column to items_id, add the itemtype column and change the existing records to refer to Changes, and add the new unique key.

jackburton79 commented 2 years ago

Done. Now the glpi:database:check_schema_integrity script doesn't complain anymore. Thanks!