From eb8b44c29dd91ac66548acaed9247062d35372ea Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Mon, 8 Jun 2026 07:07:22 -0400 Subject: [PATCH] loader: purge legacy driver in overlay namespace on teardown (self-heal nw-uns-modbus placeholder) --- otopcua-uns-loader/otopcua_uns.py | 6 ++++++ 1 file changed, 6 insertions(+) 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()