Unable to access contacts and segments (HTTP 500) after upgrading from 5.0.0 to 5.2.0

Your software
My Mautic version is: 5.2.0
My PHP version is: 8.1
My Database type and version is: MySQL 8.0.35

Your problem
My problem is: Cannot access Contacts, and Segments after update and migration.

These errors are showing in the log:
Accessing contacts:

[2024-12-04T13:12:09.366899+00:00] mautic.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\Exception\DriverException: "An exception occurred while executing a query: SQLSTATE[42000]: Syntax error or access violation: 1176 Key 'lead_date_added' doesn't exist in table 'l'" at /usr/home/idomods/domains/mautic.idomods.usermd.net/public_html/vendor/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php line 117 {"exception":"[object] (Doctrine\\DBAL\\Exception\\DriverException(code: 1176): An exception occurred while executing a query: SQLSTATE[42000]: Syntax error or access violation: 1176 Key 'lead_date_added' doesn't exist in table 'l' at /usr/home/idomods/domains/mautic.idomods.usermd.net/public_html/vendor/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php:117)\n[previous exception] [object] (Doctrine\\DBAL\\Driver\\PDO\\Exception(code: 1176): SQLSTATE[42000]: Syntax error or access violation: 1176 Key 'lead_date_added' doesn't exist in table 'l' at /usr/home/idomods/domains/mautic.idomods.usermd.net/public_html/vendor/doctrine/dbal/src/Driver/PDO/Exception.php:28)\n[previous exception] [object] (PDOException(code: 42000): SQLSTATE[42000]: Syntax error or access violation: 1176 Key 'lead_date_added' doesn't exist in table 'l' at /usr/home/idomods/domains/mautic.idomods.usermd.net/public_html/vendor/doctrine/dbal/src/Driver/PDO/Statement.php:130)"} {"hostname":"s63.mydevil.net","pid":63426}

Accessing segments:

[2024-12-04T14:15:04.723561+01:00] mautic.ERROR: Doctrine\DBAL\Exception\DriverException: An exception occurred while executing a query: SQLSTATE[42000]: Syntax error or access violation: 1176 Key 'manually_removed' doesn't exist in table 'l' (uncaught exception) at /usr/home/idomods/domains/mautic.idomods.usermd.net/public_html/vendor/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php line 117 while running console command `mautic:segments:update` [stack trace] #0 /usr/home/idomods/domains/mautic.idomods.usermd.net/public_html/vendor/doctrine/dbal/src/Connection.php(1938): Doctrine\DBAL\Driver\API\MySQL\ExceptionConverter->convert(Object(Doctrine\DBAL\Driver\PDO\Exception), Object(Doctrine\DBAL\Query)) #1 /usr/home/idomods/domains/mautic.idomods.usermd.net/public_html/vendor/doctrine/dbal/src/Connection.php(1880): Doctrine\DBAL\Connection->handleDriverException(Object(Doctrine\DBAL\Driver\PDO\Exception), Object(Doctrine\DBAL\Query)) #2 /usr/home/idomods/domains/mautic.idomods.usermd.net/public_html/vendor/doctrine/dbal/src/Connection.php(1105): Doctrine\DBAL\Connection->convertExceptionDuringQuery(Object(Doctrine\DBAL\Driver\PDO\Exception), 'SELECT count(l....', Array, Array) #3 /usr/home/idomods/domains/mautic.idomods.usermd.net/public_html/vendor/doctrine/dbal/src/Query/QueryBuilder.php(341): Doctrine\DBAL\Connection->executeQuery('SELECT count(l....', Array, Array, NULL) #4 /usr/home/idomods/domains/mautic.idomods.usermd.net/public_html/app/bundles/LeadBundle/Entity/LeadListRepository.php(288): Doctrine\DBAL\Query\QueryBuilder->executeQuery() #5 /usr/home/idomods/domains/mautic.idomods.usermd.net/public_html/app/bundles/LeadBundle/Model/ListModel.php(514): Mautic\LeadBundle\Entity\LeadListRepository->getLeadCount(Array) #6 /usr/home/idomods/domains/mautic.idomods.usermd.net/public_html/app/bundles/LeadBundle/Command/UpdateLeadListsCommand.php(145): Mautic\LeadBundle\Model\ListModel->rebuildListLeads(Object(Mautic\LeadBundle\Entity\LeadList), 300, 0, Object(Symfony\Component\Console\Output\ConsoleOutput)) #7 /usr/home/idomods/domains/mautic.idomods.usermd.net/public_html/app/bundles/LeadBundle/Command/UpdateLeadListsCommand.php(120): Mautic\LeadBundle\Command\UpdateLeadListsCommand->rebuildSegment(Object(Mautic\LeadBundle\Entity\LeadList), 300, 0, Object(Symfony\Component\Console\Output\ConsoleOutput)) #8 /usr/home/idomods/domains/mautic.idomods.usermd.net/public_html/vendor/symfony/console/Command/Command.php(298): Mautic\LeadBundle\Command\UpdateLeadListsCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #9 /usr/home/idomods/domains/mautic.idomods.usermd.net/public_html/vendor/symfony/console/Application.php(1058): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #10 /usr/home/idomods/domains/mautic.idomods.usermd.net/public_html/vendor/symfony/framework-bundle/Console/Application.php(96): Symfony\Component\Console\Application->doRunCommand(Object(Mautic\LeadBundle\Command\UpdateLeadListsCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #11 /usr/home/idomods/domains/mautic.idomods.usermd.net/public_html/vendor/symfony/console/Application.php(301): Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand(Object(Mautic\LeadBundle\Command\UpdateLeadListsCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #12 /usr/home/idomods/domains/mautic.idomods.usermd.net/public_html/vendor/symfony/framework-bundle/Console/Application.php(82): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #13 /usr/home/idomods/domains/mautic.idomods.usermd.net/public_html/vendor/symfony/console/Application.php(171): Symfony\Bundle\FrameworkBundle\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #14 /usr/home/idomods/domains/mautic.idomods.usermd.net/public_html/bin/console(16): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #

I’ve updated from 5.0.0 to 5.2.0, and i’ve had some problems with migrating the db. I had problem with “Table ‘point_groups’ already exists”, but fixed it with this workaround from GH Issue. Now mautic /s/update/schema does not show an error, but I can not access contacts and segments. In my opinion there is still some DB problem, as I don’t have table “l” inside, only “leads” which contains similar data.

Steps I have tried to fix the problem:
Multiple times tried migrating db, also I can not use this command:
bin/console doctrine:schema:update --no-interaction --force --complete
as with that my schema page shows error again, and the command fails with this error message:


 Updating database schema...


In ExceptionConverter.php line 117:

  An exception occurred while executing a query: SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP 'IDX_
  1AE3441319EB6921'; check that column/key exists


In Exception.php line 28:

  SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP 'IDX_1AE3441319EB6921'; check that column/key exists


In Connection.php line 33:

  SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP 'IDX_1AE3441319EB6921'; check that column/key exists


doctrine:schema:update [--em EM] [--complete] [--dump-sql] [-f|--force]

Please provide me some help. Thanks a lot! One thing to mention that i am not PHP developer :slight_smile:

We experienced a similar issue when upgrading from 5.0.0 to 5.0.1. I wrote about this update bug in our company blog (Mautic 5 is finally available, but beware a minor update bug (to 5.0.1)).
In our case we had to manually fix the 5.0.0 code with the patch available (fix: [DPMMA-2252] point groups migration fix by patrykgruszka · Pull Request #13195 · mautic/mautic · GitHub).

You probably need to do something similar here to be able to upgrade. But I’m not certain, it’s been a while.

Hey, I downloaded new version zip, installed and then connected my old database to it, because of errors when trying to update with composer. Now i am fighting with this error for a couple of hours and still didn’t find the fix. I’ve seen your post and tried this patch but the patch is also causing me errors unfortunately :frowning: .