diff --git a/Migration-Scripts/Legacy-IIS/DeleteIISStores.sql b/Migration-Scripts/Legacy-IIS/DeleteIISStores.sql index f7a6438..0d8ce82 100644 --- a/Migration-Scripts/Legacy-IIS/DeleteIISStores.sql +++ b/Migration-Scripts/Legacy-IIS/DeleteIISStores.sql @@ -27,41 +27,59 @@ BEGIN TRY INNER JOIN [cms_agents].[CertStores] [cs] ON [csii].[CertStoreId] = [cs].[Id] INNER JOIN @IISStoreTypeIds [sti] ON [sti].[Id] = [cs].[CertStoreType]; + DELETE [csmj] + FROM [cms_agents].[CertStoreManagementJobs] [csmj] + INNER JOIN [cms_agents].[AgentSchedules] [as] ON [csmj].[JobId] = [as].[JobId] + INNER JOIN @IISJobTypeIds [jti] ON [jti].[Id] = [as].[JobTypeId]; + + DELETE [csms] + FROM [dbo].[CertStoreManagementStaging] [csms] + INNER JOIN [cms_agents].[CertStores] [cs] ON [csms].[CertStoreId] = [cs].[Id] + INNER JOIN @IISStoreTypeIds [sti] ON [sti].[Id] = [cs].[CertStoreType]; + + DELETE [csmjs] + FROM [cms_agents].[CertStoreManagementJobStaging] [csmjs] + INNER JOIN [cms_agents].[CertStores] [cs] ON [csmjs].[StoreId] = [cs].[Id] + INNER JOIN @IISStoreTypeIds [st] ON [st].[Id] = [cs].[CertStoreType]; + + DELETE [csrj] + FROM [cms_agents].[CertStoreReenrollmentJobs] [csrj] + INNER JOIN [cms_agents].[AgentSchedules] [as] ON [csrj].[JobId] = [as].[JobId] + INNER JOIN @IISJobTypeIds [jti] ON [jti].[Id] = [as].[JobTypeId]; + DELETE [cs] FROM [cms_agents].[CertStores] [cs] INNER JOIN @IISStoreTypeIds [st] ON [cs].[CertStoreType] = [st].[Id]; DELETE [csc] FROM [cms_agents].[CertStoreContainers] [csc] - INNER JOIN @IISStoreTypeIds [st] ON [csc].[CertStoreType] = [st].[Id]; + INNER JOIN @IISStoreTypeIds [st] ON [csc].[CertStoreType] = [st].[Id]; DELETE [csij] FROM [cms_agents].[CertStoreInventoryJobs] [csij] INNER JOIN [cms_agents].[AgentSchedules] [as] ON [csij].[JobId] = [as].[JobId] INNER JOIN @IISJobTypeIds [jti] ON [jti].[Id] = [as].[JobTypeId]; - DELETE [csrj] - FROM [cms_agents].[CertStoreReenrollmentJobs] [csrj] - INNER JOIN [cms_agents].[AgentSchedules] [as] ON [csrj].[JobId] = [as].[JobId] - INNER JOIN @IISJobTypeIds [jti] ON [jti].[Id] = [as].[JobTypeId]; - - DELETE [csmj] - FROM [cms_agents].[CertStoreManagementJobs] [csmj] - INNER JOIN [cms_agents].[AgentSchedules] [as] ON [csmj].[JobId] = [as].[JobId] - INNER JOIN @IISJobTypeIds [jti] ON [jti].[Id] = [as].[JobTypeId]; - DELETE [as] FROM [cms_agents].[AgentSchedules] [as] INNER JOIN @IISJobTypeIds [jt] ON [jt].[Id] = [as].[JobTypeId]; DELETE [cstp] FROM [cms_agents].[CertStoreTypeProperties] [cstp] - INNER JOIN @IISStoreTypeIds [st] ON [cstp].[StoreTypeId] = [st].[id]; + INNER JOIN @IISStoreTypeIds [st] ON [cstp].[StoreTypeId] = [st].[Id]; + + DELETE [cstep] + FROM [cms_agents].[CertStoreTypeEntryParameters] [cstep] + INNER JOIN @IISStoreTypeIds [st] ON [cstep].[StoreTypeId] = [st].[Id]; DELETE [cst] FROM [cms_agents].[CertStoreTypes] [cst] INNER JOIN @IISStoreTypeIds [st] ON [cst].[StoreType] = [st].[id]; + DELETE [arg] + FROM [cms_agents].[AgentRegistrationGroups] [arg] + INNER JOIN @IISJobTypeIds [jt] ON [arg].[JobTypeId] = [jt].[Id]; + DELETE [ars] FROM [cms_agents].[AgentRegistrationSettings] [ars] INNER JOIN @IISJobTypeIds [jt] ON [ars].[JobTypeId] = [jt].[Id]; @@ -70,6 +88,10 @@ BEGIN TRY FROM [cms_agents].[AgentCapabilities] [ac] INNER JOIN @IISJobTypeIds [jt] ON [ac].[JobTypeId] = [jt].[Id]; + DELETE [jtf] + FROM [cms_agents].[JobTypeFields] [jtf] + INNER JOIN @IISJobTypeIds [jt] ON [jtf].[JobTypeId] = [jt].[Id]; + DELETE [jt] FROM [cms_agents].[JobTypes] [jt] INNER JOIN @IISJobTypeIds [jti] ON [jt].[Id] = [jti].[Id];