How To Migrate

How to Migrate

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.

The Dilemma

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?

The Solution: Migrate

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?

  1. Locate and open booklink_installer.php for editing in your favorite text editor.
  2. At the bottom of the file notice the last bracket ” } ”.
  3. Just before that bracket, place this text:
    • function up_2(){
        $this->addColumn('books','pages');
      }
      function down_2(){
        $this->removeColumn('books','pages');
      }
  4. Save and close the booklink_installer.php file.
  5. Run this script:
    ./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. ;-)

 
how-to-migrate.txt · Last modified: 2007/12/08 00:53 by 72.10.14.106
 

The Akelos Framework was created by Bermi Ferrer and other contributors.
Potions of the code and documentation have been ported from Ruby on Rails.

The Akelos Framework is released under the LGPL license.

"Akelos", "Akelos Framework", and the Akelos logo are trademarks of Bermi Labs All rights reserved.

Wiki driven by DokuWiki