This page describes how to migrate to and from various versions of your schema within Akelos. This is not a guide on how to migrate *to* Akelos from another framework.
Let's say that you've got your Booklink application up and running, and are fairly happy with it, but you would like to add one thing: a special field for the number of pages in the book. You already have over 50 books in the database, and you don't really want uninstall and reinstall the database, as that would remove all of the existing books.
What do you do?
Adding or removing columns from an existing table is not that hard really. Remember creating app/installers/booklink_installer.php? We're going to need to modify that file again, and run a script to update our schema. Ready?
function up_2(){
$this->addColumn('books','pages');
}
function down_2(){
$this->removeColumn('books','pages');
}
./script/migrate Booklink install 2
The above code means “install to version two”. If you just want to upgrade to the most recent version, do a simple
./script/migrate Booklink install
You may need to regenerate your Book scaffolding by running the following:
./script/generate scaffold Book
To downgrade to version one, use this code:
./script/migrate Booklink uninstall 1
The above code means “uninstall to version one”.
Using migrate keeps your existing data safe, and allows a trackable way to upgrade and downgrade.
That's it! Thanks for tuning in.