ArchangelSDY / QtDBMigration

Simple Database Migration for Qt

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

QtDBMigration

Simple Database Migration for Qt.

Example

Config file:

{
    "schemaVersions": [
        {
            "version": 0,
            "applySql": "create table table1(id integer)",
            "revertSql": "drop table table1"
        },
        {
            "version": 1,
            "applySql": "create table table2(id integer)",
            "revertSql": "drop table table2"
        }
    ]
}

Apply migration:

QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName("test.db");
if (db.open()) {
    QtDBMigration mig("./config.json");
    mig.migrate();  // Database will be at latest version
    mig.migrate(0); // Database will be at version 0
}

License

MIT

About

Simple Database Migration for Qt


Languages

Language:C++ 90.2%Language:CMake 5.4%Language:QMake 4.4%