core: Track upgrade step within schema version
[quassel.git] / src / core / sqlitestorage.h
index 5d396ad..4a33bfc 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005-2018 by the Quassel Project                        *
+ *   Copyright (C) 2005-2019 by the Quassel Project                        *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
@@ -121,15 +121,37 @@ public slots:
 
     /* Sysident handling */
     QMap<UserId, QString> getAllAuthUserNames() override;
-    QString getAuthUserName(UserId user) override;
 
 protected:
-    void setConnectionProperties(const QVariantMap & /* properties */)  override {}
+    void setConnectionProperties(const QVariantMap &properties,
+                                 const QProcessEnvironment &environment,
+                                 bool loadFromEnvironment) override {
+        Q_UNUSED(properties);
+        Q_UNUSED(environment);
+        Q_UNUSED(loadFromEnvironment);
+    }
+    // SQLite does not have any connection properties to set
     QString driverName()  override { return "QSQLITE"; }
     QString databaseName()  override { return backlogFile(); }
     int installedSchemaVersion() override;
-    bool updateSchemaVersion(int newVersion) override;
+    bool updateSchemaVersion(int newVersion, bool clearUpgradeStep) override;
     bool setupSchemaVersion(int version) override;
+
+    /**
+     * Gets the last successful schema upgrade step, or an empty string if no upgrade is in progress
+     *
+     * @return Filename of last successful schema upgrade query, or empty string if not upgrading
+     */
+    QString schemaVersionUpgradeStep() override;
+
+    /**
+     * Sets the last successful schema upgrade step
+     *
+     * @param upgradeQuery  The filename of the last successful schema upgrade query
+     * @return True if successfully set, otherwise false
+     */
+    virtual bool setSchemaVersionUpgradeStep(QString upgradeQuery) override;
+
     bool safeExec(QSqlQuery &query, int retryCount = 0);
 
 private:
@@ -168,7 +190,7 @@ public:
 
     bool prepareQuery(MigrationObject mo) override;
 
-    int stepSize() { return 50000; }
+    qint64 stepSize() { return 50000; }
 
 protected:
     bool transaction()  override { return logDb().transaction(); }
@@ -177,7 +199,7 @@ protected:
 
 private:
     void setMaxId(MigrationObject mo);
-    int _maxId;
+    qint64 _maxId;
 };