Class ConfigResourceMigrations

java.lang.Object
com.inductiveautomation.ignition.gateway.config.ConfigResourceMigrations

public final class ConfigResourceMigrations extends Object
Helpers for one-time, idempotent migrations of config resources at startup.
  • Method Details

    • rewriteCanonicalSingleton

      public static <R> boolean rewriteCanonicalSingleton(ConfigurationManager configurationManager, ResourceTypeMeta<R> meta, String actor) throws DecodingException, PushException
      Re-persists a singleton config resource in its canonical form, dropping any legacy or deprecated data that the resource's codec normalizes away on decode (for example, a deprecated scalar property folded into a list). The decode/encode round-trip is the migration, so this works for any singleton resource type whose decode normalizes legacy content - no resource-specific logic required.

      Only the resource's config payloads are rewritten: config.json, plus backupConfig.json when one is persisted and the codec can encode it. Everything else on the resource is preserved as-is - attributes (including enabled), the description, and auxiliary data files. This matters because the rewrite is pushed as a modify operation, which replaces the resource wholesale rather than merging into it.

      Idempotent and safe to call on every startup: it is a no-op when the resource is absent, lives in a read-only external collection, or is already canonical (its serialized data is unchanged, ignoring last-modification metadata).

      Type Parameters:
      R - the decoded resource type
      Parameters:
      configurationManager - the configuration manager to read from and push the rewrite to
      meta - the singleton resource type to canonicalize
      actor - the actor to attribute the rewrite to
      Returns:
      true if the resource was rewritten
      Throws:
      DecodingException - if the existing resource cannot be decoded
      PushException - if the rewrite cannot be pushed