|
| 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 | + } |
| 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 | +} |
0 commit comments