diff --git a/otopcua-uns-loader/otopcua_uns.py b/otopcua-uns-loader/otopcua_uns.py index 567b447..467ccbb 100644 --- a/otopcua-uns-loader/otopcua_uns.py +++ b/otopcua-uns-loader/otopcua_uns.py @@ -254,6 +254,9 @@ def cmd_populate_equipment(args): cur.execute("DELETE FROM dbo.Equipment WHERE UnsLineId LIKE 'nw-line-%'") cur.execute("DELETE FROM dbo.UnsLine WHERE UnsLineId LIKE 'nw-line-%'") cur.execute("DELETE FROM dbo.UnsArea WHERE UnsAreaId LIKE 'nw-area-%'") + # Equipment is now driver-less, but purge any driver still bound to the overlay namespace — + # self-heals environments that ran an older loader which created the 'nw-uns-modbus' placeholder. + cur.execute("DELETE FROM dbo.DriverInstance WHERE NamespaceId=%s", (EQ_NS,)) cur.execute("DELETE FROM dbo.Namespace WHERE NamespaceId=%s", (EQ_NS,)) cur.execute( @@ -328,6 +331,9 @@ def cmd_clean(args): cur.execute("DELETE FROM dbo.Equipment WHERE UnsLineId LIKE 'nw-line-%'") cur.execute("DELETE FROM dbo.UnsLine WHERE UnsLineId LIKE 'nw-line-%'") cur.execute("DELETE FROM dbo.UnsArea WHERE UnsAreaId LIKE 'nw-area-%'") + # Purge any driver still bound to the overlay namespace (e.g. the legacy 'nw-uns-modbus' + # placeholder created by an older loader) so 'clean' fully removes the overlay. + cur.execute("DELETE FROM dbo.DriverInstance WHERE NamespaceId=%s", (EQ_NS,)) cur.execute("DELETE FROM dbo.Namespace WHERE NamespaceId=%s", (EQ_NS,)) conn.commit() conn.close()