defuze.me  Client
Public Member Functions
DB::Migration Class Reference

This is the superclass used to define migration to be done on the database. More...

#include <migration.hpp>

List of all members.

Public Member Functions

 Migration (const char *)
virtual void up ()=0
 The up() method is automatically called by the Migration engine to do the migration.
virtual void down ()=0
 The down() method can be called by the Migration engine to undo the migration.
const QString & name ()
bool run (bool forward=true)
 This method will run the up() or down() method depending on the argument it will also wrap the migration into a SQL transaction and throw on errors.
bool exec (const QString sql)
 Next function are helper methods to build your migrations.
bool createTable (const QString name, const QString definition)
bool dropTable (const QString name)

Detailed Description

This is the superclass used to define migration to be done on the database.

Create a subclass in the migrations folder, and fill the up and down methods. Then add your subclass to the global migrations list (migration_list.hpp). You also need to add your migration to the load list (migration.cpp)

Migration number is stored and represent the position BETWEEN migrations It is used as parameter of migrate, migrateFrom and undoFrom methods.

Migration number: 0 -------------- 1 -------------- 2 -------------- 3 ------ Migrations: | Settings | Configurations | ... | ...

Definition at line 36 of file migration.hpp.


Member Function Documentation

virtual void DB::Migration::down ( ) [pure virtual]

The down() method can be called by the Migration engine to undo the migration.

Put inside this method the oposite changes of your up() method. return false if you want to cancel the migration

bool Migration::exec ( const QString  sql)

Next function are helper methods to build your migrations.

they make the syntax shorter and allow a better errors handling

Definition at line 55 of file migration.cpp.

virtual void DB::Migration::up ( ) [pure virtual]

The up() method is automatically called by the Migration engine to do the migration.

Put inside this method all the database changes you want. return false if you want to cancel the migration


The documentation for this class was generated from the following files: