Skip to content

Conversation

escopecz
Copy link
Member

@escopecz escopecz commented Mar 31, 2025

Q A
Bug fix? (use the a.b branch) ✔️
New feature/enhancement? (use the a.x branch) ✔️
Deprecations?
BC breaks? (use the c.x branch)
Automated tests included?
Related user documentation PR URL mautic/user-documentation#...
Related developer documentation PR URL mautic/developer-documentation-new#...
Issue(s) addressed Fixes #...

Description

This PR updates another package that is blocking updating Symfony to v7:

$ composer why-not symfony/console 7.2
doctrine/migrations      3.5.5     requires  symfony/console (^4.4.16 || ^5.4 || ^6.0) 
mautic/core-lib          7.0.0-dev requires  symfony/console (^6.4)                    
symfony/framework-bundle v6.4.13   conflicts symfony/console (<5.4|>=7.0)  

All the changes in this PR were generated by this command:

composer update doctrine/doctrine-migrations-bundle doctrine/migrations

It output this:

Lock file operations: 0 installs, 2 updates, 2 removals
  - Removing friendsofphp/proxy-manager-lts (v1.0.18)
  - Removing laminas/laminas-code (4.16.0)
  - Upgrading doctrine/doctrine-migrations-bundle (3.3.0 => 3.4.1)
  - Upgrading doctrine/migrations (3.5.5 => 3.9.0)

Now we should be closer to updating Symfony:

$ composer why-not symfony/console 7.2
mautic/core-lib          7.0.0-dev requires  symfony/console (^6.4)       
symfony/framework-bundle v6.4.13   conflicts symfony/console (<5.4|>=7.0)

📋 Steps to test this PR:

  1. Open this PR on Gitpod or pull down for testing locally (see docs on testing PRs here)
  2. Run bin/console doctrine:migrations:migrate to check that the Doctrine migration command won't fail with an error.

@escopecz escopecz added dependencies Pull requests that update a dependency file composer Any bugs or PRs relating to composer labels Mar 31, 2025
@escopecz escopecz added this to the 7.0.0-alpha milestone Mar 31, 2025
@escopecz escopecz changed the title Updating Doctrine migrations Updating Doctrine migrations package Mar 31, 2025
@escopecz escopecz requested a review from Copilot March 31, 2025 14:48
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

@escopecz escopecz added ready-to-test PR's that are ready to test code-review-needed PR's that require a code review before merging labels Mar 31, 2025
Copy link
Contributor

@matbcvo matbcvo left a comment

Choose a reason for hiding this comment

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

The code changes look good to me. The Doctrine migration command works, although it outputs an error that isn't caused by this PR. This error also occurs in the 7.x branch.

Looks like there's an issue with Mautic\Migrations\Version20241212090146.

gitpod /workspace/mautic (updating-doctrine-migrations) $ ddev exec bin/console doctrine:migrations:migrate
...
[notice] Column draft_custom_mjml already exists
[notice] Migration Mautic\Migrations\Version20240611103824 skipped during Pre-Checks. Reason: "Schema includes this migration"
[error] Migration Mautic\Migrations\Version20241212090146 failed during Execution. Error: "An exception occurred while executing a query: SQLSTATE[42000]: Syntax error or access violation: 1061 Duplicate key name 'internal_object_id_idx'"
15:18:05 ERROR     [mautic] Doctrine\DBAL\Exception\DriverException: An exception occurred while executing a query: SQLSTATE[42000]: Syntax error or access violation: 1061 Duplicate key name 'internal_object_id_idx' (uncaught exception) at /var/www/html/vendor/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php line 117 while running console command `doctrine:migrations:migrate`
[stack trace]
#0 /var/www/html/vendor/doctrine/dbal/src/Connection.php(1938): Doctrine\DBAL\Driver\API\MySQL\ExceptionConverter->convert()
#1 /var/www/html/vendor/doctrine/dbal/src/Connection.php(1880): Doctrine\DBAL\Connection->handleDriverException()
#2 /var/www/html/vendor/doctrine/dbal/src/Connection.php(1105): Doctrine\DBAL\Connection->convertExceptionDuringQuery()
#3 /var/www/html/vendor/doctrine/migrations/src/Version/DbalExecutor.php(275): Doctrine\DBAL\Connection->executeQuery()
#4 /var/www/html/vendor/doctrine/migrations/src/Version/DbalExecutor.php(152): Doctrine\Migrations\Version\DbalExecutor->executeResult()
#5 /var/www/html/vendor/doctrine/migrations/src/Version/DbalExecutor.php(72): Doctrine\Migrations\Version\DbalExecutor->executeMigration()
#6 /var/www/html/vendor/doctrine/migrations/src/DbalMigrator.php(87): Doctrine\Migrations\Version\DbalExecutor->execute()
#7 /var/www/html/vendor/doctrine/migrations/src/DbalMigrator.php(54): Doctrine\Migrations\DbalMigrator->executePlan()
#8 /var/www/html/vendor/doctrine/migrations/src/DbalMigrator.php(134): Doctrine\Migrations\DbalMigrator->executeMigrations()
#9 /var/www/html/vendor/doctrine/migrations/src/Tools/Console/Command/MigrateCommand.php(225): Doctrine\Migrations\DbalMigrator->migrate()
#10 /var/www/html/vendor/symfony/console/Command/Command.php(326): Doctrine\Migrations\Tools\Console\Command\MigrateCommand->execute()
#11 /var/www/html/vendor/symfony/console/Application.php(1096): Symfony\Component\Console\Command\Command->run()
#12 /var/www/html/vendor/symfony/framework-bundle/Console/Application.php(126): Symfony\Component\Console\Application->doRunCommand()
#13 /var/www/html/vendor/symfony/console/Application.php(324): Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand()
#14 /var/www/html/vendor/symfony/framework-bundle/Console/Application.php(80): Symfony\Component\Console\Application->doRun()
#15 /var/www/html/vendor/symfony/console/Application.php(175): Symfony\Bundle\FrameworkBundle\Console\Application->doRun()
#16 /var/www/html/bin/console(16): Symfony\Component\Console\Application->run()
#17 {main} ["hostname" => "mautic-web","pid" => 4579]
15:18:05 CRITICAL  [console] Error thrown while running command "doctrine:migrations:migrate". Message: "An exception occurred while executing a query: SQLSTATE[42000]: Syntax error or access violation: 1061 Duplicate key name 'internal_object_id_idx'" ["exception" => Doctrine\DBAL\Exception\DriverException^ { …},"command" => "doctrine:migrations:migrate","message" => "An exception occurred while executing a query: SQLSTATE[42000]: Syntax error or access violation: 1061 Duplicate key name 'internal_object_id_idx'"] ["hostname" => "mautic-web","pid" => 4579]
15:18:05 WARNING   [mautic] Command `doctrine:migrations:migrate` exited with status code 255 ["hostname" => "mautic-web","pid" => 4579]

In ExceptionConverter.php line 117:
                                                                                                                                                      
  An exception occurred while executing a query: SQLSTATE[42000]: Syntax error or access violation: 1061 Duplicate key name 'internal_object_id_idx'  
                                                                                                                                                      

In Exception.php line 28:
                                                                                                       
  SQLSTATE[42000]: Syntax error or access violation: 1061 Duplicate key name 'internal_object_id_idx'  
                                                                                                       

In Connection.php line 71:
                                                                                                       
  SQLSTATE[42000]: Syntax error or access violation: 1061 Duplicate key name 'internal_object_id_idx'  
                                                                                                       

doctrine:migrations:migrate [--write-sql [WRITE-SQL]] [--dry-run] [--query-time] [--allow-no-migration] [--all-or-nothing [ALL-OR-NOTHING]] [--no-all-or-nothing] [--configuration CONFIGURATION] [--em EM] [--conn CONN] [--] [<version>]

Failed to execute command bin/console doctrine:migrations:migrate: exit status 255
gitpod /workspace/mautic (updating-doctrine-migrations) $ 

@matbcvo matbcvo added code-review-passed PRs which have passed code review pending-test-confirmation PR's that require one test before they can be merged and removed code-review-needed PR's that require a code review before merging ready-to-test PR's that are ready to test labels Mar 31, 2025
@escopecz
Copy link
Member Author

That's a migration I have added. I don't see any issue when looking at the code. It didn't error out on my company laptop. On my personal laptop it fails on a different migration where I see an issue:

[error] Migration Mautic\Migrations\Version20211020114811 failed during Execution. Error: "An exception occurred while executing a query: SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP INDEX `test_company_match`; check that it exists"
19:46:54 ERROR     [mautic] Doctrine\DBAL\Exception\DriverException: An exception occurred while executing a query: SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP INDEX `test_company_match`; check that it exists (uncaught exception) at /var/www/html/vendor/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php line 117 while running console command `doctrine:migrations:migrate`
[stack trace]
#0 /var/www/html/vendor/doctrine/dbal/src/Connection.php(1938): Doctrine\DBAL\Driver\API\MySQL\ExceptionConverter->convert()
#1 /var/www/html/vendor/doctrine/dbal/src/Connection.php(1880): Doctrine\DBAL\Connection->handleDriverException()
#2 /var/www/html/vendor/doctrine/dbal/src/Connection.php(1105): Doctrine\DBAL\Connection->convertExceptionDuringQuery()
#3 /var/www/html/vendor/doctrine/migrations/lib/Doctrine/Migrations/Version/DbalExecutor.php(298): Doctrine\DBAL\Connection->executeQuery()
#4 /var/www/html/vendor/doctrine/migrations/lib/Doctrine/Migrations/Version/DbalExecutor.php(173): Doctrine\Migrations\Version\DbalExecutor->executeResult()
#5 /var/www/html/vendor/doctrine/migrations/lib/Doctrine/Migrations/Version/DbalExecutor.php(95): Doctrine\Migrations\Version\DbalExecutor->executeMigration()
#6 /var/www/html/vendor/doctrine/migrations/lib/Doctrine/Migrations/DbalMigrator.php(107): Doctrine\Migrations\Version\DbalExecutor->execute()
#7 /var/www/html/vendor/doctrine/migrations/lib/Doctrine/Migrations/DbalMigrator.php(71): Doctrine\Migrations\DbalMigrator->executePlan()
#8 /var/www/html/vendor/doctrine/migrations/lib/Doctrine/Migrations/DbalMigrator.php(157): Doctrine\Migrations\DbalMigrator->executeMigrations()
#9 /var/www/html/vendor/doctrine/migrations/lib/Doctrine/Migrations/Tools/Console/Command/MigrateCommand.php(211): Doctrine\Migrations\DbalMigrator->migrate()
#10 /var/www/html/vendor/symfony/console/Command/Command.php(326): Doctrine\Migrations\Tools\Console\Command\MigrateCommand->execute()
#11 /var/www/html/vendor/symfony/console/Application.php(1096): Symfony\Component\Console\Command\Command->run()
#12 /var/www/html/vendor/symfony/framework-bundle/Console/Application.php(126): Symfony\Component\Console\Application->doRunCommand()
#13 /var/www/html/vendor/symfony/console/Application.php(324): Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand()
#14 /var/www/html/vendor/symfony/framework-bundle/Console/Application.php(80): Symfony\Component\Console\Application->doRun()
#15 /var/www/html/vendor/symfony/console/Application.php(175): Symfony\Bundle\FrameworkBundle\Console\Application->doRun()
#16 /var/www/html/bin/console(16): Symfony\Component\Console\Application->run()
#17 {main} ["hostname" => "mautic-web","pid" => 28876]
19:46:54 CRITICAL  [console] Error thrown while running command "'d:m:m'". Message: "An exception occurred while executing a query: SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP INDEX `test_company_match`; check that it exists" ["exception" => Doctrine\DBAL\Exception\DriverException^ { …},"command" => "'d:m:m'","message" => "An exception occurred while executing a query: SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP INDEX `test_company_match`; check that it exists"] ["hostname" => "mautic-web","pid" => 28876]
19:46:54 WARNING   [mautic] Command `doctrine:migrations:migrate` exited with status code 255 ["hostname" => "mautic-web","pid" => 28876]

In ExceptionConverter.php line 117:
                                                                                                                       
  An exception occurred while executing a query: SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP I  
  NDEX `test_company_match`; check that it exists                                                                                                                         

I'll get to this tomorrow. Just wanted to make a note about this for myself.

@escopecz
Copy link
Member Author

escopecz commented Apr 1, 2025

One of the migrations is fixed in #14824.

@escopecz escopecz moved this to ⏳︎ Needs 1 more test in Open Source Fridays Apr 1, 2025
@matbcvo
Copy link
Contributor

matbcvo commented Apr 1, 2025

With fix #14824 applied, I can confirm that the error no longer occurs and the doctrine:migrations:migrate command completes successfully. 👍

[notice] Table sync_object_mapping does not exist or the index internal_object_id_idx already exists.
[notice] Migration Mautic\Migrations\Version20241212090146 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] Column is_read_only already exists
[notice] Migration Mautic\Migrations\Version20241227065658 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] Column type already exists in table dynamic_content
[notice] Migration Mautic\Migrations\Version20250127092202 skipped during Pre-Checks. Reason: "Schema includes this migration"
[warning] Migration Mautic\Migrations\Version20250207035735 was executed but did not result in any SQL statements.
[notice] Migration Mautic\Migrations\Versionzz20230929183000 skipped during Pre-Checks. Reason: "There are no local config files to migrate. Skipping the migration."
[notice] finished in 3362.2ms, used 34M memory, 67 migrations executed, 52 sql queries
                                                                                                                        
 [OK] Successfully migrated to version: Mautic\Migrations\Versionzz20230929183000                                       
                                                                                                                        

@escopecz escopecz merged commit f2b823e into mautic:7.x Apr 1, 2025
15 checks passed
@github-project-automation github-project-automation bot moved this from ⏳︎ Needs 1 more test to 🥳 Done in Open Source Fridays Apr 1, 2025
@escopecz escopecz added user-testing-passed PRs which have been successfully tested by the required number of people. and removed pending-test-confirmation PR's that require one test before they can be merged labels Apr 1, 2025
Copy link

codecov bot commented Apr 1, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.59%. Comparing base (0eafaf1) to head (f63e4de).
⚠️ Report is 1883 commits behind head on 7.x.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##                7.x   #14821      +/-   ##
============================================
- Coverage     65.59%   65.59%   -0.01%     
  Complexity    34908    34908              
============================================
  Files          2296     2296              
  Lines        140433   140433              
============================================
- Hits          92115    92114       -1     
- Misses        48318    48319       +1     

see 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@escopecz escopecz added the enhancement Any improvement to an existing feature or functionality label Aug 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code-review-passed PRs which have passed code review composer Any bugs or PRs relating to composer dependencies Pull requests that update a dependency file enhancement Any improvement to an existing feature or functionality user-testing-passed PRs which have been successfully tested by the required number of people.
Projects
Status: 🥳 Done
Development

Successfully merging this pull request may close these issues.

2 participants