#pragma once
#include <cstdint>
#include <mw/database.hpp>
#include <mw/error.hpp>
namespace overseer::db
{
/// The highest schema version this binary knows about. Increment when
/// adding a new migration.
inline constexpr int64_t HIGHEST_KNOWN_VERSION = 1;
/// Run all required migrations from the current user_version up to
/// HIGHEST_KNOWN_VERSION. If the DB is already at the target, do
/// nothing. If it is *newer* than the binary, refuse and return an
/// error. Before any migration is run, takes a backup of the DB file.
///
/// `db_path` is the on-disk path of the DB file (needed for the
/// backup); pass it even though `db` is the live connection.
mw::E<void> migrateIfNeeded(mw::SQLite& db, const std::string& db_path);
// ---- individual migrations ------------------------------------------
mw::E<void> migrateDB0To1(mw::SQLite& db);
} // namespace overseer::db