1 #ifndef SQLSTORAGE_BASE_H_
2 #define SQLSTORAGE_BASE_H_
4 #include <boost/filesystem.hpp>
5 #include <boost/interprocess/sync/file_lock.hpp>
6 #include <boost/interprocess/sync/scoped_lock.hpp>
8 #include "libaktualizr/config.h"
11 enum class DbVersion : int32_t { kEmpty = -1, kInvalid = -2 };
29 boost::filesystem::path lock_path;
30 boost::interprocess::file_lock fl_;
35 explicit SQLStorageBase(boost::filesystem::path sqldb_path,
bool readonly, std::vector<std::string> schema_migrations,
36 std::vector<std::string> schema_rollback_migrations, std::string current_schema,
37 int current_schema_version);
39 std::string getTableSchemaFromDb(
const std::string &tablename);
40 bool dbMigrateForward(
int version_from,
int version_to = 0);
41 bool dbMigrateBackward(
int version_from,
int version_to = 0);
43 DbVersion getVersion();
44 boost::filesystem::path dbPath()
const;
47 boost::filesystem::path sqldb_path_;
48 bool readonly_{
false};
51 std::shared_ptr<std::mutex> mutex_;
53 const std::vector<std::string> schema_migrations_;
54 std::vector<std::string> schema_rollback_migrations_;
55 const std::string current_schema_;
56 const int current_schema_version_;
59 bool dbInsertBackMigrations(
SQLite3Guard &db,
int version_latest);
62 #endif // SQLSTORAGE_BASE_H_