Sepasoft MES Module Suite
truncateConfiguration()
Overview
The truncateConfiguration script function removes all MES definition configuration data from the gateway database by truncating the MES object, link, property, artifact, change-log, and metadata tables. Call it before system.mes.importConfiguration() when you need to replace the entire MES configuration from a JSON export file. This operation is destructive and cannot be undone without a backup.
Syntax
Python |
system.mes.truncateConfiguration() |
Parameters
This function takes no parameters.
Returns
Type | Description |
|---|---|
None | The function returns void. It does not return a value. |
Scope / Availability
Context | Available |
|---|---|
Gateway scripts (MESGatewayScript) | Yes — runs truncate directly on the gateway |
Client / Designer scripts (MESClientScript) | Yes — invokes the gateway through RPC |
Both contexts expose the same system.mes module for configuration management.
Truncated Data
truncateConfiguration() truncates every MES table required for a full configuration reset, including:
MES object tables — One table per object storage type for all registered MES object types (core definition data)
Complex property tables — Tables backing complex properties on those object types
Object link tables — Definition and response MES object link tables
Custom property tables — Definition and response custom property tables
Artifacts — Stored artifact content referenced by MES objects
Change logs — Definition and response change-log tables
MES metadata — MES metadata table used by the object managers
Truncation uses database TRUNCATE operations. Tables that do not exist in the current schema are skipped without failing the call.
What this does not do
Item | Behavior |
|---|---|
JSON export files | Files on disk (for example, MESConfig.json) are not deleted. |
Non-MES tables | Only MES-managed tables collected by the gateway are truncated. |
Gateway module state | Installed modules and Ignition project resources are not affected. |
After truncation, system.mes.importConfiguration() can run because the object link table is empty.
Behavior
When truncateConfiguration() runs:
Table discovery — The gateway builds the full set of MES definition-related table names from registered object types, complex properties, links, artifacts, change logs, and metadata.
Database truncate — Each table is truncated in sequence against the MES analysis datasource.
Missing tables — If a table does not exist (for example, after a schema change or partial install), that table is skipped and processing continues.
There is no gateway startup pause during truncate (unlike importConfiguration()).
Exceptions
Exception | When raised |
|---|---|
SQLException / DBException | Database errors while truncating a table that exists and is accessible. |
Exception | Other failures during the truncate transaction (wrapped from the database layer). |
Example Usage
Minimal example
Python |
# Clear all MES definition data before import system.mes.truncateConfiguration() system.mes.importConfiguration() |
Complex example
Safe migration workflow: export a backup, truncate the target, import the new configuration, and keep the backup file for rollback:
Python |
backupPath = 'C:/backups/MESConfig_before_migration.json' deployPath = 'C:/deploy/MESConfig.json' # Preserve current configuration to disk before wiping the database system.mes.exportConfiguration(backupPath) # Remove all MES definition data from the database system.mes.truncateConfiguration() # Load the new configuration system.mes.importConfiguration(deployPath) |
Truncate only (for example, when resetting a development gateway before manual rebuild):
Python |
system.mes.truncateConfiguration() print('MES definition tables cleared') |
Related Functions
Module: system.mes
importConfiguration() / importConfiguration(filePath) — Loads MES definition objects from a JSON file. Requires an empty database; call truncateConfiguration() first when replacing existing configuration.
exportConfiguration() / exportConfiguration(filePath) — Exports the current MES definition configuration to a JSON file. Use before truncate when you need a recoverable backup
Sepasoft MES Module Suite