defuze.me
Client
|
This is the superclass used to define migration to be done on the database. More...
#include <migration.hpp>
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) |
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.
virtual void DB::Migration::down | ( | ) | [pure virtual] |
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] |