Skip to content

Commit 26303fb

Browse files
authored
Merge pull request #114 from Keyfactor/62371-delete-dependent-records
ab#62371 delete records from additional dependent tables
2 parents 5adb87b + 0d8d033 commit 26303fb

File tree

1 file changed

+34
-12
lines changed

1 file changed

+34
-12
lines changed

Migration-Scripts/Legacy-IIS/DeleteIISStores.sql

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,41 +27,59 @@ BEGIN TRY
2727
INNER JOIN [cms_agents].[CertStores] [cs] ON [csii].[CertStoreId] = [cs].[Id]
2828
INNER JOIN @IISStoreTypeIds [sti] ON [sti].[Id] = [cs].[CertStoreType];
2929

30+
DELETE [csmj]
31+
FROM [cms_agents].[CertStoreManagementJobs] [csmj]
32+
INNER JOIN [cms_agents].[AgentSchedules] [as] ON [csmj].[JobId] = [as].[JobId]
33+
INNER JOIN @IISJobTypeIds [jti] ON [jti].[Id] = [as].[JobTypeId];
34+
35+
DELETE [csms]
36+
FROM [dbo].[CertStoreManagementStaging] [csms]
37+
INNER JOIN [cms_agents].[CertStores] [cs] ON [csms].[CertStoreId] = [cs].[Id]
38+
INNER JOIN @IISStoreTypeIds [sti] ON [sti].[Id] = [cs].[CertStoreType];
39+
40+
DELETE [csmjs]
41+
FROM [cms_agents].[CertStoreManagementJobStaging] [csmjs]
42+
INNER JOIN [cms_agents].[CertStores] [cs] ON [csmjs].[StoreId] = [cs].[Id]
43+
INNER JOIN @IISStoreTypeIds [st] ON [st].[Id] = [cs].[CertStoreType];
44+
45+
DELETE [csrj]
46+
FROM [cms_agents].[CertStoreReenrollmentJobs] [csrj]
47+
INNER JOIN [cms_agents].[AgentSchedules] [as] ON [csrj].[JobId] = [as].[JobId]
48+
INNER JOIN @IISJobTypeIds [jti] ON [jti].[Id] = [as].[JobTypeId];
49+
3050
DELETE [cs]
3151
FROM [cms_agents].[CertStores] [cs]
3252
INNER JOIN @IISStoreTypeIds [st] ON [cs].[CertStoreType] = [st].[Id];
3353

3454
DELETE [csc]
3555
FROM [cms_agents].[CertStoreContainers] [csc]
36-
INNER JOIN @IISStoreTypeIds [st] ON [csc].[CertStoreType] = [st].[Id];
56+
INNER JOIN @IISStoreTypeIds [st] ON [csc].[CertStoreType] = [st].[Id];
3757

3858
DELETE [csij]
3959
FROM [cms_agents].[CertStoreInventoryJobs] [csij]
4060
INNER JOIN [cms_agents].[AgentSchedules] [as] ON [csij].[JobId] = [as].[JobId]
4161
INNER JOIN @IISJobTypeIds [jti] ON [jti].[Id] = [as].[JobTypeId];
4262

43-
DELETE [csrj]
44-
FROM [cms_agents].[CertStoreReenrollmentJobs] [csrj]
45-
INNER JOIN [cms_agents].[AgentSchedules] [as] ON [csrj].[JobId] = [as].[JobId]
46-
INNER JOIN @IISJobTypeIds [jti] ON [jti].[Id] = [as].[JobTypeId];
47-
48-
DELETE [csmj]
49-
FROM [cms_agents].[CertStoreManagementJobs] [csmj]
50-
INNER JOIN [cms_agents].[AgentSchedules] [as] ON [csmj].[JobId] = [as].[JobId]
51-
INNER JOIN @IISJobTypeIds [jti] ON [jti].[Id] = [as].[JobTypeId];
52-
5363
DELETE [as]
5464
FROM [cms_agents].[AgentSchedules] [as]
5565
INNER JOIN @IISJobTypeIds [jt] ON [jt].[Id] = [as].[JobTypeId];
5666

5767
DELETE [cstp]
5868
FROM [cms_agents].[CertStoreTypeProperties] [cstp]
59-
INNER JOIN @IISStoreTypeIds [st] ON [cstp].[StoreTypeId] = [st].[id];
69+
INNER JOIN @IISStoreTypeIds [st] ON [cstp].[StoreTypeId] = [st].[Id];
70+
71+
DELETE [cstep]
72+
FROM [cms_agents].[CertStoreTypeEntryParameters] [cstep]
73+
INNER JOIN @IISStoreTypeIds [st] ON [cstep].[StoreTypeId] = [st].[Id];
6074

6175
DELETE [cst]
6276
FROM [cms_agents].[CertStoreTypes] [cst]
6377
INNER JOIN @IISStoreTypeIds [st] ON [cst].[StoreType] = [st].[id];
6478

79+
DELETE [arg]
80+
FROM [cms_agents].[AgentRegistrationGroups] [arg]
81+
INNER JOIN @IISJobTypeIds [jt] ON [arg].[JobTypeId] = [jt].[Id];
82+
6583
DELETE [ars]
6684
FROM [cms_agents].[AgentRegistrationSettings] [ars]
6785
INNER JOIN @IISJobTypeIds [jt] ON [ars].[JobTypeId] = [jt].[Id];
@@ -70,6 +88,10 @@ BEGIN TRY
7088
FROM [cms_agents].[AgentCapabilities] [ac]
7189
INNER JOIN @IISJobTypeIds [jt] ON [ac].[JobTypeId] = [jt].[Id];
7290

91+
DELETE [jtf]
92+
FROM [cms_agents].[JobTypeFields] [jtf]
93+
INNER JOIN @IISJobTypeIds [jt] ON [jtf].[JobTypeId] = [jt].[Id];
94+
7395
DELETE [jt]
7496
FROM [cms_agents].[JobTypes] [jt]
7597
INNER JOIN @IISJobTypeIds [jti] ON [jt].[Id] = [jti].[Id];

0 commit comments

Comments
 (0)