Reconcile undeployed Threads SQL with current recovery graph safeguards
This commit is contained in:
parent
bcaa23b564
commit
262f2f3219
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user