Running Migrations

When packages or upgrades are installed, all migrations are automatically checked and any necessary ones installed. However, at times you may need to manually run the migrations as well. You may easily scan all packages and execute all pending migrations with the command:

apex migration migrate

This will scan the /etc/PACKAGE/Migrations/ directory of all installed packages, and check the available migrations against the list of installed migrations. Any necessary migrations will be automatically installed, bringing the database structure up to date.

If you wish to only install migrations for a specific package, you may add the --package flag to the above command such as:

apex migration migrate --package my-package

This will do the same as above, but only for the package specified.

Run Initial Package Migration

You may run the initial package migration located at /etc/PACKAGE/migrate.php / install.sql for a package with the command:

apex migration install my-package

Alternatively, if you wish to first remove the initial package migration than re-install it, simply add the -r option to the above command, such as:

apex migration install my-package -r

This will first execute the remove() method within the migrate.php script, which generally executes all SQL code within the remove.sql file, and should remove all created database tables. Afterwards, it will run the install() method and re-install the migration from a blank slate.