Skip to content

GuitarPrometheus::Project::ProjectMigrationRegistry

GuitarPrometheus::Project::ProjectMigrationRegistry

Process-wide registry of schema-bump transformers. More…

#include <ProjectMigration.h>

Public Functions

Name
ProjectMigrationRegistry &getInstance()
voidregisterMigration(int fromVersion, int toVersion, ProjectMigrationFn fn)
Register a transformer from fromVersion -> toVersion.
voidunregisterMigration(int fromVersion, int toVersion)
Forget the transformer for a specific edge.
std::vector< std::string >migrateToCurrent(nlohmann::json & json) const
Walk json from its declared schemaVersion up to kCurrentSchemaVersion, applying registered transformers in order.
voidclear()
Test-only: drop every registered migration.

Public Attributes

Name
constexpr intkCurrentSchemaVersion
Schema version emitted by the current build.

Detailed Description

class GuitarPrometheus::Project::ProjectMigrationRegistry;

Process-wide registry of schema-bump transformers.

Today’s kCurrentSchemaVersion is 1; no production migrations exist yet because the schema hasn’t bumped. The framework is in place so a future v1 -> v2 (or any later bump) is one registerMigration(1, 2, fn) call instead of a rewrite of [ProjectStore](/api-reference/classes/classguitarprometheus_1_1project_1_1projectstore/). Tests register their own transformers in their own scope to exercise the pipeline without affecting production behaviour, then unregister in teardown.

Public Functions Documentation

function getInstance

static ProjectMigrationRegistry & getInstance()

function registerMigration

void registerMigration(
int fromVersion,
int toVersion,
ProjectMigrationFn fn
)

Register a transformer from fromVersion -> toVersion.

Replaces any existing entry for that exact (from, to) edge.

function unregisterMigration

void unregisterMigration(
int fromVersion,
int toVersion
)

Forget the transformer for a specific edge.

Tests call this in teardown so global state stays clean across runs.

function migrateToCurrent

std::vector< std::string > migrateToCurrent(
nlohmann::json & json
) const

Walk json from its declared schemaVersion up to kCurrentSchemaVersion, applying registered transformers in order.

Return: Diagnostic strings — non-fatal notes (“applied v0 -> v1”) for the AlertWindow. Throws std::runtime_error when no path exists; the caller surfaces that as a load failure.

function clear

void clear()

Test-only: drop every registered migration.

Used in test fixtures so leftovers from one TEST_CASE don’t bleed into the next.

Public Attributes Documentation

variable kCurrentSchemaVersion

static constexpr int kCurrentSchemaVersion = 5;

Schema version emitted by the current build.


Updated on 2026-05-29 at 07:39:52 +0000