logic: add name delimiter to NameHierarchy
* NameHierarchy now looks like this: <delimiter>\tm<all the rest> * made new baseclasses for SettingsMigration and SettingsMigrator * Use the migration system for SqliteBookmarkStorage as well
This commit is contained in:
@@ -3,8 +3,10 @@
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/utility.h"
|
||||
#include "utility/utilityString.h"
|
||||
#include "data/SqliteStorageMigrationLambda.h"
|
||||
#include "data/SqliteStorageMigrator.h"
|
||||
|
||||
const size_t SqliteBookmarkStorage::s_storageVersion = 1;
|
||||
const size_t SqliteBookmarkStorage::s_storageVersion = 2;
|
||||
|
||||
SqliteBookmarkStorage::SqliteBookmarkStorage(const FilePath& dbFilePath)
|
||||
: SqliteStorage(dbFilePath)
|
||||
@@ -15,6 +17,24 @@ SqliteBookmarkStorage::~SqliteBookmarkStorage()
|
||||
{
|
||||
}
|
||||
|
||||
size_t SqliteBookmarkStorage::getStaticVersion() const
|
||||
{
|
||||
return s_storageVersion;
|
||||
}
|
||||
|
||||
void SqliteBookmarkStorage::migrateIfNecessary()
|
||||
{
|
||||
SqliteStorageMigrator migrator;
|
||||
|
||||
migrator.addMigration(2, std::make_shared<SqliteStorageMigrationLambda>([](const SqliteStorageMigration* migration, SqliteStorage* storage){
|
||||
migration->executeStatementInStorage(storage, "UPDATE bookmarked_node SET serialized_node_name = '::\tm' || serialized_node_name");
|
||||
migration->executeStatementInStorage(storage, "UPDATE bookmarked_edge SET serialized_source_node_name = '::\tm' || serialized_source_node_name");
|
||||
migration->executeStatementInStorage(storage, "UPDATE bookmarked_edge SET serialized_target_node_name = '::\tm' || serialized_target_node_name");
|
||||
}));
|
||||
|
||||
bool migrated = migrator.migrate(this, SqliteBookmarkStorage::s_storageVersion);
|
||||
}
|
||||
|
||||
Id SqliteBookmarkStorage::addBookmarkCategory(const std::string& name)
|
||||
{
|
||||
std::string statement = "INSERT INTO bookmark_category(id, name) "
|
||||
@@ -34,7 +54,6 @@ Id SqliteBookmarkStorage::addBookmark(const std::string& name, const std::string
|
||||
std::string statement = "INSERT INTO bookmark(id, name, comment, timestamp, category_id) "
|
||||
"VALUES (NULL, ?, ?, ?, " + std::to_string(categoryId) + ");";
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
CppSQLite3Statement stmt = m_database.compileStatement(statement.c_str());
|
||||
@@ -128,11 +147,6 @@ void SqliteBookmarkStorage::removeBookmarkCategory(Id id)
|
||||
);
|
||||
}
|
||||
|
||||
size_t SqliteBookmarkStorage::getStaticStorageVersion() const
|
||||
{
|
||||
return s_storageVersion;
|
||||
}
|
||||
|
||||
std::vector<std::pair<int, SqliteDatabaseIndex>> SqliteBookmarkStorage::getIndices() const
|
||||
{
|
||||
return std::vector<std::pair<int, SqliteDatabaseIndex>>();
|
||||
|
||||
Reference in New Issue
Block a user