Splitting tables or apps across databases

In order to scale at some point it might make sense to split out some tables or apps which allow it as they might be better off with a different replication methods, etc.

A first attempt we do right now with the activity table. In order to make use of this, the app/table needs to match the following criteria:

In case of the activity app the prefix is activity_. If a database config is not specified it falls back to the normal database configuration option for this value:

Initial splitting

For the initial split the affected tables have to be copied over to the new database, in case of the activity app these are:

  1. Enable maintenance mode

  2. Make sure optional database changes are applied:

    1. occ db:convert-mysql-charset

    2. occ db:convert-filecache-bigint

    3. occ db:add-missing-columns

    4. occ db:add-missing-indices

    5. occ db:add-missing-primary-keys

  3. Specify the desired configuration values

  4. Copy the 2 tables to the new database

  5. Disable maintenance mode

Migrations on updates

We will try to avoid migrations on those tables in the future, but it might be necessary at some point. We hope to have a dedicated plan by the time this happens. For now a potential way would be:

  1. Enable maintenance mode

  2. Update as usual

  3. Execute manual queries for schema changes provided by the app authors

  4. Execute manual queries for data changes provided by the app authors

  5. Disable maintenance mode