summaryrefslogtreecommitdiffstats
path: root/src/library/schemamanager.h
blob: 3997a6c95b3ebb19fe045933ce0587458945863f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// schemamanager.h
// Created 12/29/2009 by RJ Ryan (rryan@mit.edu)

#ifndef SCHEMAMANAGER_H
#define SCHEMAMANAGER_H

#include <QtSql>

#include "preferences/usersettings.h"
#include "library/dao/settingsdao.h"

class SchemaManager {
  public:
    enum Result {
        RESULT_OK,
        RESULT_BACKWARDS_INCOMPATIBLE,
        RESULT_UPGRADE_FAILED,
        RESULT_SCHEMA_ERROR
    };

    static Result upgradeToSchemaVersion(const QString& schemaFilename,
                                         QSqlDatabase& db, const int targetVersion);

    static const QString SETTINGS_VERSION_STRING;
    static const QString SETTINGS_MINCOMPATIBLE_STRING;

  private:
    static bool isBackwardsCompatible(SettingsDAO& settings,
                                      int currentVersion,
                                      int targetVersion);
    static int getCurrentSchemaVersion(SettingsDAO& settings);
};

#endif /* SCHEMAMANAGER_H */