Database Migration
==================

We support database migration from H2 to mysql or mariadb.

See :ref:`db` for more information about CodeScene database configuration.


Prerequisites
----------------------------

- MySQL/MariaDB client - version 5.7.x

  * in particular, we don't support `mysqldump` versions that require using `--column-statistics=0` (although you can still try to modify the script manually)
- Working network connection between CodeScene and your MySQL server (check your **firewall rules**)
- A database user with `SUPER` privilege to create the `STRINGDECODE` function required by regular CodeScene db migrations

  * In some environments, such as `Azure Database for MySQL <https://docs.microsoft.com/en-us/azure/mysql/>`_, a user with `SUPER` privilege might not be available. In that case, you need to enable the `log_bin_trust_function_creators` server parameter (see https://docs.microsoft.com/en-us/azure/mysql/howto-server-parameters). 


Migration script
----------------------------

This if a full migration script for automating the import from H2 to MySQL.

**Please stop CodeScene before doing the migration**.

After the script completes successfully, you should see the standard CodeScene login page
and be able to log in using your existing CodeScene account(s).

.. include:: migrate-database.h2-to-mysql.sh
   :literal:

