Introduction

This is the ability to have multiple databases and keep them in sync. It is very common for there to be more then one database and/or schemas within a database and they need to be versioned together in order to be of value to an application.

This means that if for instance you have an application database and an admin database for instance, that the application database must be of at least version 3 for the admin database to be at version 1. Thus it will check the current version of the application database, upgrade it if needed to version 3, and then come back and upgrade the admin database to version 1. And if for any reason the application database is downgraded to version 2, it will first go and downgrade the admin database from 1 to 0 and then downgrade the application database to version 2.

Configuration

In order to configure a schema to be dependent upon another schema, add the following section to the migrations.xml.

  <orders>
    <order schema="schema" version="version">
      <depend schema="dependant-schema" version="dependant-schema-version" />
    </order>
  </orders>

Lets take an example that comes packaged with the application.

  <orders>
    <order schema="blog" version="1">
      <depend schema="core" version="1" />
    </order>
    <order schema="blog" version="3">
      <depend schema="core" version="2" />
    </order>
    <order schema="forum" version="1">
      <depend schema="core" version="2" />
    </order>
    <order schema="admin" version="1">
      <depend schema="core" version="2" />
      <depend schema="blog" version="1" />
      <depend schema="forum" version="1" />
    </order>
  </orders>

In this example, in order to migrate the admin tool from version 0 to 2, it would first go and verify that core is at version 2. It looking at core it sees that core has no dependencies and will upgrade the core to version 2 if it is not at least that high already. Then it will make sure blog is of at least version 1 which will in turn verify that core is of at least version 1. Then finally it will bring the forum to version 1 if not already at least that high before finally upgrading the admin tool from version 0 to 1. And then proceeding from there to bump it up to version 2 seeing no further dependencies needed.