Documentation

Usage

For using this add-on, install it before you move your site or its database. You can migrate the database in few different ways:

  1. Setup your local development environment's database server to case sensitive mode and run the migration
  2. Do a local backup of your database through the concrete5 backup functionality and migrate the backup files
  3. Download an SQL migration script and run it on the server where you're moving the site

After installing the package you can find the functionality under System & Settings => Backup & Restore => Database Migration.

1. Setup your local development environment's database server to case sensitive mode

Here's how to do the first option:

  • At the end of the of your MySQL server's configuration file (my.ini or my.cnf), add a line with "lower_case_table_names=0"
  • Restart the MySQL process
  • Go to the Database Migration tab
  • Click "Run Migration"

If your site stopped working at this point, revert the MySQL configuration back and do the 2nd or 3rd option.

There's also functionality available that allows you to do the migration automatically during any page load. However, this should only be run ONCE. To do this, follow these steps:

  • Install the add-on
  • In your site.php, add line: define('DB_CASE_SENSITIVITY_FIX', true);
  • Load any page on your site
  • Remove the newly added line from site.php

If this does not work either, move to the 2nd or 3rd option.

2. Migrate the backup files

If you want to easily migrate the site backup files to have the corret database table names, just click the "Migrate Backup Files" link. Before you can do this, you need to have at least one backup file available at the Backup & Restore section.

After you've successfully migrated the backup files, you can just go back to the Backup & Restore section and download the backup file you want to move to another server.

3. Download the SQL migration script

For an easy migration, just download the migration script from development server and run it on the server where you're moving the site to. To do this, follow these steps:

  • Go to the Database Migration tab
  • Click "Download Migration Script"
  • Move the script to your server and run it there

This is how you run the script on your server from console:

mysql -h MYSQL_HOST -u MYSQL_USER -p MYSQL_DATABASE < MIGRATION_SCRIPT.sql

Where:

  • MYSQL_HOST = your MySQL server's address (e.g. localhost)
  • MYSQL_USER = your MySQL user name
  • MYSQL_DATABASE = your MySQL database name
  • MIGRATION_SCRIPT = the name of the downloaded migration script

After entering this command the console will still ask password for your MySQL user.

Adding custom tables to migration

If the database migration does not include all the tables you need to migrate, just create a new package to include the rest or add few lines of code to existing packages.

To add custom tables to the migration add the following function to the package's controller from which you want to control the custom tables:

public function getDatabaseSpecialTables() {
	return array("MyCorrectTableName", "MyAnotherCorrectTableName");
}

The migration script will automatically go these through for each installed package, so these few lines are the only thing you need to worry about.