#pragma once #include #include namespace ZShell::config { // A single migration rule: move the value stored at the dotted `from` path // to the dotted `to` path, then delete the old key (and any parent objects // left empty). // // Rules are applied to the raw JSON file on every load, before the schema // loads it. They are idempotent: once the old key is gone the rule never // fires again, so no version stamping is needed. Old rules can stay in the // table forever. // // WARNING: the target path must exist in the schema (i.e. a ConfigObject // property somewhere in the tree). If it does not, the migrated value is // loaded as an unknown key and silently dropped on the next save. struct ConfigMigrationRule { QString from; QString to; }; // Helper for writing rules: migrate("general.color.foo", "display.bar.foo") inline ConfigMigrationRule migrate(const QString& from, const QString& to) { return {from, to}; } class ConfigMigrations { public: [[nodiscard]] static const QList& rules(); // Applies all rules to `json`, returning the migrated object. [[nodiscard]] static QJsonObject apply(const QJsonObject& json); }; } // namespace ZShell::config