Skip to content

Commit

Permalink
Merge pull request #402 from jonte/fix_schema_7
Browse files Browse the repository at this point in the history
Database: Bump schema to version 7
  • Loading branch information
rocketman768 authored Feb 28, 2018
2 parents 5057f80 + 7751080 commit 5147543
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
17 changes: 16 additions & 1 deletion src/DatabaseSchemaHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <QDebug>
#include <QSqlError>

const int DatabaseSchemaHelper::dbVersion = 6;
const int DatabaseSchemaHelper::dbVersion = 7;

// Commands and keywords
QString DatabaseSchemaHelper::CREATETABLE("CREATE TABLE");
Expand Down Expand Up @@ -460,6 +460,9 @@ bool DatabaseSchemaHelper::migrateNext(int oldVersion, QSqlDatabase db)
case 5:
ret &= migrate_to_6(q);
break;
case 6:
ret &= migrate_to_7(q);
break;
default:
Brewtarget::logE(QString("Unknown version %1").arg(oldVersion));
return false;
Expand Down Expand Up @@ -1559,3 +1562,15 @@ bool DatabaseSchemaHelper::migrate_to_6(QSqlQuery q) {

return ret;
}

bool DatabaseSchemaHelper::migrate_to_7(QSqlQuery q) {
bool ret = true;

// Add "attenuation" to brewnote table
ret &= q.exec(
ALTERTABLE + SEP + tableBrewnote + SEP +
ADDCOLUMN + SEP + "attenuation" + SEP + TYPEREAL + SEP + DEFAULT + SEP + "0.0"
);

return ret;
}
2 changes: 1 addition & 1 deletion src/DatabaseSchemaHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -429,5 +429,5 @@ class DatabaseSchemaHelper
static bool migrate_to_4(QSqlQuery q);
static bool migrate_to_5(QSqlQuery q);
static bool migrate_to_6(QSqlQuery q);

static bool migrate_to_7(QSqlQuery q);
};

0 comments on commit 5147543

Please sign in to comment.