Guide to upgrading from v4 to v5 on Docker?

My Mautic version is: 4.1.11
My PHP version is: 7.4.33
My Database type and version is: 5.7.44

Your problem
I have a docker installation based on mautic:v4. I want to upgrade it to v5 and I was wondering if there’s a guide on how to make this upgrade.

Thanks,

1 Like

So I couldn’t find any step-by-step guide to performing this upgrade so I’m trying to figure it out on my own.

So far what I got is this:

The files that should survive the container life-cycle are those inside the directories:

  • media/files
  • media/images
  • media/dashboards

Plus the file app/config/local.php.

If you know of any other important user file please let me know (I’m kind of new to Mautic).

So, my idea was to change my docker-compose.yml to reflect this situation instead of mounting the whole /var/www/html directory which will get overwritten by the new version anyway…

Next step: change the image from mautic/mautic:v4 to mautic/mautic:5.0.3-apache and to mysql:8.0 for the database.

Then bring the services up and load a pre-existing database dump in the new container.

Right after that, bring the db up to date with the command php bin/console mautic:update:apply --finish.

I got this far but I got stuck on this error I can’t make sense of:

[error] Migration Mautic\Migrations\Version20230522141144 failed during Pre-Checks. Error: "Unknown column type "json_array" requested. Any Doctrine type that you use has to be registered with \Doctrine\DBAL\Types\Type::addType(). You can get a list of all the known types with \Doctrine\DBAL\Types\Type::getTypesMap(). If this error occurs during database introspection then you might have forgotten to register all database types for a Doctrine Type. Use AbstractPlatform#registerDoctrineTypeMapping() or have your custom types implement Type#getMappedDatabaseTypes(). If the type name is empty you might have a problem with the cache or forgot some mapping information."

In Exception.php line 115:
                                                                                                                                                                                                                                             
  Unknown column type "json_array" requested. Any Doctrine type that you use has to be registered with \Doctrine\DBAL\Types\Type::addType(). You can get a list of all the known types with \Doctrine\DBAL\Types\Type::getTypesMap(). If th  
  is error occurs during database introspection then you might have forgotten to register all database types for a Doctrine Type. Use AbstractPlatform#registerDoctrineTypeMapping() or have your custom types implement Type#getMappedData  
  baseTypes(). If the type name is empty you might have a problem with the cache or forgot some mapping information.

Any pointer here will be highly appreciated.

Thanks!

1 Like

Hey everyone. After a long list of unsuccesful experiments I think I have somewhat of a recipe for this upgrade.

What I did:

  1. Clone the repository locally
  2. Took a dump of my prod database (v4)
  3. Made a copy of my server configuration (docker cp mautic.ssl:/var/www/html/app/config/local.php)
  4. Copy the file from the server to my local
  5. Brought the services up using the basic example (docker-compose -f examples/basic/docker-compose.yml up)
  6. Imported the production database into the local container (docker-compose -f examples/basic/docker-compose.yml exec -T db mysql -u mautic_db_user -pmautic_db_pwd mautic_db < mautic.dump.sql)
  7. Run the migrations from within the local container (docker-compose -f examples/basic/docker-compose.yml exec php bin/console mautic:update:apply --finish)
  8. Adjusted the local config
    8.1 Replaced the prod URL with localhost
    8.2 Replaced the v4 directories (app/* for the structure used in v5)
    8.3 Added localhost as trusted_host

After this I was able to visit my local site and have version 5.0.3 working.

I didn’t copy my files nor dashboards but I believe that had I done that it would have worked.

I hope this helps. Haven’t done the full migration in prod, I hope I get to do it soon.

Regards,

2 Likes

Hi, can you confirmed that this works?
I am new to Mautic and am having an issue with the database not persisting when I update the mautic web container.

I have a separate container for mariadb.

And want to persist the local.php, media files and database.

But every time, it tries to run the setup page on deploy.

HEre is my compose file for mautic:

version: ‘3.8’

services:
rabbitmq:
image: rabbitmq:3
container_name: rabbitmq.kbb-mautic-docker
environment:
- RABBITMQ_DEFAULT_VHOST=${RABBITMQ_DEFAULT_VHOST}
volumes:
- rabbitmq-data:/var/lib/rabbitmq
networks:
- a0scg4s

mautic_web:
image: mautic/mautic
container_name: mautic_web.kbb-mautic-docker
ports:
- 8003:80
volumes:
- ./mautic/config:/var/www/html/config:z
- ./mautic/logs:/var/www/html/var/logs:z
- ./mautic/media/files:/var/www/html/docroot/media/files:z
- ./mautic/media/images:/var/www/html/docroot/media/images:z
- ./cron:/opt/mautic/cron:z
- mautic-certificates:/etc/letsencrypt # Ensure certificates are persistent
- mautic-config:/var/www/html/app/config # Ensure configuration is persistent
environment:
- DOCKER_MAUTIC_LOAD_TEST_DATA=${DOCKER_MAUTIC_LOAD_TEST_DATA}
- DOCKER_MAUTIC_RUN_MIGRATIONS=${DOCKER_MAUTIC_RUN_MIGRATIONS}
- MAUTIC_DB_HOST=db-a0scg4s
- MAUTIC_DB_PORT=3306
- MAUTIC_DB_NAME=${MAUTIC_DB_NAME}
- MAUTIC_DB_USER=${MAUTIC_DB_USER}
- MAUTIC_DB_PASSWORD=${MAUTIC_DB_PASSWORD}
healthcheck:
test: [“CMD-SHELL”, “curl -f http://localhost || exit 1”]
start_period: 30s
interval: 30s
timeout: 10s
retries: 3
networks:
- a0scg4s

mautic_cron:
image: mautic/mautic
container_name: mautic_cron.kbb-mautic-docker
volumes:
- ./mautic/config:/var/www/html/config:z
- ./mautic/logs:/var/www/html/var/logs:z
- ./mautic/media/files:/var/www/html/docroot/media/files:z
- ./mautic/media/images:/var/www/html/docroot/media/images:z
- ./cron:/opt/mautic/cron:z
- mautic-config:/var/www/html/app/config # Ensure configuration is persistent
environment:
- DOCKER_MAUTIC_ROLE=mautic_cron
- MAUTIC_DB_HOST=db-a0scg4s
- MAUTIC_DB_PORT=3306
- MAUTIC_DB_NAME=${MAUTIC_DB_NAME}
- MAUTIC_DB_USER=${MAUTIC_DB_USER}
- MAUTIC_DB_PASSWORD=${MAUTIC_DB_PASSWORD}
depends_on:
mautic_web:
condition: service_healthy
networks:
- a0scg4s

mautic_worker:
image: mautic/mautic
container_name: mautic_worker.kbb-mautic-docker
volumes:
- ./mautic/config:/var/www/html/config:z
- ./mautic/logs:/var/www/html/var/logs:z
- ./mautic/media/files:/var/www/html/docroot/media/files:z
- ./mautic/media/images:/var/www/html/docroot/media/images:z
- ./cron:/opt/mautic/cron:z
- mautic-config:/var/www/html/app/config # Ensure configuration is persistent
environment:
- DOCKER_MAUTIC_ROLE=mautic_worker
- MAUTIC_DB_HOST=db-a0scg4s
- MAUTIC_DB_PORT=3306
- MAUTIC_DB_NAME=${MAUTIC_DB_NAME}
- MAUTIC_DB_USER=${MAUTIC_DB_USER}
- MAUTIC_DB_PASSWORD=${MAUTIC_DB_PASSWORD}
depends_on:
mautic_web:
condition: service_healthy
networks:
- a0scg4s

volumes:
rabbitmq-data:
mautic-certificates:
mautic-config:

networks:
a0scg4s:
external: true