\documentclass{article}
\usepackage{ulem}
\usepackage{graphicx}
\usepackage{hyperref}
\pagestyle{headings}
\begin{document}
\part{Migration Mechanism}
When you take your application to a new revision, you may whish to change your SQL database schema. Tables may be added or removed and columns in a table may be added or removed. For this, horde provides the migration mechanism.

\part{Files}
Files under \texttt{<appname>/migration/} control the migration process. File naming follows the pattern \texttt{<n>\_<appname>\_[base|upgrade]\_<name>.php} with \texttt{n} being a decimal number and \texttt{name} an arbitrary name.

Inside the file there is a class defined which must be called \texttt{<Appname>[Base|Upgrade]<Name>} where \texttt{Name} matches the one used for file naming. Note that the file name is all lowercase and the class name is ``<a href="https://wiki.horde.org/CamelCase">CamelCase</a>``.

It appears that the \texttt{[base|upgrade]} part in the name is just a convention that will not be enforced. Still, the horde applications all seem to make use of it.

The class may define an "up" method for upgrading and a "down" method for downgrading the application. The methods may implement practically any necessary action. For instance, the down method may drop a database table when the application is to be removed from the system. For implementation of the methods feel free to steal code from one of the existing horde applications.

\part{Usage}
\section{Admin Console}
When you use the admin console, horde determines if the revision number of your application matches the highest number of migration files found. If not, the console notifies you ("DB schema needs update") and lets you trigger the migration process with the click of a button. All migration files with numbers between the current revision and the highest number found in a file name will the be considered and the up-methods of those files will be called. The revision number of your application will be set accordingly. Note that this revision number is not the same as the version number of your application defined in \texttt{<application>/lib/Application.php}.

\section{CLI Tool}
Alternatively, you may run the CLI script \texttt{horde-db-migrate}, which should already be in your shell search path. The CLI tool is especially useful for running a migration script repeatedly (such as during development) as horde will not notice a change in a migration file. The CLI tool also lets you set your database schema to a defined revision number.

\end{document}
