feat(backend): add sqlite migrations + app state + tests

这个提交包含在:
anygen-build-bot
2026-02-12 08:58:53 +00:00
父节点 b6befe69f9
当前提交 76b512939d
修改 8 个文件,包含 334 行新增5 行删除

22
backend/src/app_state.cc 普通文件
查看文件

@@ -0,0 +1,22 @@
#include "csp/app_state.h"
#include <stdexcept>
namespace csp {
AppState& AppState::Instance() {
static AppState inst;
return inst;
}
void AppState::Init(const std::string& sqlite_path) {
db_ = std::make_unique<db::SqliteDb>(db::SqliteDb::OpenFile(sqlite_path));
csp::db::ApplyMigrations(*db_);
}
csp::db::SqliteDb& AppState::db() {
if (!db_) throw std::runtime_error("AppState not initialized");
return *db_;
}
} // namespace csp