40 lines
981 B
C++
40 lines
981 B
C++
#pragma once
|
|
|
|
#include <array>
|
|
|
|
#include <cppbase/assets.hpp>
|
|
#include <cppbase/result.hpp>
|
|
|
|
#include <sqlitecpp/connection.hpp>
|
|
|
|
namespace ikarus {
|
|
CPPBASE_ASSET(m0_initial_layout, "persistence/migrations/m0_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(m0_initial_layout));
|
|
|
|
return ret;
|
|
}();
|
|
|
|
} // namespace ikarus
|