From 262f2f32199e89646190d9017eb74eb7f1d7187e Mon Sep 17 00:00:00 2001 From: Atlas Development Worker Date: Wed, 2 Dec 2026 20:23:20 +0000 Subject: [PATCH] Reconcile undeployed Threads SQL with current recovery graph safeguards --- PlotLine/Sql/340_SceneThreads.sql | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/PlotLine/Sql/340_SceneThreads.sql b/PlotLine/Sql/340_SceneThreads.sql index 1e1945e1..fed25e81 100644 --- a/PlotLine/Sql/340_SceneThreads.sql +++ b/PlotLine/Sql/340_SceneThreads.sql @@ -71,7 +71,12 @@ END; GO -- Extend the current restore definition narrowly, retaining its existing recovery -- and omission safeguards. Refuse unexpected definitions during qualification. -DECLARE @restore nvarchar(max)=OBJECT_DEFINITION(OBJECT_ID(N'dbo.ProjectRestore_ApplyFromJson')); +-- Current recovery delegates graph replacement through the preserved 236 graph +-- procedure. Patch that graph, retaining the outer native/paragraph safeguards. +DECLARE @restoreName sysname=CASE WHEN OBJECT_DEFINITION(OBJECT_ID(N'dbo.ProjectRestore_ApplyFromJson')) LIKE N'%EXEC dbo.ProjectRestore_ApplyGraph236 %' + THEN N'dbo.ProjectRestore_ApplyGraph236' ELSE N'dbo.ProjectRestore_ApplyFromJson' END; +DECLARE @wrapper nvarchar(max)=OBJECT_DEFINITION(OBJECT_ID(N'dbo.ProjectRestore_ApplyFromJson')); +DECLARE @restore nvarchar(max)=OBJECT_DEFINITION(OBJECT_ID(@restoreName)); IF @restore IS NULL THROW 51012,'The authoritative project restore procedure is required.',1; IF @restore NOT LIKE N'%SceneThreads%' BEGIN @@ -85,6 +90,12 @@ BEGIN SET @restore=REPLACE(@restore,@insert,@insert+N' EXEC dbo.ProjectRestore_InsertJsonTable N''SceneThreads'', N''$.Data.SceneThreads'', @JsonData, @ProjectID, 0;'); SET @restore=STUFF(@restore,1,CHARINDEX(N'PROCEDURE',@restore)-1,N'CREATE OR ALTER '); + -- sp_rename retains the original module header. Bind the ALTER to the graph, + -- and prove the recovery wrapper itself was preserved before committing. + SET @restore=REPLACE(@restore,N'PROCEDURE dbo.ProjectRestore_ApplyFromJson',N'PROCEDURE '+@restoreName); + IF CHARINDEX(N'PROCEDURE '+@restoreName,@restore)=0 THROW 51012,'Unexpected project restore graph header.',1; EXEC sys.sp_executesql @restore; + IF @restoreName<>N'dbo.ProjectRestore_ApplyFromJson' AND OBJECT_DEFINITION(OBJECT_ID(N'dbo.ProjectRestore_ApplyFromJson'))<>@wrapper + THROW 51012,'The outer recovery wrapper must remain unchanged.',1; END; GO