Running doctrine:migration:migrate does not apply all upgrades

My Mautic version is: 5.2.1
My PHP version is: 8.1.31
My Database type and version is: 8.0.40 MySQL
Dockerized with php8.1-apache

My Problem:

After upgrade from Mautic 5.0.4 to 5.2.1 i’d also liked to run the doctrine migrations, but they refuse to install.

mautic:update:apply runs fine, but the doctrine:migration:migrate spit out errors:

[2025-01-09 18:20:34]  [WARNING] You have 78 previously executed migrations in the database that are not registered migrations.
[2025-01-09 18:20:34]
[2025-01-09 18:20:34]
[2025-01-09 18:20:34]  >> 2021-06-23 14:03:28 (20180508202930)
[2025-01-09 18:20:34]  >> 2022-03-21 15:24:02 (20180702014364)
[2025-01-09 18:20:34]  >> 2022-03-21 15:24:02 (20180702014365)
[2025-01-09 18:20:34]  >> 2021-06-23 14:03:29 (20180821144204)
[2025-01-09 18:20:34]  >> 2021-06-23 14:03:29 (20180921144421)
[2025-01-09 18:20:34]  >> 2020-11-05 10:45:51 (20181111095447)
[2025-01-09 18:20:34]  >> 2020-11-05 10:45:51 (20190704154940)
[2025-01-09 18:20:34]  >> 2020-11-05 10:45:53 (20190724110039)
[2025-01-09 18:20:34]  >> 2020-12-13 10:56:02 (20191017140848)
[2025-01-09 18:20:34]  >> 2020-11-05 10:45:54 (20191126093923)
[2025-01-09 18:20:34]  >> 2020-12-13 10:56:02 (20191206113956)
[2025-01-09 18:20:34]  >> 2020-11-05 10:45:55 (20191219155630)
[2025-01-09 18:20:34]  >> 2020-11-05 10:45:56 (20200211095409)
[2025-01-09 18:20:34]  >> 2020-11-05 10:45:57 (20200212141530)
[2025-01-09 18:20:34]  >> 2020-11-05 10:45:57 (20200220172041)
[2025-01-09 18:20:34]  >> 2020-11-05 10:45:57 (20200227110431)
[2025-01-09 18:20:34]  >> 2020-11-05 10:45:57 (20200302164801)
[2025-01-09 18:20:34]  >> 2021-06-23 14:03:29 (20200331160919)
[2025-01-09 18:20:34]  >> 2022-03-21 15:24:02 (20200409102100)
[2025-01-09 18:20:34]  >> 2020-11-05 10:45:57 (20200422144300)
[2025-01-09 18:20:34]  >> 2022-03-21 15:24:03 (20200507122854)
[2025-01-09 18:20:34]  >> 2022-03-21 15:24:03 (20200729170800)
[2025-01-09 18:20:34]  >> 2020-11-05 10:45:58 (20200805185714)
[2025-01-09 18:20:34]  >> 2022-03-21 15:24:03 (20200810153131)
[2025-01-09 18:20:34]  >> 2022-03-21 15:24:03 (20200812180900)
[2025-01-09 18:20:34]  >> 2020-11-05 10:45:58 (20200815153711)
[2025-01-09 18:20:34]  >> 2021-06-23 14:03:29 (20200924080139)
[2025-01-09 18:20:34]  >> 2021-06-23 14:03:29 (20201015084627)
[2025-01-09 18:20:34]  >> 2021-06-23 14:03:29 (20201102120710)
[2025-01-09 18:20:34]  >> 2021-06-23 14:03:29 (20201102133546)
[2025-01-09 18:20:34]  >> 2021-06-23 14:03:29 (20201105120328)
[2025-01-09 18:20:34]  >> 2022-03-21 15:24:04 (20201120122846)
[2025-01-09 18:20:34]  >> 2022-03-21 15:24:04 (20201123070813)
[2025-01-09 18:20:34]  >> 2022-03-21 15:24:04 (20201125155904)
[2025-01-09 18:20:34]  >> 2021-06-23 14:03:29 (20201130201631)
[2025-01-09 18:20:34]  >> 2022-03-21 15:24:04 (20201207114926)
[2025-01-09 18:20:34]  >> 2021-06-23 14:03:30 (20201207140911)
[2025-01-09 18:20:34]  >> 2022-03-21 15:24:04 (20201228041109)
[2025-01-09 18:20:34]  >> 2021-06-23 14:03:30 (20210104171005)
[2025-01-09 18:20:34]  >> 2022-03-21 15:24:04 (20210203143600)
[2025-01-09 18:20:34]  >> 2021-06-23 14:03:30 (20210223174702)
[2025-01-09 18:20:34]  >> 2022-03-21 15:24:04 (20210502162314)
[2025-01-09 18:20:34]  >> 2022-03-21 15:24:04 (20210520100503)
[2025-01-09 18:20:34]  >> 2022-03-21 15:24:05 (20210609191822)
[2025-01-09 18:20:34]  >> 2022-03-21 15:24:05 (20210614151138)
[2025-01-09 18:20:34]  >> 2022-03-21 15:24:05 (20210623071326)
[2025-01-09 18:20:34]  >> 2022-03-21 15:24:05 (20220111202917)
[2025-01-09 18:20:34]  >> 2023-06-07 10:04:11 (20230519081315)
[2025-01-09 18:20:34]  >> 2023-06-07 10:04:11 (20230522115137)
[2025-01-09 18:20:34]  >> 2025-01-09 14:43:54 (Mautic\Migrations\Version20190326190241)
[2025-01-09 18:20:34]  >> 2025-01-09 14:43:54 (Mautic\Migrations\Version20190410143658)
[2025-01-09 18:20:34]  >> 2025-01-09 14:43:55 (Mautic\Migrations\Version20190524124819)
[2025-01-09 18:20:34]  >> 2025-01-09 14:43:55 (Mautic\Migrations\Version20191106152509)
[2025-01-09 18:20:34]  >> 2025-01-09 14:43:55 (Mautic\Migrations\Version20200917152259)
[2025-01-09 18:20:34]  >> 2025-01-09 14:43:55 (Mautic\Migrations\Version20201019100000)
[2025-01-09 18:20:34]  >> 2025-01-09 14:43:56 (Mautic\Migrations\Version20210112162046)
[2025-01-09 18:20:34]  >> 2025-01-09 14:43:56 (Mautic\Migrations\Version20210115065034)
[2025-01-09 18:20:34]  >> 2025-01-09 14:43:56 (Mautic\Migrations\Version20210217115150)
[2025-01-09 18:20:34]  >> 2025-01-09 14:43:56 (Mautic\Migrations\Version20210420113309)
[2025-01-09 18:20:34]  >> 2025-01-09 14:43:57 (Mautic\Migrations\Version20211026152443)
[2025-01-09 18:20:34]  >> 2025-01-09 14:43:57 (Mautic\Migrations\Version20211026153057)
[2025-01-09 18:20:34]  >> 2025-01-09 14:43:57 (Mautic\Migrations\Version20211110070503)
[2025-01-09 18:20:34]  >> 2025-01-09 14:43:57 (Mautic\Migrations\Version20211209022550)
[2025-01-09 18:20:34]  >> 2025-01-09 14:43:58 (Mautic\Migrations\Version20230506112314)
[2025-01-09 18:20:34]  >> 2025-01-09 14:43:58 (Mautic\Migrations\Version20230506113422)
[2025-01-09 18:20:34]  >> 2025-01-09 14:43:58 (Mautic\Migrations\Version20230506113627)
[2025-01-09 18:20:34]  >> 2025-01-09 14:43:58 (Mautic\Migrations\Version20230506113731)
[2025-01-09 18:20:34]  >> 2025-01-09 14:43:58 (Mautic\Migrations\Version20230506113812)
[2025-01-09 18:20:34]  >> 2025-01-09 14:43:59 (Mautic\Migrations\Version20231110103625)
[2025-01-09 18:20:34]  >> 2025-01-09 14:43:59 (Mautic\Migrations\Version20231206152313)
[2025-01-09 18:20:34]  >> 2025-01-09 14:44:05 (Mautic\Migrations\Version20231207235400)
[2025-01-09 18:20:34]  >> 2025-01-09 14:44:05 (Mautic\Migrations\Version20240226114528)
[2025-01-09 18:20:34]  >> 2025-01-09 14:44:05 (Mautic\Migrations\Version20240320081612)
[2025-01-09 18:20:34]  >> 2025-01-09 14:44:06 (Mautic\Migrations\Version20240416112112)
[2025-01-09 18:20:34]  >> 2025-01-09 14:44:06 (Mautic\Migrations\Version20240611103824)
[2025-01-09 18:20:34]  >> 2025-01-09 14:44:06 (Mautic\Migrations\Version20240704164714)
[2025-01-09 18:20:34]  >> 2025-01-09 14:44:06 (Mautic\Migrations\Version20240708153845)
[2025-01-09 18:20:34]  >> 2025-01-09 14:44:06 (Mautic\Migrations\Version20240725105507)
[2025-01-09 18:20:34] [notice] Migrating up to Mautic\Migrations\Versionzz20230929183000
[2025-01-09 18:20:34] [notice] Migration Mautic\Migrations\Version20221128145933 skipped during Pre-Checks. Reason: "Schema includes this migration"
[2025-01-09 18:20:34] [notice] Table plugin_citrix_events already exists
[2025-01-09 18:20:34] [notice] Migration Mautic\Migrations\Version20230522141144 skipped during Pre-Checks. Reason: "Schema includes this migration"
[2025-01-09 18:20:34] [notice] Migration is not required.
[2025-01-09 18:20:34] [notice] Migration Mautic\Migrations\Version20230606111852 skipped during Pre-Checks. Reason: "Schema includes this migration"
[2025-01-09 18:20:34] [notice] Migration Mautic\Migrations\Versionzz20230929183000 skipped during Pre-Checks. Reason: "There are no local config files to migrate. Skipping the migration."
[2025-01-09 18:20:34] [notice] finished in 64.9ms, used 54.5M memory, 4 migrations executed, 0 sql queries
[2025-01-09 18:20:34]
[2025-01-09 18:20:34]
[2025-01-09 18:20:34]  [OK] Successfully migrated to version: Mautic\Migrations\Versionzz20230929183000
[2025-01-09 18:20:34]
[2025-01-09 18:20:34]
[2025-01-09 18:20:34]

When i run “status” it get

root@a0e1d9df866c:/var/www/html# php bin/console doctrine:migration:status
+----------------------+----------------------+------------------------------------------------------------------------+
| Configuration                                                                                                        |
+----------------------+----------------------+------------------------------------------------------------------------+
| Storage              | Type                 | Doctrine\Migrations\Metadata\Storage\TableMetadataStorageConfiguration |
|                      | Table Name           | migrations                                                             |
|                      | Column Name          | version                                                                |
|----------------------------------------------------------------------------------------------------------------------|
| Database             | Driver               | Doctrine\DBAL\Driver\PDO\MySQL\Driver                                  |
|                      | Name                 | mautic                                                                 |
|----------------------------------------------------------------------------------------------------------------------|
| Versions             | Previous             | Mautic\Migrations\Version20240708153845                                |
|                      | Current              | Mautic\Migrations\Version20240725105507                                |
|                      | Next                 | Mautic\Migrations\Version20221128145933                                |
|                      | Latest               | Mautic\Migrations\Versionzz20230929183000                              |
|----------------------------------------------------------------------------------------------------------------------|
| Migrations           | Executed             | 97                                                                     |
|                      | Executed Unavailable | 78                                                                     |
|                      | Available            | 23                                                                     |
|                      | New                  | 4                                                                      |
|----------------------------------------------------------------------------------------------------------------------|
| Migration Namespaces | Mautic\Migrations    | /var/www/html/docroot/app/migrations                                   |
+----------------------+----------------------+------------------------------------------------------------------------+

I have no clue what that means or how to fix it. Looks like there was a problem with the 2022-11-28 migration?

php ../bin/console doctrine:migrations:list
+-------------------------------------------+-------------------------+---------------------+----------------+-------------+
| Migration Versions                                                                                         |             |
+-------------------------------------------+-------------------------+---------------------+----------------+-------------+
| Migration                                 | Status                  | Migrated At         | Execution Time | Description |
+-------------------------------------------+-------------------------+---------------------+----------------+-------------+
| 20180508202930                            | migrated, not available | 2021-06-23 14:03:28 |                |             |
| 20180702014364                            | migrated, not available | 2022-03-21 15:24:02 |                |             |
| 20180702014365                            | migrated, not available | 2022-03-21 15:24:02 |                |             |
| 20180821144204                            | migrated, not available | 2021-06-23 14:03:29 |                |             |
| 20180921144421                            | migrated, not available | 2021-06-23 14:03:29 |                |             |
| 20181111095447                            | migrated, not available | 2020-11-05 10:45:51 |                |             |
| 20190704154940                            | migrated, not available | 2020-11-05 10:45:51 |                |             |
| 20190724110039                            | migrated, not available | 2020-11-05 10:45:53 |                |             |
| 20191017140848                            | migrated, not available | 2020-12-13 10:56:02 |                |             |
| 20191126093923                            | migrated, not available | 2020-11-05 10:45:54 |                |             |
| 20191206113956                            | migrated, not available | 2020-12-13 10:56:02 |                |             |
| 20191219155630                            | migrated, not available | 2020-11-05 10:45:55 |                |             |
| 20200211095409                            | migrated, not available | 2020-11-05 10:45:56 |                |             |
| 20200212141530                            | migrated, not available | 2020-11-05 10:45:57 |                |             |
| 20200220172041                            | migrated, not available | 2020-11-05 10:45:57 |                |             |
| 20200227110431                            | migrated, not available | 2020-11-05 10:45:57 |                |             |
| 20200302164801                            | migrated, not available | 2020-11-05 10:45:57 |                |             |
| 20200331160919                            | migrated, not available | 2021-06-23 14:03:29 |                |             |
| 20200409102100                            | migrated, not available | 2022-03-21 15:24:02 |                |             |
| 20200422144300                            | migrated, not available | 2020-11-05 10:45:57 |                |             |
| 20200507122854                            | migrated, not available | 2022-03-21 15:24:03 |                |             |
| 20200729170800                            | migrated, not available | 2022-03-21 15:24:03 |                |             |
| 20200805185714                            | migrated, not available | 2020-11-05 10:45:58 |                |             |
| 20200810153131                            | migrated, not available | 2022-03-21 15:24:03 |                |             |
| 20200812180900                            | migrated, not available | 2022-03-21 15:24:03 |                |             |
| 20200815153711                            | migrated, not available | 2020-11-05 10:45:58 |                |             |
| 20200924080139                            | migrated, not available | 2021-06-23 14:03:29 |                |             |
| 20201015084627                            | migrated, not available | 2021-06-23 14:03:29 |                |             |
| 20201102120710                            | migrated, not available | 2021-06-23 14:03:29 |                |             |
| 20201102133546                            | migrated, not available | 2021-06-23 14:03:29 |                |             |
| 20201105120328                            | migrated, not available | 2021-06-23 14:03:29 |                |             |
| 20201120122846                            | migrated, not available | 2022-03-21 15:24:04 |                |             |
| 20201123070813                            | migrated, not available | 2022-03-21 15:24:04 |                |             |
| 20201125155904                            | migrated, not available | 2022-03-21 15:24:04 |                |             |
| 20201130201631                            | migrated, not available | 2021-06-23 14:03:29 |                |             |
| 20201207114926                            | migrated, not available | 2022-03-21 15:24:04 |                |             |
| 20201207140911                            | migrated, not available | 2021-06-23 14:03:30 |                |             |
| 20201228041109                            | migrated, not available | 2022-03-21 15:24:04 |                |             |
| 20210104171005                            | migrated, not available | 2021-06-23 14:03:30 |                |             |
| 20210203143600                            | migrated, not available | 2022-03-21 15:24:04 |                |             |
| 20210223174702                            | migrated, not available | 2021-06-23 14:03:30 |                |             |
| 20210502162314                            | migrated, not available | 2022-03-21 15:24:04 |                |             |
| 20210520100503                            | migrated, not available | 2022-03-21 15:24:04 |                |             |
| 20210609191822                            | migrated, not available | 2022-03-21 15:24:05 |                |             |
| 20210614151138                            | migrated, not available | 2022-03-21 15:24:05 |                |             |
| 20210623071326                            | migrated, not available | 2022-03-21 15:24:05 |                |             |
| 20220111202917                            | migrated, not available | 2022-03-21 15:24:05 |                |             |
| 20230519081315                            | migrated, not available | 2023-06-07 10:04:11 |                |             |
| 20230522115137                            | migrated, not available | 2023-06-07 10:04:11 |                |             |
| Mautic\Migrations\Version020230615115326  | migrated                | 2024-05-16 15:19:27 | 1.586s         |             |
| Mautic\Migrations\Version20190326190241   | migrated                | 2025-01-09 14:43:54 | 0.231s         |             |
| Mautic\Migrations\Version20190410143658   | migrated                | 2025-01-09 14:43:54 | 0.487s         |             |
| Mautic\Migrations\Version20190524124819   | migrated                | 2025-01-09 14:43:55 | 0.327s         |             |
| Mautic\Migrations\Version20191106152509   | migrated                | 2025-01-09 14:43:55 | 0.001s         |             |
| Mautic\Migrations\Version20200415135706   | migrated                | 2024-05-16 15:19:29 | 0.222s         |             |
| Mautic\Migrations\Version20200513162918   | migrated                | 2024-05-16 15:19:29 | 0.099s         |             |
| Mautic\Migrations\Version20200917152259   | migrated                | 2025-01-09 14:43:55 | 0.34s          |             |
| Mautic\Migrations\Version20201019100000   | migrated                | 2025-01-09 14:43:55 | 0.227s         |             |
| Mautic\Migrations\Version20201026101117   | not migrated            |                     |                |             |
| Mautic\Migrations\Version20210112162046   | migrated                | 2025-01-09 14:43:56 | 0.224s         |             |
| Mautic\Migrations\Version20210115065034   | migrated                | 2025-01-09 14:43:56 | 0.253s         |             |
| Mautic\Migrations\Version20210217115150   | migrated                | 2025-01-09 14:43:56 | 0.255s         |             |
| Mautic\Migrations\Version20210420113309   | migrated                | 2025-01-09 14:43:56 | 0.242s         |             |
| Mautic\Migrations\Version20211026152443   | migrated                | 2025-01-09 14:43:57 | 0.195s         |             |
| Mautic\Migrations\Version20211026153057   | migrated                | 2025-01-09 14:43:57 | 0.201s         |             |
| Mautic\Migrations\Version20211110070503   | migrated                | 2025-01-09 14:43:57 | 0.266s         |             |
| Mautic\Migrations\Version20211209022550   | migrated                | 2025-01-09 14:43:57 | 0.149s         |             |
| Mautic\Migrations\Version20220216161028   | migrated                | 2024-05-16 15:19:29 | 0.006s         |             |
| Mautic\Migrations\Version20220429091934   | migrated                | 2024-05-16 15:19:29 | 0.132s         |             |
| Mautic\Migrations\Version20220722074516   | migrated                | 2024-05-16 15:19:29 | 0.128s         |             |
| Mautic\Migrations\Version20221010121758   | migrated                | 2024-05-16 15:19:29 | 0s             |             |
| Mautic\Migrations\Version20221014061125   | migrated                | 2024-05-16 15:19:29 | 0.103s         |             |
| Mautic\Migrations\Version20221014081742   | migrated                | 2024-05-16 15:19:29 | 0.127s         |             |
| Mautic\Migrations\Version20221128145933   | not migrated            |                     |                |             |
| Mautic\Migrations\Version20230131133732   | migrated                | 2024-05-16 15:19:30 | 0.127s         |             |
| Mautic\Migrations\Version20230307083702   | migrated                | 2024-05-16 15:19:30 | 0.002s         |             |
| Mautic\Migrations\Version20230311195347   | migrated                | 2024-05-16 15:19:30 | 0.003s         |             |
| Mautic\Migrations\Version20230321133733   | migrated                | 2024-05-16 15:19:30 | 0.121s         |             |
| Mautic\Migrations\Version20230424083829   | migrated                | 2024-05-16 15:19:30 | 0.131s         |             |
| Mautic\Migrations\Version20230506112314   | migrated                | 2025-01-09 14:43:58 | 0.185s         |             |
| Mautic\Migrations\Version20230506113422   | migrated                | 2025-01-09 14:43:58 | 0.198s         |             |
| Mautic\Migrations\Version20230506113627   | migrated                | 2025-01-09 14:43:58 | 0.214s         |             |
| Mautic\Migrations\Version20230506113731   | migrated                | 2025-01-09 14:43:58 | 0.181s         |             |
| Mautic\Migrations\Version20230506113812   | migrated                | 2025-01-09 14:43:58 | 0.194s         |             |
| Mautic\Migrations\Version20230519154448   | migrated                | 2024-05-16 15:19:30 | 0.138s         |             |
| Mautic\Migrations\Version20230522141144   | not migrated            |                     |                |             |
| Mautic\Migrations\Version20230525202700   | migrated                | 2024-05-16 15:19:30 | 0.002s         |             |
| Mautic\Migrations\Version20230606111852   | not migrated            |                     |                |             |
| Mautic\Migrations\Version20230615101328   | migrated                | 2024-05-16 15:19:30 | 0.001s         |             |
| Mautic\Migrations\Version20230621074925   | migrated                | 2024-05-16 15:19:30 | 0.402s         |             |
| Mautic\Migrations\Version20230627140512   | migrated                | 2025-01-09 14:43:59 | 0.001s         |             |
| Mautic\Migrations\Version20231110103625   | migrated                | 2025-01-09 14:43:59 | 0.09s          |             |
| Mautic\Migrations\Version20231206152313   | migrated                | 2025-01-09 14:43:59 | 5.675s         |             |
| Mautic\Migrations\Version20231207235400   | migrated                | 2025-01-09 14:44:05 | 0.275s         |             |
| Mautic\Migrations\Version20240226114528   | migrated                | 2025-01-09 14:44:05 | 0.53s          |             |
| Mautic\Migrations\Version20240320081612   | migrated                | 2025-01-09 14:44:05 | 0.275s         |             |
| Mautic\Migrations\Version20240416112112   | migrated                | 2025-01-09 14:44:06 | 0.258s         |             |
| Mautic\Migrations\Version20240611103824   | migrated                | 2025-01-09 14:44:06 | 0.215s         |             |
| Mautic\Migrations\Version20240704164714   | migrated                | 2025-01-09 14:44:06 | 0.001s         |             |
| Mautic\Migrations\Version20240708153845   | migrated                | 2025-01-09 14:44:06 | 0.126s         |             |
| Mautic\Migrations\Version20240725105507   | migrated                | 2025-01-09 14:44:06 | 0.003s         |             |
| Mautic\Migrations\Versionzz20230929183000 | not migrated            |                     |                |             |
+-------------------------------------------+-------------------------+---------------------+----------------+-------------+

The commands

php /var/www/html/bin/console doctrine:migrations:status

shows

| Migrations           | Executed             | 97                                                                     |
|                      | Executed Unavailable | 49                                                                     |
|                      | Available            | 53                                                                     |
|                      | New                  | 5                                                                      |

Means that my doctrine has handled 97 migrations in total. Each migration is represented in a PHP class file having an “up” method which does the job. The files are located under docroot/app/migrations. There are 53 files, so these are the “Available” ones from the status. The 49 unavailable are those not represented as a file anymore.
The interesting part are the 5 “New” ones, which means they are not executed now.
Those 5 are the ones show in the doctrine:migrations:list one post above which have the status “not migrated”:

| Mautic\Migrations\Version20201026101117   | not migrated            |                     |                |             |
| Mautic\Migrations\Version20221128145933   | not migrated            |                     |                |             |
| Mautic\Migrations\Version20230522141144   | not migrated            |                     |                |             |
| Mautic\Migrations\Version20230606111852   | not migrated            |                     |                |             |
| Mautic\Migrations\Versionzz20230929183000 | not migrated            |                     |                |             |

The code after the Version filename is simply the datetime string of the appearance. So beside of the last one with that strange “zz” in front, the others are ordered by dateime. The missing ones are in the middle between other migrations.

Also from the doctrine:migrations:status i see

|----------------------------------------------------------------------------------------------------------------------|
| Versions             | Previous             | Mautic\Migrations\Version20240708153845                                |
|                      | Current              | Mautic\Migrations\Version20240725105507                                |
|                      | Next                 | Mautic\Migrations\Version20221128145933                                |
|                      | Latest               | Mautic\Migrations\Versionzz20230929183000                              |
|----------------------------------------------------------------------------------------------------------------------|

The current migration level my schema is upon is “Version20240725105507” and the next migration that would be picked is “Version20221128145933”, which is the second in the list of not applied ones.
The command “doctrine:migrations:migrate” would try to get until the “Latest” one “Versionzz20230929183000”, but that did not seem to work.

So i tried to do it step by step, first call the “Next” migration:

php /var/www/html/bin/console doctrine:migrations:migrate 'Mautic\Migrations\Version20221128145933'

results in

[notice] Migrating up to Mautic\Migrations\Version20221128145933
[notice] Migration Mautic\Migrations\Version20201026101117 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] Migration Mautic\Migrations\Version20221128145933 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] finished in 71.3ms, used 56.5M memory, 2 migrations executed, 0 sql queries

 [OK] Successfully migrated to version: Mautic\Migrations\Version20221128145933

after that, status shows another “Next”

|----------------------------------------------------------------------------------------------------------------------|
| Versions             | Previous             | Mautic\Migrations\Version20240708153845                                |
|                      | Current              | Mautic\Migrations\Version20240725105507                                |
|                      | Next                 | Mautic\Migrations\Version20201026101117                                |
|                      | Latest               | Mautic\Migrations\Versionzz20230929183000                              |
|----------------------------------------------------------------------------------------------------------------------|

Did the same single migration for “Version20201026101117”:

[notice] Migrating up to Mautic\Migrations\Version20201026101117
[notice] Migration Mautic\Migrations\Version20201026101117 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] finished in 42.6ms, used 52.5M memory, 1 migrations executed, 0 sql queries

 [OK] Successfully migrated to version: Mautic\Migrations\Version20201026101117

But now the “Next” did not show a new one, but the same, also the number of “New” did not go down.

|----------------------------------------------------------------------------------------------------------------------|
| Migrations           | Executed             | 97                                                                     |
|                      | Executed Unavailable | 49                                                                     |
|                      | Available            | 53                                                                     |
|                      | New                  | 5                                                                      |
|----------------------------------------------------------------------------------------------------------------------|

I encountered the same issue just yesterday updating to 5.2.1, and it seems the problem lies in how the versions are ordered in the output of:

php bin/console doctrine:migrations:status

The versions appear to be sorted alphabetically rather than numerically. This can cause confusion because the Previous, Current, Next, and Latest tags may not reflect the actual chronological order of the migrations. For example, in my case, the output was:

Previous           | Mautic\Migrations\Version20240708153845  
Current            | Mautic\Migrations\Version20240725105507   
Next               | Mautic\Migrations\Version20201026101117  
Latest             | Mautic\Migrations\Versionzz20230929183000  

Here, Version20201026101117 (a 2020 migration) was marked as Next after a 2024 migration, which clearly shows the issue.

This issue happens because Doctrine sorts the migrations by their version names as strings in alphabetical order instead of by the chronological date embedded in the version name.

So your “Current” version is the real latest.

Interesting, thanks! When i do “doctrince:migrations:migrate” it shows “OK” in the end, and the 5 “new” are the ones shown to be skipped because the schema is already applied. I hoped to get some order in here back again…

When i install Mautic in the latest version with a new database, it would create the latest schema, right? If i then export my old DB and import it there, would that might solve the false-positives?

When i create a new database and run the migrations i get it clean so far:

(docker 6c2dbc27de34):/var/www/html# php bin/console doctrine:migrations:migrate

 WARNING! You are about to execute a migration in database "mautic" that could result in schema changes and data loss. Are you sure you wish to continue? (yes/no) [yes]:
 > yes

[notice] Migrating up to Mautic\Migrations\Versionzz20230929183000
[notice] Migration Mautic\Migrations\Version20190326190241 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] Migration Mautic\Migrations\Version20190410143658 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] Schema includes this migration
[notice] Migration Mautic\Migrations\Version20190524124819 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] Migration Mautic\Migrations\Version20200415135706 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] Migration Mautic\Migrations\Version20200513162918 skipped during Pre-Checks. Reason: "The body_text column has already been added to the email_copies table."
[notice] Migration Mautic\Migrations\Version20201019100000 skipped during Pre-Checks. Reason: "Table emails_draft already exists. Skipping migration"
[notice] Migration Mautic\Migrations\Version20201026101117 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] Migration Mautic\Migrations\Version20210112162046 skipped during Pre-Checks. Reason: "Index `integration_integration_object_name_last_sync_date` already exists. Skipping the migration"
[notice] Migration Mautic\Migrations\Version20210115065034 skipped during Pre-Checks. Reason: "The emails table already includes the preheader_text column"
[notice] Migration Mautic\Migrations\Version20210217115150 skipped during Pre-Checks. Reason: "Deleted column already added in tables"
[notice] Index lead_list_alias already exists
[notice] Migration Mautic\Migrations\Version20210420113309 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] Index idx_object_field_order_is_published already exists
[notice] Migration Mautic\Migrations\Version20211026152443 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] Index idx_frequency_date_added already exists
[notice] Migration Mautic\Migrations\Version20211026153057 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] Column already in BOOLEAN type
[notice] Migration Mautic\Migrations\Version20211110070503 skipped during Pre-Checks. Reason: "Schema includes this migration"
[warning] Migration Mautic\Migrations\Version20211209022550 was executed but did not result in any SQL statements.
[notice] Table contact_export_scheduler already exists
[notice] Migration Mautic\Migrations\Version20220429091934 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] Migration Mautic\Migrations\Version20220722074516 skipped during Pre-Checks. Reason: "The deduplicate column has already been added to the notifications table."
[notice] Migration Mautic\Migrations\Version20221014061125 skipped during Pre-Checks. Reason: "Index webhook_id_date_added already exists"
[notice] Migration Mautic\Migrations\Version20221014081742 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] Migration Mautic\Migrations\Version20221128145933 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] Migration Mautic\Migrations\Version20230131133732 skipped during Pre-Checks. Reason: "The last_built_time column has already been added to the lead_lists table."
[warning] Migration Mautic\Migrations\Version20230311195347 was executed but did not result in any SQL statements.
[notice] Column asset_downloads.utm_campaign already exists
[notice] Column asset_downloads.utm_content already exists
[notice] Column asset_downloads.utm_medium already exists
[notice] Column asset_downloads.utm_source already exists
[notice] Column asset_downloads.utm_term already exists
[notice] Migration Mautic\Migrations\Version20230321133733 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] Migration Mautic\Migrations\Version20230424083829 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] The index "dnc_date_added" has already been added to the table "lead_donotcontact".
[notice] Migration Mautic\Migrations\Version20230506112314 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] The index "stat_dynamic_content_date_sent" has already been added to the table "dynamic_content_stats".
[notice] Migration Mautic\Migrations\Version20230506113422 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] The index "message_queue_date_published" has already been added to the table "message_queue".
[notice] Migration Mautic\Migrations\Version20230506113627 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] The index "lead_stages_change_log_date_added" has already been added to the table "lead_stages_change_log".
[notice] Migration Mautic\Migrations\Version20230506113731 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] The index "utm_date_added" has already been added to the table "lead_utmtags".
[notice] Migration Mautic\Migrations\Version20230506113812 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] Table plugin_crm_pipedrive_owners was already removed
[notice] Migration Mautic\Migrations\Version20230519154448 skipped during Pre-Checks. Reason: "Schema includes this migration"
[warning] Migration Mautic\Migrations\Version20230522141144 was executed but did not result in any SQL statements.
[notice] Migration is not required.
[notice] Migration Mautic\Migrations\Version20230606111852 skipped during Pre-Checks. Reason: "Schema includes this migration"
[warning] Migration Mautic\Migrations\Version20230615101328 was executed but did not result in any SQL statements.
[notice] Table point_groups already exists
[notice] Table point_group_contact_score already exists
[notice] Column points.group_id already exists
[notice] Column point_triggers.group_id already exists
[notice] Column lead_points_change_log.group_id already exists
[notice] Foreign key FK_9D85A703E7A1254A already exists in point_group_contact_score table
[notice] Foreign key FK_9D85A703FE54D947 already exists in point_group_contact_score table
[notice] Foreign key FK_27BA8E29FE54D947 already exists in points table
[notice] Foreign key FK_9CABD32FFE54D947 already exists in point_triggers table
[notice] Foreign key FK_949C2CCCFE54D947 already exists in lead_points_change_log table
[notice] Migration Mautic\Migrations\Version20230621074925 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] Migration Mautic\Migrations\Version20230627140512 skipped during Pre-Checks. Reason: "The deprecated %kernel.root_dir% is unused. Your local.php file is just fine. Skipping the migration."
[notice] 0 record(s) have been updated successfully.
[warning] Migration Mautic\Migrations\Version20231110103625 was executed but did not result in any SQL statements.
[notice] Index stat_email_lead_id_date_sent already exists
[notice] Index stat_email_email_id_is_read already exists
[notice] Migration Mautic\Migrations\Version20231206152313 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] Migration Mautic\Migrations\Version20231207235400 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] Table email_list_excluded already exists
[notice] Foreign key FK_3D3C217BA832C1C9 already exists
[notice] Foreign key FK_3D3C217BB9FC8874 already exists
[notice] Migration Mautic\Migrations\Version20240226114528 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] Column trigger_window already exists
[notice] Migration Mautic\Migrations\Version20240320081612 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] Column version already exists
[notice] Migration Mautic\Migrations\Version20240416112112 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] Column draft_custom_mjml already exists
[notice] Migration Mautic\Migrations\Version20240611103824 skipped during Pre-Checks. Reason: "Schema includes this migration"
[warning] Migration Mautic\Migrations\Version20240708153845 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 1969.8ms, used 58.5M memory, 53 migrations executed, 41 sql queries

 [OK] Successfully migrated to version: Mautic\Migrations\Versionzz20230929183000

Interesting that it shows it migrated to Versionzz2023… but when using “status” it tells “Version20240725105507” is the current.

(docker 6c2dbc27de34):/var/www/html# php bin/console doctrine:migrations:status
+----------------------+----------------------+------------------------------------------------------------------------+
| Configuration                                                                                                        |
+----------------------+----------------------+------------------------------------------------------------------------+
| Storage              | Type                 | Doctrine\Migrations\Metadata\Storage\TableMetadataStorageConfiguration |
|                      | Table Name           | migrations                                                             |
|                      | Column Name          | version                                                                |
|----------------------------------------------------------------------------------------------------------------------|
| Database             | Driver               | Doctrine\DBAL\Driver\PDO\MySQL\Driver                                  |
|                      | Name                 | mautic                                                                 |
|----------------------------------------------------------------------------------------------------------------------|
| Versions             | Previous             | Mautic\Migrations\Version20240708153845                                |
|                      | Current              | Mautic\Migrations\Version20240725105507                                |
|                      | Next                 | Mautic\Migrations\Version20190326190241                                |
|                      | Latest               | Mautic\Migrations\Versionzz20230929183000                              |
|----------------------------------------------------------------------------------------------------------------------|
| Migrations           | Executed             | 15                                                                     |
|                      | Executed Unavailable | 0                                                                      |
|                      | Available            | 53                                                                     |
|                      | New                  | 38                                                                     |
|----------------------------------------------------------------------------------------------------------------------|
| Migration Namespaces | Mautic\Migrations    | /var/www/html/docroot/app/migrations                                   |
+----------------------+----------------------+------------------------------------------------------------------------+

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.