implement remaining logic
Signed-off-by: Folling <mail@folling.io>
This commit is contained in:
parent
e1bf97704a
commit
1ce811d566
41 changed files with 1393 additions and 408 deletions
40
src/persistence/migrations.hpp
Normal file
40
src/persistence/migrations.hpp
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
#pragma once
|
||||
|
||||
#include <array>
|
||||
|
||||
#include <cppbase/assets.hpp>
|
||||
#include <cppbase/result.hpp>
|
||||
|
||||
#include <sqlitecpp/connection.hpp>
|
||||
|
||||
namespace ikarus {
|
||||
CPPBASE_ASSET(m1_initial_layout, "persistence/migrations/m1_initial_layout.sql");
|
||||
|
||||
class Migration : public sqlitecpp::Migration {
|
||||
public:
|
||||
Migration(char const * sql, size_t size):
|
||||
sql{sql, size} {}
|
||||
|
||||
~Migration() override = default;
|
||||
|
||||
public:
|
||||
[[nodiscard]] inline auto get_content() const -> std::string_view override {
|
||||
return sql;
|
||||
}
|
||||
|
||||
public:
|
||||
std::string_view sql;
|
||||
};
|
||||
|
||||
#define DECLARE_MIGRATION(name) std::make_unique<ikarus::Migration>(static_cast<char const *>(name()), name##_size())
|
||||
|
||||
constexpr std::string_view DB_VERSION_KEY = "IKARUS_DB_VERSION";
|
||||
std::vector<std::unique_ptr<sqlitecpp::Migration>> const MIGRATIONS = []() {
|
||||
std::vector<std::unique_ptr<sqlitecpp::Migration>> ret;
|
||||
|
||||
ret.emplace_back(DECLARE_MIGRATION(m1_initial_layout));
|
||||
|
||||
return ret;
|
||||
}();
|
||||
|
||||
} // namespace ikarus
|
||||
Loading…
Add table
Add a link
Reference in a new issue