Changesets with Existing Gateways

Changesets with Existing Gateways

Run this on a test pair first. Back up both gateways and their MES databases before changing either system.

Step 1: Make the configuration match

Use production as the baseline. Staging changes that are not in that export are replaced by it. Recreate any of those differences on staging after the import, inside a new Change Set.

On production, from a Gateway script:

Python
[Python]  system.mes.exportConfiguration()

That writes MESConfig.json in the Ignition data directory.

Copy that file into the Ignition data directory on staging, then run:

Python
[Python]  system.mes.truncateConfiguration() system.mes.importConfiguration()

importConfiguration() reloads the MES runtime after a successful import.

truncateConfiguration() clears MES definition data only. It does not clear Change Set files or Change Set tables.

Step 2: Remove the existing Change Set history on both gateways

Stop both gateways first. The gateway keeps the last applied Change Set in memory until restart, so this cleanup has to finish before either gateway starts again.

On each gateway, delete the contents of:

{Ignition data directory}/changesets/configuration/diff

If com.sepasoft.changesets.path is set, delete the contents of that directory instead.

In the MES database on each gateway, remove the rows from these tables:

  • ClosedChangeset

  • OpenChangeset

  • ChangesetActionHistory

  • ChangesetOriginatorHistory

  • ConfigurationChangeset

Leave the MES configuration tables in place. There is no script or endpoint that clears Change Set history. Deleting the files alone is not enough: an applied Change Set that is missing from disk is kept and reported as a reconciliation error.

Start both gateways. On each one, confirm the closed list is empty:

Python
[Python]  system.mes.changeset.listClosed()

Step 3: Create the shared baseline on staging

Make the Production Model changes on staging and apply them there. The first Change Set applied after the cleanup is the single shared INITIAL. Later Change Sets chain from that one.

Step 4: Promote to production

Copy the new closed Change Set files from staging to production, preserving the relative path under changesets/configuration/diff. Each file lives at aa/bb/<rest-of-uuid>.json.

On production:

Python
[Python]  system.mes.changeset.reconcile() system.mes.changeset.applyPlan() system.mes.changeset.applyMissing("")

reconcile() only indexes the files as unapplied. applyPlan() shows the order and anything blocked. applyMissing("") applies that plan. Review errors from reconcile and apply-plan, and failures from apply-missing, before treating the promotion as complete.

The same calls are available as:

  • GET /data/productiongateway/api/v1/changeset/config/reconcile

  • GET /data/productiongateway/api/v1/changeset/config/apply-plan

  • GET /data/productiongateway/api/v1/changeset/config/apply-missing

A gateway restart does not apply Change Sets.

For later promotions, copy only the new closed files. Production must already have the predecessor applied. Leave the existing Change Set folders where they are until step 2 deletes them. Copying one gateway’s current Change Set folder onto the other produces two INITIAL Change Sets, and reconcile will reject that.