Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
MigrationRunner.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 fuddlesworth
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4#pragma once
5
6#include <phosphorconfig_export.h>
7
9
10#include <QJsonObject>
11#include <QString>
12#include <QVector>
13
14namespace PhosphorConfig {
15
22class PHOSPHORCONFIG_EXPORT MigrationRunner
23{
24public:
25 explicit MigrationRunner(const Schema& schema);
26
30 explicit MigrationRunner(Schema&&) = delete;
31
36 void runInMemory(QJsonObject& root) const;
37
48 bool runOnFile(const QString& jsonPath) const;
49
51 int readVersion(const QJsonObject& root) const;
52
54 void stampVersion(QJsonObject& root) const;
55
56private:
57 const Schema& m_schema;
60 QVector<MigrationStep> m_orderedSteps;
61};
62
63} // namespace PhosphorConfig
Executes a Schema's migration chain against a JSON document.
Definition MigrationRunner.h:23
bool runOnFile(const QString &jsonPath) const
Read the file at jsonPath, run the chain, and — if the version advanced — atomically write the result...
void stampVersion(QJsonObject &root) const
Stamp root with the schema's current version.
int readVersion(const QJsonObject &root) const
Current version persisted in root, or 1 if unset / invalid.
void runInMemory(QJsonObject &root) const
Apply the full migration chain in memory.
MigrationRunner(const Schema &schema)
MigrationRunner(Schema &&)=delete
Forbid construction from a temporary Schema — the runner stores a const reference,...
Definition IBackend.h:19
Declarative description of a configuration store.
Definition Schema.h:89