|
1 | | -using System.Diagnostics; |
2 | | - |
3 | | -namespace DigitalLearningSolutions.Data.Migrations |
4 | | -{ |
5 | | - using FluentMigrator; |
6 | | - using Microsoft.Data.SqlClient; |
7 | | - using System; |
8 | | - |
9 | | - [Migration(202401290942)] |
10 | | - public class RenameDeprecatedStoredProcs : Migration |
11 | | - { |
12 | | - public override void Up() |
13 | | - { |
14 | | - string[] currentProcedureNames = GetProcedureNames(); |
15 | | - |
16 | | - foreach (string currentProcedureName in currentProcedureNames) |
17 | | - { |
18 | | - string newProcedureName = currentProcedureName + "_deprecated"; |
19 | | - string renameQuery = $"EXEC sp_rename '{currentProcedureName}', '{newProcedureName}';"; |
20 | | - |
21 | | - Execute.Sql(renameQuery); |
| 1 | +using System.Diagnostics; |
| 2 | + |
| 3 | +namespace DigitalLearningSolutions.Data.Migrations |
| 4 | +{ |
| 5 | + using FluentMigrator; |
| 6 | + using Microsoft.Data.SqlClient; |
| 7 | + using System; |
| 8 | + |
| 9 | + [Migration(202401290942)] |
| 10 | + public class RenameDeprecatedStoredProcs : Migration |
| 11 | + { |
| 12 | + public override void Up() |
| 13 | + { |
| 14 | + string[] currentProcedureNames = GetProcedureNames(); |
| 15 | + |
| 16 | + foreach (string currentProcedureName in currentProcedureNames) |
| 17 | + { |
| 18 | + string newProcedureName = currentProcedureName + "_deprecated"; |
| 19 | + string renameQuery = $"EXEC sp_rename '{currentProcedureName}', '{newProcedureName}';"; |
| 20 | + |
| 21 | + Execute.Sql(renameQuery); |
22 | 22 | } |
23 | 23 |
|
24 | | - } |
25 | | - public override void Down() |
26 | | - { |
27 | | - string[] procedureNames = GetProcedureNames(); |
28 | | - |
29 | | - foreach (string procedureName in procedureNames) |
30 | | - { |
31 | | - string currentProcedureName = procedureName + "_deprecated"; |
32 | | - string renameQuery = $"EXEC sp_rename '{currentProcedureName}', '{procedureName}';"; |
33 | | - |
34 | | - Execute.Sql(renameQuery); |
35 | | - } |
36 | | - } |
37 | | - |
38 | | - private string[] GetProcedureNames() |
39 | | - { |
40 | | - string[] oldProcedureNames = |
41 | | - { |
42 | | - "aspnet_AnyDataInTables", |
43 | | - "aspnet_Applications_CreateApplication", |
44 | | - "aspnet_CheckSchemaVersion", |
45 | | - "aspnet_Membership_ChangePasswordQuestionAndAnswer", |
46 | | - "aspnet_Membership_CreateUser", |
47 | | - "aspnet_Membership_FindUsersByEmail", |
48 | | - "aspnet_Membership_FindUsersByName", |
49 | | - "aspnet_Membership_GetAllUsers", |
50 | | - "aspnet_Membership_GetNumberOfUsersOnline", |
51 | | - "aspnet_Membership_GetPassword", |
52 | | - "aspnet_Membership_GetPasswordWithFormat", |
53 | | - "aspnet_Membership_GetUserByEmail", |
54 | | - "aspnet_Membership_GetUserByName", |
55 | | - "aspnet_Membership_GetUserByUserId", |
56 | | - "aspnet_Membership_ResetPassword", |
57 | | - "aspnet_Membership_SetPassword", |
58 | | - "aspnet_Membership_UnlockUser", |
59 | | - "aspnet_Membership_UpdateUser", |
60 | | - "aspnet_Membership_UpdateUserInfo", |
61 | | - "aspnet_Paths_CreatePath", |
62 | | - "aspnet_PersonalizationAdministration_DeleteAllState", |
63 | | - "aspnet_PersonalizationAdministration_FindState", |
64 | | - "aspnet_PersonalizationAdministration_GetCountOfState", |
65 | | - "aspnet_PersonalizationAdministration_ResetSharedState", |
66 | | - "aspnet_PersonalizationAdministration_ResetUserState", |
67 | | - "aspnet_PersonalizationAllUsers_GetPageSettings", |
68 | | - "aspnet_PersonalizationAllUsers_ResetPageSettings", |
69 | | - "aspnet_PersonalizationAllUsers_SetPageSettings", |
70 | | - "aspnet_PersonalizationPerUser_GetPageSettings", |
71 | | - "aspnet_PersonalizationPerUser_ResetPageSettings", |
72 | | - "aspnet_PersonalizationPerUser_SetPageSettings", |
73 | | - "aspnet_Profile_DeleteInactiveProfiles", |
74 | | - "aspnet_Profile_DeleteProfiles", |
75 | | - "aspnet_Profile_GetNumberOfInactiveProfiles", |
76 | | - "aspnet_Profile_GetProfiles", |
77 | | - "aspnet_Profile_GetProperties", |
78 | | - "aspnet_Profile_SetProperties", |
79 | | - "aspnet_RegisterSchemaVersion", |
80 | | - "aspnet_Roles_CreateRole", |
81 | | - "aspnet_Roles_DeleteRole", |
82 | | - "aspnet_Roles_GetAllRoles", |
83 | | - "aspnet_Roles_RoleExists", |
84 | | - "aspnet_Setup_RemoveAllRoleMembers", |
85 | | - "aspnet_Setup_RestorePermissions", |
86 | | - "aspnet_UnRegisterSchemaVersion", |
87 | | - "aspnet_Users_CreateUser", |
88 | | - "aspnet_Users_DeleteUser", |
89 | | - "aspnet_UsersInRoles_AddUsersToRoles", |
90 | | - "aspnet_UsersInRoles_FindUsersInRole", |
91 | | - "aspnet_UsersInRoles_GetRolesForUser", |
92 | | - "aspnet_UsersInRoles_GetUsersInRoles", |
93 | | - "aspnet_UsersInRoles_IsUserInRole", |
94 | | - "aspnet_UsersInRoles_RemoveUsersFromRoles", |
95 | | - "aspnet_WebEvent_LogEvent", |
96 | | - "ClearSectionBookmark", |
97 | | - "GetActiveAvailableCustomisationsForCentreFiltered_V2", |
98 | | - "GetActiveAvailableCustomisationsForCentreFiltered_V3", |
99 | | - "GetDelegatesForCustomisation_V2", |
100 | | - "GetDelegatesForCustomisation_V3", |
101 | | - "GetDelegatesForCustomisation_V4", |
102 | | - "GetKnowledgeBankData", |
103 | | - "GetSelfAssessmentDashboardDataPivot", |
104 | | - "GroupDelegates_Add_QT", |
105 | | - "InsertUserNotificationIfNotExists", |
106 | | - "PrePopulateActivityLog", |
107 | | - "PurgeDelegatesForCentre", |
108 | | - "uspCandidatesForAllCustomisations", |
109 | | - "uspCandidatesForCentre", |
110 | | - "uspCandidatesForCentre_V5", |
111 | | - "uspCandidatesForCentre_V6", |
112 | | - "uspCandidatesForCustomisation", |
113 | | - "uspCandidatesForCustomisation_V5", |
114 | | - "uspCandidatesForCustomisation_V6", |
115 | | - "uspCreateProgressRecord_V2", |
116 | | - "uspEvaluationSummaryDateRangeV2", |
117 | | - "uspEvaluationSummaryDateRangeV3", |
118 | | - "uspFollowUpSurveys", |
119 | | - "uspFollowUpSurveysTest", |
120 | | - "uspGetCentreRankKB", |
121 | | - "uspGetKBTopTen", |
122 | | - "uspGetRandomFAQ", |
123 | | - "uspGetRegCompChrt", |
124 | | - "uspGetRegCompV2", |
125 | | - "uspGetRegCompV5", |
126 | | - "uspMergeCustomisations", |
127 | | - "uspNonCompleterSurveys", |
128 | | - "uspNonCompleterSurveysTest", |
129 | | - "uspReturnProgressDetail_V2", |
130 | | - "uspReturnSectionsForCandCustOld", |
131 | | - "uspSaveNewCandidate_V6", |
132 | | - "uspSaveNewCandidate_V8", |
133 | | - "uspSearchKnowledgeBank_V2", |
134 | | - "uspSearchKnowledgeBankByLevel", |
135 | | - "uspStoreRegistration_V2", |
136 | | - "uspTicketsOverTime", |
137 | | - "uspUpdateCandidate_V6", |
138 | | - "uspUpdateCandidateEmailCheck_V2" |
139 | | - }; |
140 | | - |
141 | | - return oldProcedureNames; |
142 | | - } |
143 | | - } |
144 | | -} |
| 24 | + } |
| 25 | + public override void Down() |
| 26 | + { |
| 27 | + string[] procedureNames = GetProcedureNames(); |
| 28 | + |
| 29 | + foreach (string procedureName in procedureNames) |
| 30 | + { |
| 31 | + string currentProcedureName = procedureName + "_deprecated"; |
| 32 | + string renameQuery = $"EXEC sp_rename '{currentProcedureName}', '{procedureName}';"; |
| 33 | + |
| 34 | + Execute.Sql(renameQuery); |
| 35 | + } |
| 36 | + } |
| 37 | + |
| 38 | + public static string[] GetProcedureNames() |
| 39 | + { |
| 40 | + string[] oldProcedureNames = |
| 41 | + { |
| 42 | + "aspnet_Personalization_GetApplicationId", |
| 43 | + "aspnet_AnyDataInTables", |
| 44 | + "aspnet_Applications_CreateApplication", |
| 45 | + "aspnet_CheckSchemaVersion", |
| 46 | + "aspnet_Membership_ChangePasswordQuestionAndAnswer", |
| 47 | + "aspnet_Membership_CreateUser", |
| 48 | + "aspnet_Membership_FindUsersByEmail", |
| 49 | + "aspnet_Membership_FindUsersByName", |
| 50 | + "aspnet_Membership_GetAllUsers", |
| 51 | + "aspnet_Membership_GetNumberOfUsersOnline", |
| 52 | + "aspnet_Membership_GetPassword", |
| 53 | + "aspnet_Membership_GetPasswordWithFormat", |
| 54 | + "aspnet_Membership_GetUserByEmail", |
| 55 | + "aspnet_Membership_GetUserByName", |
| 56 | + "aspnet_Membership_GetUserByUserId", |
| 57 | + "aspnet_Membership_ResetPassword", |
| 58 | + "aspnet_Membership_SetPassword", |
| 59 | + "aspnet_Membership_UnlockUser", |
| 60 | + "aspnet_Membership_UpdateUser", |
| 61 | + "aspnet_Membership_UpdateUserInfo", |
| 62 | + "aspnet_Paths_CreatePath", |
| 63 | + "aspnet_PersonalizationAdministration_DeleteAllState", |
| 64 | + "aspnet_PersonalizationAdministration_FindState", |
| 65 | + "aspnet_PersonalizationAdministration_GetCountOfState", |
| 66 | + "aspnet_PersonalizationAdministration_ResetSharedState", |
| 67 | + "aspnet_PersonalizationAdministration_ResetUserState", |
| 68 | + "aspnet_PersonalizationAllUsers_GetPageSettings", |
| 69 | + "aspnet_PersonalizationAllUsers_ResetPageSettings", |
| 70 | + "aspnet_PersonalizationAllUsers_SetPageSettings", |
| 71 | + "aspnet_PersonalizationPerUser_GetPageSettings", |
| 72 | + "aspnet_PersonalizationPerUser_ResetPageSettings", |
| 73 | + "aspnet_PersonalizationPerUser_SetPageSettings", |
| 74 | + "aspnet_Profile_DeleteInactiveProfiles", |
| 75 | + "aspnet_Profile_DeleteProfiles", |
| 76 | + "aspnet_Profile_GetNumberOfInactiveProfiles", |
| 77 | + "aspnet_Profile_GetProfiles", |
| 78 | + "aspnet_Profile_GetProperties", |
| 79 | + "aspnet_Profile_SetProperties", |
| 80 | + "aspnet_RegisterSchemaVersion", |
| 81 | + "aspnet_Roles_CreateRole", |
| 82 | + "aspnet_Roles_DeleteRole", |
| 83 | + "aspnet_Roles_GetAllRoles", |
| 84 | + "aspnet_Roles_RoleExists", |
| 85 | + "aspnet_Setup_RemoveAllRoleMembers", |
| 86 | + "aspnet_Setup_RestorePermissions", |
| 87 | + "aspnet_UnRegisterSchemaVersion", |
| 88 | + "aspnet_Users_CreateUser", |
| 89 | + "aspnet_Users_DeleteUser", |
| 90 | + "aspnet_UsersInRoles_AddUsersToRoles", |
| 91 | + "aspnet_UsersInRoles_FindUsersInRole", |
| 92 | + "aspnet_UsersInRoles_GetRolesForUser", |
| 93 | + "aspnet_UsersInRoles_GetUsersInRoles", |
| 94 | + "aspnet_UsersInRoles_IsUserInRole", |
| 95 | + "aspnet_UsersInRoles_RemoveUsersFromRoles", |
| 96 | + "aspnet_WebEvent_LogEvent", |
| 97 | + "ClearSectionBookmark", |
| 98 | + "GetActiveAvailableCustomisationsForCentreFiltered_V2", |
| 99 | + "GetActiveAvailableCustomisationsForCentreFiltered_V3", |
| 100 | + "GetDelegatesForCustomisation_V2", |
| 101 | + "GetDelegatesForCustomisation_V3", |
| 102 | + "GetDelegatesForCustomisation_V4", |
| 103 | + "GetKnowledgeBankData", |
| 104 | + "GetSelfAssessmentDashboardDataPivot", |
| 105 | + "GroupDelegates_Add_QT", |
| 106 | + "InsertUserNotificationIfNotExists", |
| 107 | + "PrePopulateActivityLog", |
| 108 | + "PurgeDelegatesForCentre", |
| 109 | + "uspCandidatesForAllCustomisations", |
| 110 | + "uspCandidatesForCentre", |
| 111 | + "uspCandidatesForCentre_V5", |
| 112 | + "uspCandidatesForCentre_V6", |
| 113 | + "uspCandidatesForCustomisation", |
| 114 | + "uspCandidatesForCustomisation_V5", |
| 115 | + "uspCandidatesForCustomisation_V6", |
| 116 | + "uspCreateProgressRecord_V2", |
| 117 | + "uspEvaluationSummaryDateRangeV2", |
| 118 | + "uspEvaluationSummaryDateRangeV3", |
| 119 | + "uspFollowUpSurveys", |
| 120 | + "uspFollowUpSurveysTest", |
| 121 | + "uspGetCentreRankKB", |
| 122 | + "uspGetKBTopTen", |
| 123 | + "uspGetRandomFAQ", |
| 124 | + "uspGetRegCompChrt", |
| 125 | + "uspGetRegCompV2", |
| 126 | + "uspGetRegCompV5", |
| 127 | + "uspMergeCustomisations", |
| 128 | + "uspNonCompleterSurveys", |
| 129 | + "uspNonCompleterSurveysTest", |
| 130 | + "uspReturnProgressDetail_V2", |
| 131 | + "uspReturnSectionsForCandCustOld", |
| 132 | + "uspSaveNewCandidate_V6", |
| 133 | + "uspSaveNewCandidate_V8", |
| 134 | + "uspSearchKnowledgeBank_V2", |
| 135 | + "uspSearchKnowledgeBankByLevel", |
| 136 | + "uspStoreRegistration_V2", |
| 137 | + "uspTicketsOverTime", |
| 138 | + "uspUpdateCandidate_V6", |
| 139 | + "uspUpdateCandidateEmailCheck_V2" |
| 140 | + }; |
| 141 | + |
| 142 | + return oldProcedureNames; |
| 143 | + } |
| 144 | + } |
| 145 | +} |
0 commit comments