defuze.me
Client
|
00001 /************************************************************************** 00002 ** defuze.me Epitech Innovative Project 00003 ** 00004 ** Copyright 2010 00005 ** Athena Calmettes - Jocelyn De La Rosa - Francois Gaillard 00006 ** Adrien Jarthon - Alexandre Moore - Luc Peres - Arnaud Sellier 00007 ** 00008 ** All rights reserved. 00009 **************************************************************************/ 00010 00011 #ifndef MIGRATION_HPP 00012 #define MIGRATION_HPP 00013 00014 #include <QList> 00015 #include <QString> 00016 #include <QSqlQuery> 00017 #include <QSqlError> 00018 #include <QDebug> 00019 #include <QVariant> 00020 00021 namespace DB 00022 { 00023 class DBCore; 00024 00036 class Migration 00037 { 00038 public: 00039 Migration(const char*); 00040 virtual ~Migration(); 00046 virtual void up() = 0; 00052 virtual void down() = 0; 00053 const QString& name(); 00057 bool run(bool forward = true); 00058 00062 bool exec(const QString sql); 00063 bool createTable(const QString name, const QString definition); 00064 bool dropTable(const QString name); 00065 00066 private: 00067 const QString _name; 00068 }; 00069 00070 class MigrationEngine 00071 { 00072 public: 00073 MigrationEngine(DBCore& dbCore); 00074 ~MigrationEngine(); 00075 bool migrate(int from, int to); 00076 bool migrate(int to); 00077 bool migrate(); 00078 bool undo(); 00079 int migrationsCount(); 00080 private: 00081 QList<Migration*> migrations; 00082 DBCore& db; 00083 }; 00084 } 00085 00086 #endif // MIGRATION_HPP