Migrate to PostgreSQL server

Support for MySQL/MariaDB will be dropped in Zammad 7.0 upwards. Make sure to migrate your existing instance of Zammad to PostgreSQL.

The following guide will provide you with a rough direction through that migration process.

Note

🤓 Zammad version requirement ahead

Below commands will only work with Zammad 5.3.0 or higher. Please make sure to update the latest (MySQL supported) version first.

Warning

Proof of concept ahead

As the technical details may differ from system to system, this guide comes without any warranty. Please proceed at your own risk. In doubt please refer to the documentation of the tools used.

Preparation

  1. Stop Zammad:

    $ systemctl stop zammad
    
  2. Create a backup of your instance.

Install PostgreSQL

$ apt update
$ apt install postgresql postgresql-contrib
$ systemctl start postgresql
$ systemctl enable postgresql

Please also have a look at Configure Database server.

Nothing to do, continue with the next step. 🎉

Install pgloader

$ apt update
$ apt install pgloader

Create pgloader command file

Create a command file for pgloader with:

$ zammad run rake zammad:db:pgloader > /tmp/pgloader-command

Afterwards, you need to tweak the created file with the correct URL of the target PostgreSQL server.

-- Adjust the PostgreSQL URL below to correct value before executing this command file.
INTO pgsql://zammad:pgsql_password@localhost/zammad

You will at least need to replace psql_password placeholder in the provided example.

Verify the rest of the MySQL credentials in the command file, they should reflect the configuration of your current environment.

Database Credentials

Adjust the configuration file to fill in the credentials for your new PostgreSQL server. Use postgresql as adapter.

Tip

🤓 For easiest usage …

If you provide your Zammad user with database creation permission, you can run db:create in the following section. If you don’t want that, you’ll have to create the database manually.

Create empty database

Now you need to create an empty database in PostgreSQL.

$ zammad run rake db:create

Migrate

You can check your configuration by running pgloader in a dry run first:

$ pgloader --dry-run /tmp/pgloader-command

Finishing

After the migration has completed, you’ll better clear some cache files:

$ zammad run rails r 'Rails.cache.clear'
$ systemctl start zammad