From 5f377c7d11ab6659a3f0a97fa23766573ba8c942 Mon Sep 17 00:00:00 2001 From: Pierre Date: Fri, 8 May 2020 14:23:32 +0200 Subject: SONAR-13221 move migrations from v83 to v84 --- .../db/migration/MigrationConfigurationModule.java | 6 +- .../db/migration/version/v83/DbVersion83.java | 750 -------------------- .../version/v83/DropIdFromComponentsTable.java | 2 +- ...KeyOnUuidColumnOfActiveRuleParametersTable.java | 38 - .../AddUuidColumnToActiveRuleParametersTable.java | 31 - .../DropIdColumnOfActiveRuleParametersTable.java | 31 - ...ryKeyOnIdColumnOfActiveRuleParametersTable.java | 32 - ...eActiveRuleParametersUuidColumnNotNullable.java | 31 - .../PopulateActiveRuleParametersUuid.java | 50 -- ...ActiveRuleUuidColumnToActiveRuleParameters.java | 50 -- ...nActiveRuleUuidOfActiveRuleParametersTable.java | 61 -- ...ddPrimaryKeyOnUuidColumnOfActiveRulesTable.java | 38 - .../AddUuidColumnToActiveRulesTable.java | 31 - ...iveRuleIdColumnOfActiveRuleParametersTable.java | 36 - .../DropIdColumnOfActiveRulesTable.java | 31 - ...xOnActiveRuleIdOfActiveRuleParametersTable.java | 52 -- ...DropPrimaryKeyOnIdColumnOfActiveRulesTable.java | 32 - ...iveRuleParametersActiveRuleUuidNotNullable.java | 50 -- .../MakeActiveRulesUuidColumnNotNullable.java | 31 - ...PopulateActiveRuleParametersActiveRuleUuid.java | 49 -- .../v83/activerules/PopulateActiveRulesUuid.java | 50 -- ...AddPrimaryKeyOnUuidColumnOfCeActivityTable.java | 38 - .../ceactivity/DropIdColumnOfCeActivityTable.java | 31 - .../DropPrimaryKeyOnIdColumnOfCeActivityTable.java | 32 - .../AddPrimaryKeyOnUuidColumnOfCeQueueTable.java | 38 - .../v83/cequeue/DropIdColumnOfCeQueueTable.java | 31 - .../DropPrimaryKeyOnIdColumnOfCeQueueTable.java | 32 - .../DropUniqueIndexOnUuidColumnOfCeQueueTable.java | 41 -- .../version/v83/common/AddUuidColumnToTable.java | 51 -- .../migration/version/v83/common/DropIdColumn.java | 42 -- .../v83/common/DropPrimaryKeyOnIdColumn.java | 41 -- .../v83/common/MakeUuidColumnNotNullable.java | 51 -- ...aryKeyOnUuidColumnOfDuplicationsIndexTable.java | 38 - .../AddUuidToDuplicationsIndexTable.java | 31 - .../DropIdColumnOfDuplicationsIndexTable.java | 31 - ...imaryKeyOnIdColumnOfDuplicationsIndexTable.java | 32 - ...MakeDuplicationsIndexUuidColumnNotNullable.java | 31 - .../PopulateDuplicationsIndexUuid.java | 50 -- .../AddPrimaryKeyOnUuidColumnOfEventsTable.java | 38 - .../v83/events/DropIdColumnOfEventsTable.java | 31 - .../DropPrimaryKeyOnIdColumnOfEventsTable.java | 32 - ...ddPrimaryKeyOnUuidColumnOfFileSourcesTable.java | 38 - .../AddUuidColumnToFileSourcesTable.java | 31 - .../DropIdColumnOfFileSourcesTable.java | 31 - ...DropPrimaryKeyOnIdColumnOfFileSourcesTable.java | 32 - .../MakeFileSourcesUuidColumnNotNullable.java | 31 - .../v83/filesources/PopulateFileSourcesUuid.java | 50 -- ...AddPrimaryKeyOnUuidColumnOfGroupRolesTable.java | 38 - .../grouproles/AddUuidColumnToGroupRolesTable.java | 31 - .../grouproles/DropIdColumnOfGroupRolesTable.java | 41 -- .../DropPrimaryKeyOnIdColumnOfGroupRolesTable.java | 32 - .../MakeGroupRolesUuidColumnNotNullable.java | 31 - .../v83/grouproles/PopulateGroupRolesUuid.java | 50 -- .../AddPrimaryKeyOnUuidColumnOfGroupsTable.java | 38 - .../v83/groups/AddUuidColumnToGroupsTable.java | 31 - .../v83/groups/DropIdColumnOfGroupsTable.java | 31 - .../DropPrimaryKeyOnIdColumnOfGroupsTable.java | 32 - .../groups/MakeGroupsUuidColumnNotNullable.java | 31 - .../version/v83/groups/PopulateGroupsUuid.java | 50 -- .../grouproles/AddGroupUuidColumnToGroupRoles.java | 50 -- .../AddIndexOnGroupUuidOfGroupRolesTable.java | 76 -- .../DropGroupIdColumnOfGroupRolesTable.java | 36 - .../DropIndexOnGroupIdOfGroupRolesTable.java | 52 -- .../grouproles/PopulateGroupRolesGroupUuid.java | 49 -- .../AddGroupUuidColumnToGroupsUsers.java | 50 -- .../AddIndexOnGroupUuidOfGroupsUsersTable.java | 76 -- .../DropGroupIdColumnOfGroupsUsersTable.java | 36 - .../DropIndexOnGroupIdOfGroupsUsersTable.java | 59 -- .../MakeGroupsUsersGroupUuidNotNullable.java | 50 -- .../groupsusers/PopulateGroupsUsersGroupUuid.java | 51 -- .../AddDefaultGroupUuidColumnToOrganizations.java | 50 -- ...opDefaultGroupIdColumnOfOrganizationsTable.java | 36 - .../PopulateOrganizationsDefaultGroupUuid.java | 49 -- .../AddGroupUuidColumnToPermTemplatesGroups.java | 50 -- ...ropGroupIdColumnOfPermTemplatesGroupsTable.java | 36 - .../PopulatePermTemplatesGroupsGroupUuid.java | 49 -- .../AddGroupUuidColumnToQProfileEditGroups.java | 50 -- ...dIndexOnGroupUuidOfQProfileEditGroupsTable.java | 66 -- ...DropGroupIdColumnOfQProfileEditGroupsTable.java | 36 - ...ropIndexOnGroupIdOfQProfileEditGroupsTable.java | 52 -- ...MakeQProfileEditGroupsGroupUuidNotNullable.java | 50 -- .../PopulateQProfileEditGroupsGroupUuid.java | 49 -- ...dPrimaryKeyOnUuidColumnOfIssueChangesTable.java | 38 - .../AddUuidColumnToIssueChangesTable.java | 31 - .../DropIdColumnOfIssueChangesTable.java | 31 - ...ropPrimaryKeyOnIdColumnOfIssueChangesTable.java | 32 - .../MakeIssueChangesUuidColumnNotNullable.java | 31 - .../v83/issuechanges/PopulateIssueChangesUuid.java | 50 -- .../AddPrimaryKeyOnKeeColumnOfIssuesTable.java | 38 - .../v83/issues/DropIdColumnOfIssuesTable.java | 31 - .../DropPrimaryKeyOnIdColumnOfIssuesTable.java | 32 - ...rimaryKeyOnUuidColumnOfManualMeasuresTable.java | 38 - .../AddUuidColumnToManualMeasures.java | 50 -- .../DropIdColumnOfManualMeasuresTable.java | 37 - ...pPrimaryKeyOnIdColumnOfManualMeasuresTable.java | 41 -- .../MakeManualMeasuresUuidColumnNotNullable.java | 50 -- .../manualmeasures/PopulateManualMeasureUuid.java | 50 -- .../AddPrimaryKeyOnUuidColumnOfMetricsTable.java | 38 - .../v83/metrics/AddUuidColumnToMetricsTable.java | 31 - .../v83/metrics/DropIdColumnOfMetricsTable.java | 31 - .../DropPrimaryKeyOnIdColumnOfMetricsTable.java | 32 - .../metrics/MakeMetricsUuidColumnNotNullable.java | 31 - .../version/v83/metrics/PopulateMetricsUuid.java | 50 -- .../AddIndexOnMetricUuidOfLiveMeasuresTable.java | 66 -- .../AddMetricUuidColumnToLiveMeasures.java | 50 -- .../DropIndexOnMetricIdOfLiveMeasuresTable.java | 52 -- .../DropMetricIdColumnOfLiveMeasuresTable.java | 36 - .../MakeLiveMeasuresMetricUuidNotNullable.java | 50 -- .../PopulateLiveMeasuresMetricUuid.java | 49 -- .../AddMetricUuidColumnToManualMeasures.java | 50 -- .../DropMetricIdColumnOfManualMeasuresTable.java | 36 - .../MakeManualMeasuresMetricUuidNotNullable.java | 50 -- .../PopulateManualMeasuresMetricUuid.java | 49 -- ...AddIndexOnMetricUuidOfProjectMeasuresTable.java | 66 -- .../AddMetricUuidColumnToProjectMeasures.java | 50 -- .../DropIndexOnMetricIdOfProjectMeasuresTable.java | 52 -- .../DropMetricIdColumnOfProjectMeasuresTable.java | 36 - .../MakeProjectMeasuresMetricUuidNotNullable.java | 50 -- .../PopulateProjectMeasuresMetricUuid.java | 49 -- ...AddMetricUuidColumnToQualityGateConditions.java | 50 -- ...MetricIdColumnOfQualityGateConditionsTable.java | 36 - ...QualityGateConditionsMetricUuidNotNullable.java | 50 -- .../PopulateQualityGateConditionsMetricUuid.java | 52 -- ...dPrimaryKeyOnUuidColumnOfNotificationTable.java | 38 - .../AddUuidAndCreatedAtColumnsToNotification.java | 58 -- .../DropIdColumnOfNotificationTable.java | 31 - ...ropPrimaryKeyOnIdColumnOfNotificationTable.java | 32 - ...ficationUuidAndCreatedAtColumnsNotNullable.java | 59 -- .../PopulateNotificationUuidAndCreatedAt.java | 60 -- .../db/migration/version/v83/package-info.java | 23 - ...yKeyOnUuidColumnOfPermissionTemplatesTable.java | 38 - .../AddUuidColumnToPermissionTemplates.java | 31 - .../DropIdColumnOfPermissionTemplatesTable.java | 31 - .../DropKeeColumnOfPermissionTemplatesTable.java | 37 - ...aryKeyOnIdColumnOfPermissionTemplatesTable.java | 32 - ...akePermissionTemplateUuidColumnNotNullable.java | 31 - .../PopulatePermissionTemplatesUuid.java | 58 -- ...AddTemplateUuidColumnToPermTemplatesGroups.java | 50 -- ...TemplateIdColumnOfPermTemplatesGroupsTable.java | 37 - ...mplatesGroupsTemplateUuidColumnNotNullable.java | 50 -- ...ulatePermTemplatesGroupsTemplateUuidColumn.java | 49 -- .../AddTemplateUuidColumnToPermTemplatesUsers.java | 50 -- ...pTemplateIdColumnOfPermTemplatesUsersTable.java | 37 - ...emplatesUsersTemplateUuidColumnNotNullable.java | 50 -- ...pulatePermTemplatesUsersTemplateUuidColumn.java | 49 -- ...TemplateUuidColumnToPermTplCharacteristics.java | 50 -- ...ionKeyColumnsOfPermTplCharacteristicsTable.java | 67 -- ...plateIdColumnOfPermTplCharacteristicsTable.java | 37 - ...ionKeyColumnsOfPermTplCharacteristicsTable.java | 52 -- ...aracteristicsTemplateUuidColumnNotNullable.java | 50 -- ...tePermTplCharacteristicsTemplateUuidColumn.java | 49 -- ...yKeyOnUuidColumnOfPermTemplatesGroupsTable.java | 38 - .../AddUuidColumnToPermTemplatesGroupsTable.java | 31 - .../DropIdColumnOfPermTemplatesGroupsTable.java | 31 - ...aryKeyOnIdColumnOfPermTemplatesGroupsTable.java | 32 - ...kePermTemplatesGroupsUuidColumnNotNullable.java | 31 - .../PopulatePermTemplatesGroupsUuid.java | 50 -- ...ryKeyOnUuidColumnOfPermTemplatesUsersTable.java | 38 - .../AddUuidColumnToPermTemplatesUsersTable.java | 31 - .../DropIdColumnOfPermTemplatesUsersTable.java | 31 - ...maryKeyOnIdColumnOfPermTemplatesUsersTable.java | 32 - ...akePermTemplatesUsersUuidColumnNotNullable.java | 31 - .../PopulatePermTemplatesUsersUuid.java | 50 -- ...yOnUuidColumnOfPermTplCharacteristicsTable.java | 38 - ...AddUuidColumnToPermTplCharacteristicsTable.java | 31 - .../DropIdColumnOfPermTplCharacteristicsTable.java | 31 - ...KeyOnIdColumnOfPermTplCharacteristicsTable.java | 32 - ...ermTplCharacteristicsUuidColumnNotNullable.java | 31 - .../PopulatePermTplCharacteristicsUuid.java | 50 -- ...imaryKeyOnUuidColumnOfProjectMeasuresTable.java | 38 - .../AddUuidColumnToProjectMeasures.java | 31 - .../DropIdColumnOfProjectMeasuresTable.java | 31 - ...PrimaryKeyOnIdColumnOfProjectMeasuresTable.java | 32 - .../MakeProjectMeasuresUuidColumnNotNullable.java | 31 - .../PopulateProjectMeasureUuid.java | 50 -- ...maryKeyOnUuidColumnOfProjectQProfilesTable.java | 38 - .../AddUuidColumnToProjectQProfilesTable.java | 50 -- .../DropIdColumnOfProjectQProfilesTable.java | 41 -- ...rimaryKeyOnIdColumnOfProjectQProfilesTable.java | 41 -- .../MakeProjectQProfilesUuidColumnNotNullable.java | 50 -- .../PopulateProjectQProfilesUuid.java | 51 -- ...AddPrimaryKeyOnUuidColumnOfPropertiesTable.java | 38 - .../v83/properties/AddUuidColumnToProperties.java | 31 - .../properties/DropIdColumnOfPropertiesTable.java | 37 - .../DropPrimaryKeyOnIdColumnOfPropertiesTable.java | 34 - .../MakePropertiesUuidColumnNotNullable.java | 31 - .../v83/properties/PopulatePropertiesUuid.java | 50 -- ...eyOnUuidColumnOfQualityGateConditionsTable.java | 38 - .../AddUuidColumnToQualityGateConditionsTable.java | 31 - .../DropIdColumnOfQualityGateConditionsTable.java | 31 - ...yKeyOnIdColumnOfQualityGateConditionsTable.java | 32 - ...QualityGateConditionsUuidColumnNotNullable.java | 31 - .../PopulateQualityGateConditionsUuid.java | 50 -- .../AddPrimaryKeyOnUuidColumnOfQGatesTable.java | 38 - .../AddQGateUuidColumnForQGateConditions.java | 51 -- .../v83/qualitygates/DropIdColumnOfQGateTable.java | 31 - .../qualitygates/DropOrphansQGateConditions.java | 45 -- .../DropPrimaryKeyOnIdColumnOfQGatesTable.java | 34 - .../DropQGateIdColumnForQGateConditions.java | 41 -- ...UniqueIndexOnUuidColumnOfQualityGatesTable.java | 40 -- ...ateUuidColumnNotNullableForQGateConditions.java | 50 -- .../PopulateQGateUuidColumnForQGateConditions.java | 46 -- .../AddPrimaryKeyOnUuidColumnOfRulesTable.java | 38 - .../AddUuidAndTemplateUuidColumnsToRules.java | 58 -- .../v83/rules/DropIdColumnOfRulesTable.java | 37 - .../DropPrimaryKeyOnIdColumnOfRulesTable.java | 41 -- .../rules/DropTemplateIdColumnOfRulesTable.java | 37 - .../v83/rules/MakeRulesUuidColumnNotNullable.java | 50 -- .../v83/rules/PopulateRulesTemplateUuid.java | 49 -- .../version/v83/rules/PopulateRulesUuid.java | 50 -- .../activerules/AddIndexToActiveRulesTable.java | 70 -- .../AddRuleUuidColumnToActiveRulesTable.java | 50 -- .../DropIndexOnRuleIdColumnOfActiveRulesTable.java | 43 -- .../DropRuleIdColumnOfActiveRulesTable.java | 37 - .../MakeActiveRulesRuleUuidColumnNotNullable.java | 50 -- .../PopulateActiveRulesRuleUuidColumn.java | 49 -- .../AddIndexToDeprecatedRuleKeysTable.java | 63 -- ...AddRuleUuidColumnToDeprecatedRuleKeysTable.java | 50 -- ...dexOnRuleIdColumnOfDeprecatedRuleKeysTable.java | 41 -- .../DropRuleIdColumnOfDeprecatedRuleKeysTable.java | 37 - ...eprecatedRuleKeysRuleUuidColumnNotNullable.java | 50 -- .../PopulateDeprecatedRuleKeysRuleUuidColumn.java | 49 -- .../v83/rules/issues/AddIndexToIssuesTable.java | 62 -- .../issues/AddRuleUuidColumnToIssuesTable.java | 49 -- .../DropIndexOnRuleIdColumnOfIssuesTable.java | 41 -- .../issues/DropRuleIdColumnOfIssuesTable.java | 37 - .../rules/issues/PopulateIssuesRuleUuidColumn.java | 49 -- ...OrganizationUuidColumnOfRulesMetadataTable.java | 38 - .../AddRuleUuidColumnToRulesMetadataTable.java | 50 -- ...opPrimaryKeyOnIdColumnOfRulesMetadataTable.java | 41 -- .../DropRuleIdColumnOfRulesMetadataTable.java | 37 - ...MakeRulesMetadataRuleUuidColumnNotNullable.java | 50 -- .../PopulateRulesMetadataRuleUuidColumn.java | 49 -- .../AddIndexesToRulesParametersTable.java | 81 --- .../AddRuleUuidColumnToRulesParametersTable.java | 50 -- ...ndexesOnRuleIdColumnOfRulesParametersTable.java | 45 -- .../DropRuleIdColumnOfRulesParametersTable.java | 37 - ...keRulesParametersRuleUuidColumnNotNullable.java | 50 -- .../PopulateRulesParametersRuleUuidColumn.java | 49 -- ...imaryKeyOnUuidColumnOfRulesParametersTable.java | 38 - .../AddUuidColumnToRulesParameters.java | 31 - .../DropIdColumnOfRulesParametersTable.java | 31 - ...PrimaryKeyOnIdColumnOfRulesParametersTable.java | 32 - .../MakeRulesParametersUuidColumnNotNullable.java | 31 - .../PopulateRulesParametersUuid.java | 50 -- ...sParameterUuidColumnToActiveRuleParameters.java | 50 -- ...rameterIdColumnOfActiveRuleParametersTable.java | 37 - ...ametersRulesParameterUuidColumnNotNullable.java | 50 -- ...lateActiveRuleParametersRulesParameterUuid.java | 49 -- ...PrimaryKeyOnUuidColumnOfRulesProfilesTable.java | 38 - .../AddUuidColumnToRulesProfilesTable.java | 31 - .../DropIdColumnOfRulesProfilesTable.java | 33 - .../DropKeeColumnOfRulesProfilesTable.java | 41 -- ...opPrimaryKeyOnIdColumnOfRulesProfilesTable.java | 32 - ...UniqueIndexOnKeeColumnOfRulesProfilesTable.java | 52 -- .../MakeRulesProfilesUuidColumnNotNullable.java | 32 - .../rulesprofiles/PopulateRulesProfilesUuid.java | 50 -- .../AddProfileUuidColumnToActiveRulesTable.java | 50 -- ...IndexOnProfileUuidColumnOfActiveRulesTable.java | 67 -- .../DropProfileIdColumnOfActiveRulesTable.java | 41 -- ...ueIndexOnProfileIdColumnOfActiveRulesTable.java | 52 -- ...akeActiveRulesProfileUuidColumnNotNullable.java | 50 -- .../PopulateActiveRulesProfileUuid.java | 49 -- .../PopulateOrgQProfilesRulesProfileUuid.java | 48 -- .../PopulateQProfileChangesRulesProfileUuid.java | 48 -- .../AddPrimaryKeyOnUuidColumnOfSnapshotsTable.java | 38 - .../issues/DropIdColumnOfSnapshotsTable.java | 31 - .../DropPrimaryKeyOnIdColumnOfSnapshotsTable.java | 41 -- .../AddPrimaryKeyOnUuidColumnOfUserRolesTable.java | 38 - .../userroles/AddUuidColumnToUserRolesTable.java | 31 - .../userroles/DropIdColumnOfUserRolesTable.java | 29 - .../DropPrimaryKeyOnIdColumnOfUserRolesTable.java | 32 - .../MakeUserRolesUuidColumnNotNullable.java | 31 - .../v83/userroles/PopulateUserRolesUuid.java | 50 -- .../AddPrimaryKeyOnUuidColumnOfUsersTable.java | 38 - .../v83/users/DropIdColumnOfUsersTable.java | 32 - .../DropPrimaryKeyOnIdColumnOfUsersTable.java | 33 - .../DropUniqueIndexOnUuidColumnOfUsersTable.java | 53 -- .../AddIndexOnUserUuidOfGroupsUsersTable.java | 60 -- ...ndexOnUserUuidAndGroupIdOfGroupsUsersTable.java | 65 -- .../AddUserUuidColumnToGroupsUsers.java | 29 - .../DropIndexOnUserIdOfGroupsUsersTable.java | 52 -- ...eIndexOnUserIdAndGroupIdOfGroupsUsersTable.java | 52 -- .../DropUserIdColumnOfGroupsUsersTable.java | 37 - .../MakeGroupsUsersUserUuidColumnNotNullable.java | 50 -- .../groupsusers/PopulateGroupsUsersUserUuid.java | 53 -- ...dIndexOnUserUuidOfOrganizationMembersTable.java | 60 -- ...AndOrganizationUuidColumnsOfUserRolesTable.java | 38 - .../AddUserUuidColumnToOrganizationMembers.java | 29 - ...ropIndexOnUserIdOfOrganizationMembersTable.java | 52 -- ...OrganizationUuidOfOrganizationMembersTable.java | 41 -- ...DropUserIdColumnOfOrganizationMembersTable.java | 36 - ...ganizationMembersUserUuidColumnNotNullable.java | 31 - .../PopulateOrganizationMembersUserUuid.java | 54 -- .../AddUserUuidColumnToPermTemplatesUsers.java | 30 - .../DropUserIdColumnOfPermTemplatesUsersTable.java | 36 - ...ermTemplatesUsersUserUuidColumnNotNullable.java | 31 - .../PopulatePermTemplatesUsersUserUuid.java | 52 -- .../AddUserUuidColumnToPropertiesUsers.java | 30 - .../DropUserIdColumnOfPropertiesTable.java | 36 - .../fk/properties/PopulatePropertiesUserUuid.java | 52 -- ...uidAndQProfileUuidOfQProfileEditUsersTable.java | 64 -- .../AddUserUuidColumnToQProfileEditUsers.java | 30 - ...rIdAndQProfileUuidOfQProfileEditUsersTable.java | 52 -- .../DropUserIdColumnOfQProfileEditUsersTable.java | 36 - ...QProfileEditUsersUserUuidColumnNotNullable.java | 31 - .../PopulateQProfileEditUsersUserUuid.java | 52 -- .../AddIndexOnUserUuidOfUserRolesTable.java | 60 -- .../fk/userroles/AddUserUuidColumnToUserRoles.java | 30 - .../DropIndexOnUserIdOfUserRolesTable.java | 52 -- .../DropUserIdColumnOfUserRolesTable.java | 36 - .../fk/userroles/PopulateUserRolesUserUuid.java | 52 -- .../users/fk/util/AddUserUuidColumnToTable.java | 51 -- .../fk/util/MakeUserUuidColumnNotNullable.java | 51 -- ...AddPrimaryKeyOnUuidColumnOfUserTokensTable.java | 38 - .../v83/usertokens/AddUuidColumnToUserTokens.java | 31 - .../usertokens/DropIdColumnOfUserTokensTable.java | 31 - .../DropPrimaryKeyOnIdColumnOfUserTokensTable.java | 32 - .../usertokens/MakeUserTokensUuidNotNullable.java | 31 - .../v83/usertokens/PopulateUserTokensUuid.java | 52 -- .../version/v83/util/AddPrimaryKeyBuilder.java | 46 -- .../v83/util/DropPrimaryKeySqlGenerator.java | 99 --- .../db/migration/version/v83/util/SqlHelper.java | 116 --- .../db/migration/version/v84/DbVersion84.java | 781 +++++++++++++++++++++ ...KeyOnUuidColumnOfActiveRuleParametersTable.java | 38 + .../AddUuidColumnToActiveRuleParametersTable.java | 31 + .../DropIdColumnOfActiveRuleParametersTable.java | 31 + ...ryKeyOnIdColumnOfActiveRuleParametersTable.java | 32 + ...eActiveRuleParametersUuidColumnNotNullable.java | 31 + .../PopulateActiveRuleParametersUuid.java | 50 ++ ...ActiveRuleUuidColumnToActiveRuleParameters.java | 50 ++ ...nActiveRuleUuidOfActiveRuleParametersTable.java | 61 ++ ...ddPrimaryKeyOnUuidColumnOfActiveRulesTable.java | 38 + .../AddUuidColumnToActiveRulesTable.java | 31 + ...iveRuleIdColumnOfActiveRuleParametersTable.java | 36 + .../DropIdColumnOfActiveRulesTable.java | 31 + ...xOnActiveRuleIdOfActiveRuleParametersTable.java | 52 ++ ...DropPrimaryKeyOnIdColumnOfActiveRulesTable.java | 32 + ...iveRuleParametersActiveRuleUuidNotNullable.java | 50 ++ .../MakeActiveRulesUuidColumnNotNullable.java | 31 + ...PopulateActiveRuleParametersActiveRuleUuid.java | 49 ++ .../v84/activerules/PopulateActiveRulesUuid.java | 50 ++ ...AddPrimaryKeyOnUuidColumnOfCeActivityTable.java | 38 + .../ceactivity/DropIdColumnOfCeActivityTable.java | 31 + .../DropPrimaryKeyOnIdColumnOfCeActivityTable.java | 32 + .../AddPrimaryKeyOnUuidColumnOfCeQueueTable.java | 38 + .../v84/cequeue/DropIdColumnOfCeQueueTable.java | 31 + .../DropPrimaryKeyOnIdColumnOfCeQueueTable.java | 32 + .../DropUniqueIndexOnUuidColumnOfCeQueueTable.java | 41 ++ .../version/v84/common/AddUuidColumnToTable.java | 51 ++ .../migration/version/v84/common/DropIdColumn.java | 42 ++ .../v84/common/DropPrimaryKeyOnIdColumn.java | 41 ++ .../v84/common/MakeUuidColumnNotNullable.java | 51 ++ ...aryKeyOnUuidColumnOfDuplicationsIndexTable.java | 38 + .../AddUuidToDuplicationsIndexTable.java | 31 + .../DropIdColumnOfDuplicationsIndexTable.java | 31 + ...imaryKeyOnIdColumnOfDuplicationsIndexTable.java | 32 + ...MakeDuplicationsIndexUuidColumnNotNullable.java | 31 + .../PopulateDuplicationsIndexUuid.java | 50 ++ .../AddPrimaryKeyOnUuidColumnOfEventsTable.java | 38 + .../v84/events/DropIdColumnOfEventsTable.java | 31 + .../DropPrimaryKeyOnIdColumnOfEventsTable.java | 32 + ...ddPrimaryKeyOnUuidColumnOfFileSourcesTable.java | 38 + .../AddUuidColumnToFileSourcesTable.java | 31 + .../DropIdColumnOfFileSourcesTable.java | 31 + ...DropPrimaryKeyOnIdColumnOfFileSourcesTable.java | 32 + .../MakeFileSourcesUuidColumnNotNullable.java | 31 + .../v84/filesources/PopulateFileSourcesUuid.java | 50 ++ ...AddPrimaryKeyOnUuidColumnOfGroupRolesTable.java | 38 + .../grouproles/AddUuidColumnToGroupRolesTable.java | 31 + .../grouproles/DropIdColumnOfGroupRolesTable.java | 41 ++ .../DropPrimaryKeyOnIdColumnOfGroupRolesTable.java | 32 + .../MakeGroupRolesUuidColumnNotNullable.java | 31 + .../v84/grouproles/PopulateGroupRolesUuid.java | 50 ++ .../AddPrimaryKeyOnUuidColumnOfGroupsTable.java | 38 + .../v84/groups/AddUuidColumnToGroupsTable.java | 31 + .../v84/groups/DropIdColumnOfGroupsTable.java | 31 + .../DropPrimaryKeyOnIdColumnOfGroupsTable.java | 32 + .../groups/MakeGroupsUuidColumnNotNullable.java | 31 + .../version/v84/groups/PopulateGroupsUuid.java | 50 ++ .../grouproles/AddGroupUuidColumnToGroupRoles.java | 50 ++ .../AddIndexOnGroupUuidOfGroupRolesTable.java | 76 ++ .../DropGroupIdColumnOfGroupRolesTable.java | 36 + .../DropIndexOnGroupIdOfGroupRolesTable.java | 52 ++ .../grouproles/PopulateGroupRolesGroupUuid.java | 49 ++ .../AddGroupUuidColumnToGroupsUsers.java | 50 ++ .../AddIndexOnGroupUuidOfGroupsUsersTable.java | 76 ++ .../DropGroupIdColumnOfGroupsUsersTable.java | 36 + .../DropIndexOnGroupIdOfGroupsUsersTable.java | 59 ++ .../MakeGroupsUsersGroupUuidNotNullable.java | 50 ++ .../groupsusers/PopulateGroupsUsersGroupUuid.java | 51 ++ .../AddDefaultGroupUuidColumnToOrganizations.java | 50 ++ ...opDefaultGroupIdColumnOfOrganizationsTable.java | 36 + .../PopulateOrganizationsDefaultGroupUuid.java | 49 ++ .../AddGroupUuidColumnToPermTemplatesGroups.java | 50 ++ ...ropGroupIdColumnOfPermTemplatesGroupsTable.java | 36 + .../PopulatePermTemplatesGroupsGroupUuid.java | 49 ++ .../AddGroupUuidColumnToQProfileEditGroups.java | 50 ++ ...dIndexOnGroupUuidOfQProfileEditGroupsTable.java | 66 ++ ...DropGroupIdColumnOfQProfileEditGroupsTable.java | 36 + ...ropIndexOnGroupIdOfQProfileEditGroupsTable.java | 52 ++ ...MakeQProfileEditGroupsGroupUuidNotNullable.java | 50 ++ .../PopulateQProfileEditGroupsGroupUuid.java | 49 ++ ...dPrimaryKeyOnUuidColumnOfIssueChangesTable.java | 38 + .../AddUuidColumnToIssueChangesTable.java | 31 + .../DropIdColumnOfIssueChangesTable.java | 31 + ...ropPrimaryKeyOnIdColumnOfIssueChangesTable.java | 32 + .../MakeIssueChangesUuidColumnNotNullable.java | 31 + .../v84/issuechanges/PopulateIssueChangesUuid.java | 50 ++ .../AddPrimaryKeyOnKeeColumnOfIssuesTable.java | 38 + .../v84/issues/DropIdColumnOfIssuesTable.java | 31 + .../DropPrimaryKeyOnIdColumnOfIssuesTable.java | 32 + ...rimaryKeyOnUuidColumnOfManualMeasuresTable.java | 38 + .../AddUuidColumnToManualMeasures.java | 50 ++ .../DropIdColumnOfManualMeasuresTable.java | 37 + ...pPrimaryKeyOnIdColumnOfManualMeasuresTable.java | 41 ++ .../MakeManualMeasuresUuidColumnNotNullable.java | 50 ++ .../manualmeasures/PopulateManualMeasureUuid.java | 50 ++ .../AddPrimaryKeyOnUuidColumnOfMetricsTable.java | 38 + .../v84/metrics/AddUuidColumnToMetricsTable.java | 31 + .../v84/metrics/DropIdColumnOfMetricsTable.java | 31 + .../DropPrimaryKeyOnIdColumnOfMetricsTable.java | 32 + .../metrics/MakeMetricsUuidColumnNotNullable.java | 31 + .../version/v84/metrics/PopulateMetricsUuid.java | 50 ++ .../AddIndexOnMetricUuidOfLiveMeasuresTable.java | 66 ++ .../AddMetricUuidColumnToLiveMeasures.java | 50 ++ .../DropIndexOnMetricIdOfLiveMeasuresTable.java | 52 ++ .../DropMetricIdColumnOfLiveMeasuresTable.java | 36 + .../MakeLiveMeasuresMetricUuidNotNullable.java | 50 ++ .../PopulateLiveMeasuresMetricUuid.java | 49 ++ .../AddMetricUuidColumnToManualMeasures.java | 50 ++ .../DropMetricIdColumnOfManualMeasuresTable.java | 36 + .../MakeManualMeasuresMetricUuidNotNullable.java | 50 ++ .../PopulateManualMeasuresMetricUuid.java | 49 ++ ...AddIndexOnMetricUuidOfProjectMeasuresTable.java | 66 ++ .../AddMetricUuidColumnToProjectMeasures.java | 50 ++ .../DropIndexOnMetricIdOfProjectMeasuresTable.java | 52 ++ .../DropMetricIdColumnOfProjectMeasuresTable.java | 36 + .../MakeProjectMeasuresMetricUuidNotNullable.java | 50 ++ .../PopulateProjectMeasuresMetricUuid.java | 49 ++ ...AddMetricUuidColumnToQualityGateConditions.java | 50 ++ ...MetricIdColumnOfQualityGateConditionsTable.java | 36 + ...QualityGateConditionsMetricUuidNotNullable.java | 50 ++ .../PopulateQualityGateConditionsMetricUuid.java | 52 ++ ...dPrimaryKeyOnUuidColumnOfNotificationTable.java | 38 + .../AddUuidAndCreatedAtColumnsToNotification.java | 58 ++ .../DropIdColumnOfNotificationTable.java | 31 + ...ropPrimaryKeyOnIdColumnOfNotificationTable.java | 32 + ...ficationUuidAndCreatedAtColumnsNotNullable.java | 59 ++ .../PopulateNotificationUuidAndCreatedAt.java | 60 ++ .../db/migration/version/v84/package-info.java | 23 + ...yKeyOnUuidColumnOfPermissionTemplatesTable.java | 38 + .../AddUuidColumnToPermissionTemplates.java | 31 + .../DropIdColumnOfPermissionTemplatesTable.java | 31 + .../DropKeeColumnOfPermissionTemplatesTable.java | 37 + ...aryKeyOnIdColumnOfPermissionTemplatesTable.java | 32 + ...akePermissionTemplateUuidColumnNotNullable.java | 31 + .../PopulatePermissionTemplatesUuid.java | 58 ++ ...AddTemplateUuidColumnToPermTemplatesGroups.java | 50 ++ ...TemplateIdColumnOfPermTemplatesGroupsTable.java | 37 + ...mplatesGroupsTemplateUuidColumnNotNullable.java | 50 ++ ...ulatePermTemplatesGroupsTemplateUuidColumn.java | 49 ++ .../AddTemplateUuidColumnToPermTemplatesUsers.java | 50 ++ ...pTemplateIdColumnOfPermTemplatesUsersTable.java | 37 + ...emplatesUsersTemplateUuidColumnNotNullable.java | 50 ++ ...pulatePermTemplatesUsersTemplateUuidColumn.java | 49 ++ ...TemplateUuidColumnToPermTplCharacteristics.java | 50 ++ ...ionKeyColumnsOfPermTplCharacteristicsTable.java | 67 ++ ...plateIdColumnOfPermTplCharacteristicsTable.java | 37 + ...ionKeyColumnsOfPermTplCharacteristicsTable.java | 52 ++ ...aracteristicsTemplateUuidColumnNotNullable.java | 50 ++ ...tePermTplCharacteristicsTemplateUuidColumn.java | 49 ++ ...yKeyOnUuidColumnOfPermTemplatesGroupsTable.java | 38 + .../AddUuidColumnToPermTemplatesGroupsTable.java | 31 + .../DropIdColumnOfPermTemplatesGroupsTable.java | 31 + ...aryKeyOnIdColumnOfPermTemplatesGroupsTable.java | 32 + ...kePermTemplatesGroupsUuidColumnNotNullable.java | 31 + .../PopulatePermTemplatesGroupsUuid.java | 50 ++ ...ryKeyOnUuidColumnOfPermTemplatesUsersTable.java | 38 + .../AddUuidColumnToPermTemplatesUsersTable.java | 31 + .../DropIdColumnOfPermTemplatesUsersTable.java | 31 + ...maryKeyOnIdColumnOfPermTemplatesUsersTable.java | 32 + ...akePermTemplatesUsersUuidColumnNotNullable.java | 31 + .../PopulatePermTemplatesUsersUuid.java | 50 ++ ...yOnUuidColumnOfPermTplCharacteristicsTable.java | 38 + ...AddUuidColumnToPermTplCharacteristicsTable.java | 31 + .../DropIdColumnOfPermTplCharacteristicsTable.java | 31 + ...KeyOnIdColumnOfPermTplCharacteristicsTable.java | 32 + ...ermTplCharacteristicsUuidColumnNotNullable.java | 31 + .../PopulatePermTplCharacteristicsUuid.java | 50 ++ ...imaryKeyOnUuidColumnOfProjectMeasuresTable.java | 38 + .../AddUuidColumnToProjectMeasures.java | 31 + .../DropIdColumnOfProjectMeasuresTable.java | 31 + ...PrimaryKeyOnIdColumnOfProjectMeasuresTable.java | 32 + .../MakeProjectMeasuresUuidColumnNotNullable.java | 31 + .../PopulateProjectMeasureUuid.java | 50 ++ ...maryKeyOnUuidColumnOfProjectQProfilesTable.java | 38 + .../AddUuidColumnToProjectQProfilesTable.java | 50 ++ .../DropIdColumnOfProjectQProfilesTable.java | 41 ++ ...rimaryKeyOnIdColumnOfProjectQProfilesTable.java | 41 ++ .../MakeProjectQProfilesUuidColumnNotNullable.java | 50 ++ .../PopulateProjectQProfilesUuid.java | 50 ++ ...AddPrimaryKeyOnUuidColumnOfPropertiesTable.java | 38 + .../v84/properties/AddUuidColumnToProperties.java | 31 + .../properties/DropIdColumnOfPropertiesTable.java | 37 + .../DropPrimaryKeyOnIdColumnOfPropertiesTable.java | 34 + .../MakePropertiesUuidColumnNotNullable.java | 31 + .../v84/properties/PopulatePropertiesUuid.java | 50 ++ ...eyOnUuidColumnOfQualityGateConditionsTable.java | 38 + .../AddUuidColumnToQualityGateConditionsTable.java | 31 + .../DropIdColumnOfQualityGateConditionsTable.java | 31 + ...yKeyOnIdColumnOfQualityGateConditionsTable.java | 32 + ...QualityGateConditionsUuidColumnNotNullable.java | 31 + .../PopulateQualityGateConditionsUuid.java | 50 ++ .../AddPrimaryKeyOnUuidColumnOfQGatesTable.java | 38 + .../AddQGateUuidColumnForQGateConditions.java | 50 ++ .../v84/qualitygates/DropIdColumnOfQGateTable.java | 31 + .../qualitygates/DropOrphansQGateConditions.java | 45 ++ .../DropPrimaryKeyOnIdColumnOfQGatesTable.java | 34 + .../DropQGateIdColumnForQGateConditions.java | 41 ++ ...UniqueIndexOnUuidColumnOfQualityGatesTable.java | 40 ++ ...ateUuidColumnNotNullableForQGateConditions.java | 50 ++ .../PopulateQGateUuidColumnForQGateConditions.java | 46 ++ .../AddPrimaryKeyOnUuidColumnOfRulesTable.java | 38 + .../AddUuidAndTemplateUuidColumnsToRules.java | 58 ++ .../v84/rules/DropIdColumnOfRulesTable.java | 37 + .../DropPrimaryKeyOnIdColumnOfRulesTable.java | 41 ++ .../rules/DropTemplateIdColumnOfRulesTable.java | 37 + .../v84/rules/MakeRulesUuidColumnNotNullable.java | 50 ++ .../v84/rules/PopulateRulesTemplateUuid.java | 49 ++ .../version/v84/rules/PopulateRulesUuid.java | 50 ++ .../activerules/AddIndexToActiveRulesTable.java | 70 ++ .../AddRuleUuidColumnToActiveRulesTable.java | 50 ++ .../DropIndexOnRuleIdColumnOfActiveRulesTable.java | 43 ++ .../DropRuleIdColumnOfActiveRulesTable.java | 37 + .../MakeActiveRulesRuleUuidColumnNotNullable.java | 50 ++ .../PopulateActiveRulesRuleUuidColumn.java | 49 ++ .../AddIndexToDeprecatedRuleKeysTable.java | 63 ++ ...AddRuleUuidColumnToDeprecatedRuleKeysTable.java | 50 ++ ...dexOnRuleIdColumnOfDeprecatedRuleKeysTable.java | 41 ++ .../DropRuleIdColumnOfDeprecatedRuleKeysTable.java | 37 + ...eprecatedRuleKeysRuleUuidColumnNotNullable.java | 50 ++ .../PopulateDeprecatedRuleKeysRuleUuidColumn.java | 49 ++ .../v84/rules/issues/AddIndexToIssuesTable.java | 62 ++ .../issues/AddRuleUuidColumnToIssuesTable.java | 49 ++ .../DropIndexOnRuleIdColumnOfIssuesTable.java | 41 ++ .../issues/DropRuleIdColumnOfIssuesTable.java | 37 + .../rules/issues/PopulateIssuesRuleUuidColumn.java | 49 ++ ...OrganizationUuidColumnOfRulesMetadataTable.java | 38 + .../AddRuleUuidColumnToRulesMetadataTable.java | 50 ++ ...opPrimaryKeyOnIdColumnOfRulesMetadataTable.java | 41 ++ .../DropRuleIdColumnOfRulesMetadataTable.java | 37 + ...MakeRulesMetadataRuleUuidColumnNotNullable.java | 50 ++ .../PopulateRulesMetadataRuleUuidColumn.java | 49 ++ .../AddIndexesToRulesParametersTable.java | 81 +++ .../AddRuleUuidColumnToRulesParametersTable.java | 50 ++ ...ndexesOnRuleIdColumnOfRulesParametersTable.java | 45 ++ .../DropRuleIdColumnOfRulesParametersTable.java | 37 + ...keRulesParametersRuleUuidColumnNotNullable.java | 50 ++ .../PopulateRulesParametersRuleUuidColumn.java | 49 ++ ...imaryKeyOnUuidColumnOfRulesParametersTable.java | 38 + .../AddUuidColumnToRulesParameters.java | 31 + .../DropIdColumnOfRulesParametersTable.java | 31 + ...PrimaryKeyOnIdColumnOfRulesParametersTable.java | 32 + .../MakeRulesParametersUuidColumnNotNullable.java | 31 + .../PopulateRulesParametersUuid.java | 50 ++ ...sParameterUuidColumnToActiveRuleParameters.java | 50 ++ ...rameterIdColumnOfActiveRuleParametersTable.java | 37 + ...ametersRulesParameterUuidColumnNotNullable.java | 50 ++ ...lateActiveRuleParametersRulesParameterUuid.java | 49 ++ ...PrimaryKeyOnUuidColumnOfRulesProfilesTable.java | 38 + .../AddUuidColumnToRulesProfilesTable.java | 31 + .../DropIdColumnOfRulesProfilesTable.java | 33 + .../DropKeeColumnOfRulesProfilesTable.java | 41 ++ ...opPrimaryKeyOnIdColumnOfRulesProfilesTable.java | 32 + ...UniqueIndexOnKeeColumnOfRulesProfilesTable.java | 52 ++ .../MakeRulesProfilesUuidColumnNotNullable.java | 32 + .../rulesprofiles/PopulateRulesProfilesUuid.java | 50 ++ .../AddProfileUuidColumnToActiveRulesTable.java | 50 ++ ...IndexOnProfileUuidColumnOfActiveRulesTable.java | 67 ++ .../DropProfileIdColumnOfActiveRulesTable.java | 41 ++ ...ueIndexOnProfileIdColumnOfActiveRulesTable.java | 52 ++ ...akeActiveRulesProfileUuidColumnNotNullable.java | 50 ++ .../PopulateActiveRulesProfileUuid.java | 49 ++ .../PopulateOrgQProfilesRulesProfileUuid.java | 48 ++ .../PopulateQProfileChangesRulesProfileUuid.java | 48 ++ .../AddPrimaryKeyOnUuidColumnOfSnapshotsTable.java | 38 + .../issues/DropIdColumnOfSnapshotsTable.java | 31 + .../DropPrimaryKeyOnIdColumnOfSnapshotsTable.java | 41 ++ .../AddPrimaryKeyOnUuidColumnOfUserRolesTable.java | 38 + .../userroles/AddUuidColumnToUserRolesTable.java | 31 + .../userroles/DropIdColumnOfUserRolesTable.java | 29 + .../DropPrimaryKeyOnIdColumnOfUserRolesTable.java | 32 + .../MakeUserRolesUuidColumnNotNullable.java | 31 + .../v84/userroles/PopulateUserRolesUuid.java | 50 ++ .../AddPrimaryKeyOnUuidColumnOfUsersTable.java | 38 + .../v84/users/DropIdColumnOfUsersTable.java | 32 + .../DropPrimaryKeyOnIdColumnOfUsersTable.java | 33 + .../DropUniqueIndexOnUuidColumnOfUsersTable.java | 53 ++ .../AddIndexOnUserUuidOfGroupsUsersTable.java | 60 ++ ...ndexOnUserUuidAndGroupIdOfGroupsUsersTable.java | 64 ++ .../AddUserUuidColumnToGroupsUsers.java | 29 + .../DropIndexOnUserIdOfGroupsUsersTable.java | 52 ++ ...eIndexOnUserIdAndGroupIdOfGroupsUsersTable.java | 52 ++ .../DropUserIdColumnOfGroupsUsersTable.java | 37 + .../MakeGroupsUsersUserUuidColumnNotNullable.java | 50 ++ .../groupsusers/PopulateGroupsUsersUserUuid.java | 53 ++ ...dIndexOnUserUuidOfOrganizationMembersTable.java | 60 ++ ...AndOrganizationUuidColumnsOfUserRolesTable.java | 38 + .../AddUserUuidColumnToOrganizationMembers.java | 29 + ...ropIndexOnUserIdOfOrganizationMembersTable.java | 52 ++ ...OrganizationUuidOfOrganizationMembersTable.java | 41 ++ ...DropUserIdColumnOfOrganizationMembersTable.java | 36 + ...ganizationMembersUserUuidColumnNotNullable.java | 31 + .../PopulateOrganizationMembersUserUuid.java | 54 ++ .../AddUserUuidColumnToPermTemplatesUsers.java | 30 + .../DropUserIdColumnOfPermTemplatesUsersTable.java | 36 + ...ermTemplatesUsersUserUuidColumnNotNullable.java | 31 + .../PopulatePermTemplatesUsersUserUuid.java | 52 ++ .../AddUserUuidColumnToPropertiesUsers.java | 30 + .../DropUserIdColumnOfPropertiesTable.java | 36 + .../fk/properties/PopulatePropertiesUserUuid.java | 52 ++ ...uidAndQProfileUuidOfQProfileEditUsersTable.java | 64 ++ .../AddUserUuidColumnToQProfileEditUsers.java | 30 + ...rIdAndQProfileUuidOfQProfileEditUsersTable.java | 52 ++ .../DropUserIdColumnOfQProfileEditUsersTable.java | 36 + ...QProfileEditUsersUserUuidColumnNotNullable.java | 31 + .../PopulateQProfileEditUsersUserUuid.java | 52 ++ .../AddIndexOnUserUuidOfUserRolesTable.java | 60 ++ .../fk/userroles/AddUserUuidColumnToUserRoles.java | 30 + .../DropIndexOnUserIdOfUserRolesTable.java | 52 ++ .../DropUserIdColumnOfUserRolesTable.java | 36 + .../fk/userroles/PopulateUserRolesUserUuid.java | 52 ++ .../users/fk/util/AddUserUuidColumnToTable.java | 51 ++ .../fk/util/MakeUserUuidColumnNotNullable.java | 51 ++ ...AddPrimaryKeyOnUuidColumnOfUserTokensTable.java | 38 + .../v84/usertokens/AddUuidColumnToUserTokens.java | 31 + .../usertokens/DropIdColumnOfUserTokensTable.java | 31 + .../DropPrimaryKeyOnIdColumnOfUserTokensTable.java | 32 + .../usertokens/MakeUserTokensUuidNotNullable.java | 31 + .../v84/usertokens/PopulateUserTokensUuid.java | 50 ++ .../version/v84/util/AddPrimaryKeyBuilder.java | 46 ++ .../v84/util/DropPrimaryKeySqlGenerator.java | 99 +++ .../db/migration/version/v84/util/SqlHelper.java | 116 +++ .../db/migration/version/v83/DbVersion83Test.java | 1 + .../version/v83/DropIdFromComponentsTableTest.java | 4 +- ...nUuidColumnOfActiveRuleParametersTableTest.java | 51 -- .../AddUuidColumnToActiveRuleParametersTest.java | 62 -- ...ropIdColumnOfActiveRuleParametersTableTest.java | 51 -- ...yOnIdColumnOfActiveRuleParametersTableTest.java | 56 -- ...iveRuleParametersUuidColumnNotNullableTest.java | 43 -- .../PopulateActiveRuleParametersUuidTest.java | 81 --- ...veRuleUuidColumnToActiveRuleParametersTest.java | 61 -- ...iveRuleUuidOfActiveRuleParametersTableTest.java | 50 -- ...imaryKeyOnUuidColumnOfActiveRulesTableTest.java | 50 -- .../AddUuidColumnToActiveRulesTableTest.java | 62 -- ...uleIdColumnOfActiveRuleParametersTableTest.java | 50 -- .../DropIdColumnOfActiveRulesTableTest.java | 51 -- ...ctiveRuleIdOfActiveRuleParametersTableTest.java | 54 -- ...PrimaryKeyOnIdColumnOfActiveRulesTableTest.java | 56 -- ...uleParametersActiveRuleUuidNotNullableTest.java | 42 -- .../MakeActiveRulesUuidColumnNotNullableTest.java | 42 -- ...lateActiveRuleParametersActiveRuleUuidTest.java | 102 --- .../activerules/PopulateActiveRulesUuidTest.java | 81 --- ...rimaryKeyOnUuidColumnOfCeActivityTableTest.java | 49 -- .../DropIdColumnOfCeActivityTableTest.java | 49 -- ...pPrimaryKeyOnIdColumnOfCeActivityTableTest.java | 56 -- ...ddPrimaryKeyOnUuidColumnOfCeQueueTableTest.java | 50 -- .../cequeue/DropIdColumnOfCeQueueTableTest.java | 51 -- ...DropPrimaryKeyOnIdColumnOfCeQueueTableTest.java | 56 -- ...pUniqueIndexOnUuidColumnOfCeQueueTableTest.java | 44 -- ...eyOnUuidColumnOfDuplicationsIndexTableTest.java | 51 -- .../AddUuidToDuplicationsIndexTableTest.java | 70 -- .../DropIdColumnOfDuplicationsIndexTableTest.java | 51 -- ...yKeyOnIdColumnOfDuplicationsIndexTableTest.java | 56 -- ...DuplicationsIndexUuidColumnNotNullableTest.java | 43 -- .../PopulateDuplicationsIndexUuidTest.java | 85 --- ...AddPrimaryKeyOnUuidColumnOfEventsTableTest.java | 49 -- .../v83/events/DropIdColumnOfEventsTableTest.java | 50 -- .../DropPrimaryKeyOnIdColumnOfEventsTableTest.java | 55 -- ...imaryKeyOnUuidColumnOfFileSourcesTableTest.java | 50 -- .../AddUuidColumnToFileSourcesTableTest.java | 69 -- .../DropIdColumnOfFileSourcesTableTest.java | 51 -- ...PrimaryKeyOnIdColumnOfFileSourcesTableTest.java | 56 -- .../MakeFileSourcesUuidColumnNotNullableTest.java | 42 -- .../filesources/PopulateFileSourcesUuidTest.java | 83 --- ...rimaryKeyOnUuidColumnOfGroupRolesTableTest.java | 49 -- .../AddUuidColumnToGroupRolesTableTest.java | 68 -- .../DropIdColumnOfGroupRolesTableTest.java | 50 -- ...pPrimaryKeyOnIdColumnOfGroupRolesTableTest.java | 55 -- .../MakeGroupRolesUuidColumnNotNullableTest.java | 42 -- .../v83/grouproles/PopulateGroupRolesUuidTest.java | 84 --- ...AddPrimaryKeyOnUuidColumnOfGroupsTableTest.java | 50 -- .../v83/groups/AddUuidColumnToGroupsTableTest.java | 61 -- .../v83/groups/DropIdColumnOfGroupsTableTest.java | 51 -- .../DropPrimaryKeyOnIdColumnOfGroupsTableTest.java | 56 -- .../MakeGroupsUuidColumnNotNullableTest.java | 42 -- .../version/v83/groups/PopulateGroupsUuidTest.java | 80 --- .../AddGroupUuidColumnToGroupRolesTest.java | 64 -- .../AddIndexOnGroupUuidOfGroupRolesTableTest.java | 54 -- .../DropGroupIdColumnOfGroupRolesTableTest.java | 52 -- .../DropIndexOnGroupIdOfGroupRolesTableTest.java | 56 -- .../PopulateGroupRolesGroupUuidTest.java | 104 --- .../AddGroupUuidColumnToGroupsUsersTest.java | 62 -- .../AddIndexOnGroupUuidOfGroupsUsersTableTest.java | 54 -- .../DropGroupIdColumnOfGroupsUsersTableTest.java | 52 -- .../DropIndexOnGroupIdOfGroupsUsersTableTest.java | 60 -- .../MakeGroupsUsersGroupUuidNotNullableTest.java | 44 -- .../PopulateGroupsUsersGroupUuidTest.java | 101 --- ...dDefaultGroupUuidColumnToOrganizationsTest.java | 68 -- ...faultGroupIdColumnOfOrganizationsTableTest.java | 52 -- .../PopulateOrganizationsDefaultGroupUuidTest.java | 108 --- ...ddGroupUuidColumnToPermTemplatesGroupsTest.java | 64 -- ...roupIdColumnOfPermTemplatesGroupsTableTest.java | 52 -- .../PopulatePermTemplatesGroupsGroupUuidTest.java | 103 --- ...AddGroupUuidColumnToQProfileEditGroupsTest.java | 63 -- ...exOnGroupUuidOfQProfileEditGroupsTableTest.java | 53 -- ...GroupIdColumnOfQProfileEditGroupsTableTest.java | 52 -- ...ndexOnGroupIdOfQProfileEditGroupsTableTest.java | 56 -- ...QProfileEditGroupsGroupUuidNotNullableTest.java | 44 -- .../PopulateQProfileEditGroupsGroupUuidTest.java | 102 --- ...maryKeyOnUuidColumnOfIssueChangesTableTest.java | 50 -- .../AddUuidColumnToIssueChangesTableTest.java | 65 -- .../DropIdColumnOfIssueChangesTableTest.java | 51 -- ...rimaryKeyOnIdColumnOfIssueChangesTableTest.java | 55 -- .../MakeIssueChangesUuidColumnNotNullableTest.java | 42 -- .../issuechanges/PopulateIssueChangesUuidTest.java | 80 --- .../AddPrimaryKeyOnKeeColumnOfIssuesTableTest.java | 49 -- .../v83/issues/DropIdColumnOfIssuesTableTest.java | 50 -- .../DropPrimaryKeyOnIdColumnOfIssuesTableTest.java | 55 -- ...aryKeyOnUuidColumnOfManualMeasureTableTest.java | 51 -- .../AddUuidToManualMeasuresTest.java | 66 -- .../DropIdColumnOfManualMeasuresTableTest.java | 51 -- ...maryKeyOnIdColumnOfManualMeasuresTableTest.java | 56 -- ...akeManualMeasuresUuidColumnNotNullableTest.java | 43 -- .../PopulateManualMeasuresUuidTest.java | 81 --- ...ddPrimaryKeyOnUuidColumnOfMetricsTableTest.java | 50 -- .../metrics/AddUuidColumnToMetricsTableTest.java | 60 -- .../metrics/DropIdColumnOfMetricsTableTest.java | 51 -- ...DropPrimaryKeyOnIdColumnOfMetricsTableTest.java | 56 -- .../MakeMetricsUuidColumnNotNullableTest.java | 42 -- .../v83/metrics/PopulateMetricsUuidTest.java | 79 --- ...ddIndexOnMetricUuidOfLiveMeasuresTableTest.java | 50 -- .../AddMetricUuidColumnToLiveMeasuresTest.java | 64 -- ...DropIndexOnMetricIdOfLiveMeasuresTableTest.java | 54 -- .../DropMetricIdColumnOfLiveMeasuresTableTest.java | 50 -- .../MakeLiveMeasuresMetricUuidNotNullableTest.java | 42 -- .../PopulateLiveMeasuresMetricUuidTest.java | 102 --- .../AddMetricUuidColumnToManualMeasuresTest.java | 60 -- ...ropMetricIdColumnOfManualMeasuresTableTest.java | 50 -- ...akeManualMeasuresMetricUuidNotNullableTest.java | 42 -- .../PopulateManualMeasuresMetricUuidTest.java | 99 --- ...ndexOnMetricUuidOfProjectMeasuresTableTest.java | 50 -- .../AddMetricUuidColumnToProjectMeasuresTest.java | 61 -- ...pIndexOnMetricIdOfProjectMeasuresTableTest.java | 54 -- ...opMetricIdColumnOfProjectMeasuresTableTest.java | 50 -- ...keProjectMeasuresMetricUuidNotNullableTest.java | 42 -- .../PopulateProjectMeasuresMetricUuidTest.java | 100 --- ...etricUuidColumnToQualityGateConditionsTest.java | 59 -- ...icIdColumnOfQualityGateConditionsTableTest.java | 50 -- ...ityGateConditionsMetricUuidNotNullableTest.java | 42 -- ...opulateQualityGateConditionsMetricUuidTest.java | 118 ---- ...maryKeyOnUuidColumnOfNotificationTableTest.java | 51 -- ...dUuidAndCreatedAtColumnsToNotificationTest.java | 83 --- .../DropIdColumnOfNotificationTableTest.java | 51 -- ...rimaryKeyOnIdColumnOfNotificationTableTest.java | 56 -- ...tionUuidAndCreatedAtColumnsNotNullableTest.java | 45 -- .../PopulateNotificationUuidAndCreatedAtTest.java | 110 --- ...OnUuidColumnOfPermissionTemplatesTableTest.java | 52 -- .../AddUuidColumnToPermissionTemplatesTest.java | 68 -- ...DropIdColumnOfPermissionTemplatesTableTest.java | 52 -- ...ropKeeColumnOfPermissionTemplatesTableTest.java | 52 -- ...eyOnIdColumnOfPermissionTemplatesTableTest.java | 56 -- ...ermissionTemplateUuidColumnNotNullableTest.java | 44 -- .../PopulatePermissionTemplatesUuidTest.java | 87 --- ...emplateUuidColumnToPermTemplatesGroupsTest.java | 66 -- ...lateIdColumnOfPermTemplatesGroupsTableTest.java | 52 -- ...tesGroupsTemplateUuidColumnNotNullableTest.java | 44 -- ...ePermTemplatesGroupsTemplateUuidColumnTest.java | 116 --- ...TemplateUuidColumnToPermTemplatesUsersTest.java | 68 -- ...plateIdColumnOfPermTemplatesUsersTableTest.java | 52 -- ...atesUsersTemplateUuidColumnNotNullableTest.java | 44 -- ...tePermTemplatesUsersTemplateUuidColumnTest.java | 117 --- ...lateUuidColumnToPermTplCharacteristicsTest.java | 70 -- ...eyColumnsOfPermTplCharacteristicsTableTest.java | 52 -- ...eIdColumnOfPermTplCharacteristicsTableTest.java | 52 -- ...eyColumnsOfPermTplCharacteristicsTableTest.java | 52 -- ...teristicsTemplateUuidColumnNotNullableTest.java | 44 -- ...rmTplCharacteristicsTemplateUuidColumnTest.java | 118 ---- ...OnUuidColumnOfPermTemplatesGroupsTableTest.java | 51 -- ...ddUuidColumnToPermTemplatesGroupsTableTest.java | 64 -- ...DropIdColumnOfPermTemplatesGroupsTableTest.java | 51 -- ...eyOnIdColumnOfPermTemplatesGroupsTableTest.java | 57 -- ...rmTemplatesGroupsUuidColumnNotNullableTest.java | 42 -- .../PopulatePermTemplatesGroupsUuidTest.java | 81 --- ...yOnUuidColumnOfPermTemplatesUsersTableTest.java | 51 -- ...AddUuidColumnToPermTemplatesUsersTableTest.java | 64 -- .../DropIdColumnOfPermTemplatesUsersTableTest.java | 51 -- ...KeyOnIdColumnOfPermTemplatesUsersTableTest.java | 57 -- ...ermTemplatesUsersUuidColumnNotNullableTest.java | 42 -- .../PopulatePermTemplatesUsersUuidTest.java | 81 --- ...uidColumnOfPermTplCharacteristicsTableTest.java | 51 -- ...uidColumnToPermTplCharacteristicsTableTest.java | 66 -- ...pIdColumnOfPermTplCharacteristicsTableTest.java | 51 -- ...nIdColumnOfPermTplCharacteristicsTableTest.java | 57 -- ...plCharacteristicsUuidColumnNotNullableTest.java | 42 -- .../PopulatePermTplCharacteristicsUuidTest.java | 83 --- ...ryKeyOnUuidColumnOfProjectMeasureTableTest.java | 51 -- .../AddUuidToProjectMeasuresTest.java | 67 -- .../DropIdColumnOfProjectMeasuresTableTest.java | 51 -- ...aryKeyOnIdColumnOfProjectMeasuresTableTest.java | 56 -- ...keProjectMeasuresUuidColumnNotNullableTest.java | 43 -- .../PopulateProjectMeasuresUuidTest.java | 82 --- ...KeyOnUuidColumnOfProjectQProfilesTableTest.java | 49 -- .../AddUuidColumnToProjectQProfilesTableTest.java | 66 -- .../DropIdColumnOfProjectQProfilesTableTest.java | 49 -- ...ryKeyOnIdColumnOfProjectQProfilesTableTest.java | 54 -- ...eProjectQProfilesUuidColumnNotNullableTest.java | 43 -- .../PopulateProjectQProfilesUuidTest.java | 80 --- ...rimaryKeyOnUuidColumnOfPropertiesTableTest.java | 52 -- .../properties/AddUuidColumnToPropertiesTest.java | 64 -- .../DropIdColumnOfPropertiesTableTest.java | 52 -- ...pPrimaryKeyOnIdColumnOfPropertiesTableTest.java | 56 -- .../MakeNotificationUuidColumnNotNullableTest.java | 45 -- .../PopulatePropertiesUuidAndCreatedAtTest.java | 84 --- ...UuidColumnOfQualityGateConditionsTableTest.java | 50 -- ...UuidColumnToQualityGateConditionsTableTest.java | 66 -- ...opIdColumnOfQualityGateConditionsTableTest.java | 51 -- ...OnIdColumnOfQualityGateConditionsTableTest.java | 56 -- ...ityGateConditionsUuidColumnNotNullableTest.java | 42 -- .../PopulateQualityGateConditionsUuidTest.java | 81 --- ...AddPrimaryKeyOnUuidColumnOfQGatesTableTest.java | 50 -- .../AddQGateUuidColumnForQGateConditionsTest.java | 52 -- .../qualitygates/DropIdColumnOfQGateTableTest.java | 51 -- .../DropOrphansQGateConditionsTest.java | 73 -- .../DropPrimaryKeyOnIdColumnOfQGatesTableTest.java | 56 -- .../DropQGateIdColumnForQGateConditionsTest.java | 52 -- ...ueIndexOnUuidColumnOfQualityGatesTableTest.java | 43 -- ...uidColumnNotNullableForQGateConditionsTest.java | 43 -- ...ulateQGateUuidColumnForQGateConditionsTest.java | 93 --- .../AddPrimaryKeyOnUuidColumnOfRulesTableTest.java | 50 -- .../AddUuidAndTemplateUuidColumnsToRulesTest.java | 66 -- .../v83/rules/DropIdColumnOfRulesTableTest.java | 50 -- .../DropPrimaryKeyOnIdColumnOfRulesTableTest.java | 56 -- .../DropTemplateIdColumnOfRulesTableTest.java | 50 -- .../rules/MakeRulesUuidColumnNotNullableTest.java | 43 -- .../v83/rules/PopulateRulesTemplateUuidTest.java | 74 -- .../version/v83/rules/PopulateRulesUuidTest.java | 75 -- .../AddIndexToActiveRulesTableTest.java | 51 -- .../AddRuleUuidColumnToActiveRulesTableTest.java | 79 --- ...pIndexOnRuleIdColumnOfActiveRulesTableTest.java | 54 -- .../DropRuleIdColumnOfActiveRulesTableTest.java | 50 -- ...keActiveRulesRuleUuidColumnNotNullableTest.java | 43 -- .../PopulateActiveRulesRuleUuidColumnTest.java | 84 --- .../AddIndexToDeprecatedRuleKeysTableTest.java | 51 -- ...uleUuidColumnToDeprecatedRuleKeysTableTest.java | 80 --- ...nRuleIdColumnOfDeprecatedRuleKeysTableTest.java | 54 -- ...pRuleIdColumnOfDeprecatedRuleKeysTableTest.java | 50 -- ...catedRuleKeysRuleUuidColumnNotNullableTest.java | 43 -- ...pulateDeprecatedRuleKeysRuleUuidColumnTest.java | 86 --- .../rules/issues/AddIndexToIssuesTableTest.java | 51 -- .../issues/AddRuleUuidColumnToIssuesTableTest.java | 81 --- .../DropIndexOnRuleIdColumnOfIssuesTableTest.java | 54 -- .../issues/DropRuleIdColumnOfIssuesTableTest.java | 50 -- .../issues/PopulateIssuesRuleUuidColumnTest.java | 87 --- ...nizationUuidColumnOfRulesMetadataTableTest.java | 50 -- .../AddRuleUuidColumnToRulesMetadataTableTest.java | 80 --- ...imaryKeyOnIdColumnOfRulesMetadataTableTest.java | 56 -- .../DropRuleIdColumnOfRulesMetadataTableTest.java | 50 -- ...RulesMetadataRuleUuidColumnNotNullableTest.java | 43 -- .../PopulateRulesMetadataRuleUuidColumnTest.java | 85 --- .../AddIndexesToRulesParametersTableTest.java | 53 -- ...ddRuleUuidColumnToRulesParametersTableTest.java | 78 -- ...esOnRuleIdColumnOfRulesParametersTableTest.java | 57 -- ...DropRuleIdColumnOfRulesParametersTableTest.java | 50 -- ...lesParametersRuleUuidColumnNotNullableTest.java | 43 -- .../PopulateRulesParametersRuleUuidColumnTest.java | 84 --- ...yKeyOnUuidColumnOfRulesParametersTableTest.java | 51 -- .../AddUuidColumnToRulesParametersTest.java | 67 -- .../DropIdColumnOfRulesParametersTableTest.java | 51 -- ...aryKeyOnIdColumnOfRulesParametersTableTest.java | 56 -- ...keRulesParametersUuidColumnNotNullableTest.java | 43 -- .../PopulateRulesParametersUuidTest.java | 82 --- ...ameterUuidColumnToActiveRuleParametersTest.java | 66 -- ...terIdColumnOfActiveRuleParametersTableTest.java | 51 -- ...ersRulesParameterUuidColumnNotNullableTest.java | 43 -- ...ActiveRuleParametersRulesParameterUuidTest.java | 127 ---- ...aryKeyOnUuidColumnOfRulesProfilesTableTest.java | 49 -- .../AddUuidColumnToRulesProfilesTableTest.java | 67 -- .../DropIdColumnOfRulesProfilesTableTest.java | 49 -- .../DropKeeColumnOfRulesProfilesTableTest.java | 49 -- ...imaryKeyOnIdColumnOfRulesProfilesTableTest.java | 54 -- ...ueIndexOnKeeColumnOfRulesProfilesTableTest.java | 54 -- ...MakeRulesProfilesUuidColumnNotNullableTest.java | 43 -- .../PopulateRulesProfilesUuidTest.java | 81 --- ...AddProfileUuidColumnToActiveRulesTableTest.java | 63 -- ...xOnProfileUuidColumnOfActiveRulesTableTest.java | 51 -- .../DropProfileIdColumnOfActiveRulesTableTest.java | 49 -- ...dexOnProfileIdColumnOfActiveRulesTableTest.java | 51 -- ...ctiveRulesProfileUuidColumnNotNullableTest.java | 43 -- .../PopulateActiveRulesProfileUuidTest.java | 113 --- .../PopulateOrgQProfilesRulesProfileUuidTest.java | 137 ---- ...opulateQProfileChangesRulesProfileUuidTest.java | 136 ---- ...PrimaryKeyOnUuidColumnOfSnapshotsTableTest.java | 50 -- .../DropIdColumnOfSnapshotsTableTest.java | 51 -- ...opPrimaryKeyOnIdColumnOfSnapshotsTableTest.java | 56 -- .../AddPrimaryKeyOnUuidColumnOfUsersTableTest.java | 49 -- .../v83/users/DropIdColumnOfUsersTableTest.java | 49 -- .../DropPrimaryKeyOnIdColumnOfUsersTableTest.java | 54 -- ...ropUniqueIndexOnUuidColumnOfUsersTableTest.java | 50 -- .../AddIndexOnUserUuidOfGroupsUsersTableTest.java | 49 -- ...OnUserUuidAndGroupIdOfGroupsUsersTableTest.java | 51 -- .../AddUserUuidColumnToGroupsUsersTest.java | 62 -- .../DropIndexOnUserIdOfGroupsUsersTableTest.java | 50 -- ...exOnUserIdAndGroupIdOfGroupsUsersTableTest.java | 50 -- .../DropUserIdColumnOfGroupsUsersTableTest.java | 50 -- ...keGroupsUsersUserUuidColumnNotNullableTest.java | 44 -- .../PopulateGroupsUsersUserUuidTest.java | 139 ---- ...exOnUserUuidOfOrganizationMembersTableTest.java | 49 -- ...rganizationUuidColumnsOfUserRolesTableTest.java | 51 -- ...AddUserUuidColumnToOrganizationMembersTest.java | 61 -- ...ndexOnUserIdOfOrganizationMembersTableTest.java | 50 -- ...nizationUuidOfOrganizationMembersTableTest.java | 54 -- ...UserIdColumnOfOrganizationMembersTableTest.java | 51 -- ...zationMembersUserUuidColumnNotNullableTest.java | 43 -- .../PopulateOrganizationMembersUserUuidTest.java | 140 ---- .../AddUserUuidColumnToPermTemplatesUsersTest.java | 65 -- ...pUserIdColumnOfPermTemplatesUsersTableTest.java | 51 -- ...emplatesUsersUserUuidColumnNotNullableTest.java | 43 -- .../PopulatePermTemplatesUsersUserUuidTest.java | 145 ---- .../AddUserUuidColumnToPropertiesUsersTest.java | 65 -- .../DropUserIdColumnOfPropertiesTableTest.java | 51 -- .../properties/PopulatePropertiesUserUuidTest.java | 154 ---- ...ndQProfileUuidOfQProfileEditUsersTableTest.java | 49 -- .../AddUserUuidColumnToQProfileEditUsersTest.java | 64 -- ...ndQProfileUuidOfQProfileEditUsersTableTest.java | 50 -- ...opUserIdColumnOfQProfileEditUsersTableTest.java | 51 -- ...fileEditUsersUserUuidColumnNotNullableTest.java | 43 -- .../PopulateQProfileEditUsersUserUuidTest.java | 145 ---- .../AddIndexOnUserUuidOfUserRolesTableTest.java | 49 -- .../AddUserUuidColumnToUserRolesTest.java | 64 -- .../DropIndexOnUserIdOfUserRolesTableTest.java | 52 -- .../DropUserIdColumnOfUserRolesTableTest.java | 51 -- .../userroles/PopulateUserRolesUserUuidTest.java | 145 ---- ...rimaryKeyOnUuidColumnOfUserTokensTableTest.java | 49 -- .../usertokens/AddUuidColumnToUserTokensTest.java | 63 -- .../DropIdColumnOfUserTokensTableTest.java | 49 -- ...pPrimaryKeyOnIdColumnOfUserTokensTableTest.java | 55 -- .../MakeUserTokensUuidNotNullableTest.java | 43 -- .../v83/usertokens/PopulateUserTokensUuidTest.java | 97 --- .../version/v83/util/AddPrimaryKeyBuilderTest.java | 43 -- .../v83/util/DropPrimaryKeySqlGeneratorTest.java | 96 --- .../db/migration/version/v84/DbVersion84Test.java | 42 ++ ...nUuidColumnOfActiveRuleParametersTableTest.java | 51 ++ .../AddUuidColumnToActiveRuleParametersTest.java | 62 ++ ...ropIdColumnOfActiveRuleParametersTableTest.java | 51 ++ ...yOnIdColumnOfActiveRuleParametersTableTest.java | 56 ++ ...iveRuleParametersUuidColumnNotNullableTest.java | 43 ++ .../PopulateActiveRuleParametersUuidTest.java | 81 +++ ...veRuleUuidColumnToActiveRuleParametersTest.java | 61 ++ ...iveRuleUuidOfActiveRuleParametersTableTest.java | 50 ++ ...imaryKeyOnUuidColumnOfActiveRulesTableTest.java | 50 ++ .../AddUuidColumnToActiveRulesTableTest.java | 62 ++ ...uleIdColumnOfActiveRuleParametersTableTest.java | 50 ++ .../DropIdColumnOfActiveRulesTableTest.java | 51 ++ ...ctiveRuleIdOfActiveRuleParametersTableTest.java | 54 ++ ...PrimaryKeyOnIdColumnOfActiveRulesTableTest.java | 56 ++ ...uleParametersActiveRuleUuidNotNullableTest.java | 42 ++ .../MakeActiveRulesUuidColumnNotNullableTest.java | 42 ++ ...lateActiveRuleParametersActiveRuleUuidTest.java | 102 +++ .../activerules/PopulateActiveRulesUuidTest.java | 81 +++ ...rimaryKeyOnUuidColumnOfCeActivityTableTest.java | 49 ++ .../DropIdColumnOfCeActivityTableTest.java | 49 ++ ...pPrimaryKeyOnIdColumnOfCeActivityTableTest.java | 56 ++ ...ddPrimaryKeyOnUuidColumnOfCeQueueTableTest.java | 50 ++ .../cequeue/DropIdColumnOfCeQueueTableTest.java | 51 ++ ...DropPrimaryKeyOnIdColumnOfCeQueueTableTest.java | 56 ++ ...pUniqueIndexOnUuidColumnOfCeQueueTableTest.java | 44 ++ ...eyOnUuidColumnOfDuplicationsIndexTableTest.java | 51 ++ .../AddUuidToDuplicationsIndexTableTest.java | 70 ++ .../DropIdColumnOfDuplicationsIndexTableTest.java | 51 ++ ...yKeyOnIdColumnOfDuplicationsIndexTableTest.java | 56 ++ ...DuplicationsIndexUuidColumnNotNullableTest.java | 43 ++ .../PopulateDuplicationsIndexUuidTest.java | 85 +++ ...AddPrimaryKeyOnUuidColumnOfEventsTableTest.java | 49 ++ .../v84/events/DropIdColumnOfEventsTableTest.java | 50 ++ .../DropPrimaryKeyOnIdColumnOfEventsTableTest.java | 55 ++ ...imaryKeyOnUuidColumnOfFileSourcesTableTest.java | 50 ++ .../AddUuidColumnToFileSourcesTableTest.java | 69 ++ .../DropIdColumnOfFileSourcesTableTest.java | 51 ++ ...PrimaryKeyOnIdColumnOfFileSourcesTableTest.java | 56 ++ .../MakeFileSourcesUuidColumnNotNullableTest.java | 42 ++ .../filesources/PopulateFileSourcesUuidTest.java | 83 +++ ...rimaryKeyOnUuidColumnOfGroupRolesTableTest.java | 49 ++ .../AddUuidColumnToGroupRolesTableTest.java | 68 ++ .../DropIdColumnOfGroupRolesTableTest.java | 50 ++ ...pPrimaryKeyOnIdColumnOfGroupRolesTableTest.java | 55 ++ .../MakeGroupRolesUuidColumnNotNullableTest.java | 42 ++ .../v84/grouproles/PopulateGroupRolesUuidTest.java | 84 +++ ...AddPrimaryKeyOnUuidColumnOfGroupsTableTest.java | 50 ++ .../v84/groups/AddUuidColumnToGroupsTableTest.java | 61 ++ .../v84/groups/DropIdColumnOfGroupsTableTest.java | 51 ++ .../DropPrimaryKeyOnIdColumnOfGroupsTableTest.java | 56 ++ .../MakeGroupsUuidColumnNotNullableTest.java | 42 ++ .../version/v84/groups/PopulateGroupsUuidTest.java | 80 +++ .../AddGroupUuidColumnToGroupRolesTest.java | 64 ++ .../AddIndexOnGroupUuidOfGroupRolesTableTest.java | 54 ++ .../DropGroupIdColumnOfGroupRolesTableTest.java | 52 ++ .../DropIndexOnGroupIdOfGroupRolesTableTest.java | 56 ++ .../PopulateGroupRolesGroupUuidTest.java | 104 +++ .../AddGroupUuidColumnToGroupsUsersTest.java | 62 ++ .../AddIndexOnGroupUuidOfGroupsUsersTableTest.java | 54 ++ .../DropGroupIdColumnOfGroupsUsersTableTest.java | 52 ++ .../DropIndexOnGroupIdOfGroupsUsersTableTest.java | 60 ++ .../MakeGroupsUsersGroupUuidNotNullableTest.java | 44 ++ .../PopulateGroupsUsersGroupUuidTest.java | 101 +++ ...dDefaultGroupUuidColumnToOrganizationsTest.java | 68 ++ ...faultGroupIdColumnOfOrganizationsTableTest.java | 52 ++ .../PopulateOrganizationsDefaultGroupUuidTest.java | 108 +++ ...ddGroupUuidColumnToPermTemplatesGroupsTest.java | 64 ++ ...roupIdColumnOfPermTemplatesGroupsTableTest.java | 52 ++ .../PopulatePermTemplatesGroupsGroupUuidTest.java | 103 +++ ...AddGroupUuidColumnToQProfileEditGroupsTest.java | 63 ++ ...exOnGroupUuidOfQProfileEditGroupsTableTest.java | 53 ++ ...GroupIdColumnOfQProfileEditGroupsTableTest.java | 52 ++ ...ndexOnGroupIdOfQProfileEditGroupsTableTest.java | 56 ++ ...QProfileEditGroupsGroupUuidNotNullableTest.java | 44 ++ .../PopulateQProfileEditGroupsGroupUuidTest.java | 102 +++ ...maryKeyOnUuidColumnOfIssueChangesTableTest.java | 50 ++ .../AddUuidColumnToIssueChangesTableTest.java | 65 ++ .../DropIdColumnOfIssueChangesTableTest.java | 51 ++ ...rimaryKeyOnIdColumnOfIssueChangesTableTest.java | 55 ++ .../MakeIssueChangesUuidColumnNotNullableTest.java | 42 ++ .../issuechanges/PopulateIssueChangesUuidTest.java | 80 +++ .../AddPrimaryKeyOnKeeColumnOfIssuesTableTest.java | 49 ++ .../v84/issues/DropIdColumnOfIssuesTableTest.java | 50 ++ .../DropPrimaryKeyOnIdColumnOfIssuesTableTest.java | 55 ++ ...aryKeyOnUuidColumnOfManualMeasureTableTest.java | 51 ++ .../AddUuidToManualMeasuresTest.java | 66 ++ .../DropIdColumnOfManualMeasuresTableTest.java | 51 ++ ...maryKeyOnIdColumnOfManualMeasuresTableTest.java | 56 ++ ...akeManualMeasuresUuidColumnNotNullableTest.java | 43 ++ .../PopulateManualMeasuresUuidTest.java | 81 +++ ...ddPrimaryKeyOnUuidColumnOfMetricsTableTest.java | 50 ++ .../metrics/AddUuidColumnToMetricsTableTest.java | 60 ++ .../metrics/DropIdColumnOfMetricsTableTest.java | 51 ++ ...DropPrimaryKeyOnIdColumnOfMetricsTableTest.java | 56 ++ .../MakeMetricsUuidColumnNotNullableTest.java | 42 ++ .../v84/metrics/PopulateMetricsUuidTest.java | 79 +++ ...ddIndexOnMetricUuidOfLiveMeasuresTableTest.java | 50 ++ .../AddMetricUuidColumnToLiveMeasuresTest.java | 64 ++ ...DropIndexOnMetricIdOfLiveMeasuresTableTest.java | 54 ++ .../DropMetricIdColumnOfLiveMeasuresTableTest.java | 50 ++ .../MakeLiveMeasuresMetricUuidNotNullableTest.java | 42 ++ .../PopulateLiveMeasuresMetricUuidTest.java | 102 +++ .../AddMetricUuidColumnToManualMeasuresTest.java | 60 ++ ...ropMetricIdColumnOfManualMeasuresTableTest.java | 50 ++ ...akeManualMeasuresMetricUuidNotNullableTest.java | 42 ++ .../PopulateManualMeasuresMetricUuidTest.java | 99 +++ ...ndexOnMetricUuidOfProjectMeasuresTableTest.java | 50 ++ .../AddMetricUuidColumnToProjectMeasuresTest.java | 61 ++ ...pIndexOnMetricIdOfProjectMeasuresTableTest.java | 54 ++ ...opMetricIdColumnOfProjectMeasuresTableTest.java | 50 ++ ...keProjectMeasuresMetricUuidNotNullableTest.java | 42 ++ .../PopulateProjectMeasuresMetricUuidTest.java | 100 +++ ...etricUuidColumnToQualityGateConditionsTest.java | 59 ++ ...icIdColumnOfQualityGateConditionsTableTest.java | 50 ++ ...ityGateConditionsMetricUuidNotNullableTest.java | 42 ++ ...opulateQualityGateConditionsMetricUuidTest.java | 118 ++++ ...maryKeyOnUuidColumnOfNotificationTableTest.java | 51 ++ ...dUuidAndCreatedAtColumnsToNotificationTest.java | 83 +++ .../DropIdColumnOfNotificationTableTest.java | 51 ++ ...rimaryKeyOnIdColumnOfNotificationTableTest.java | 56 ++ ...tionUuidAndCreatedAtColumnsNotNullableTest.java | 45 ++ .../PopulateNotificationUuidAndCreatedAtTest.java | 110 +++ ...OnUuidColumnOfPermissionTemplatesTableTest.java | 51 ++ .../AddUuidColumnToPermissionTemplatesTest.java | 67 ++ ...DropIdColumnOfPermissionTemplatesTableTest.java | 51 ++ ...ropKeeColumnOfPermissionTemplatesTableTest.java | 51 ++ ...eyOnIdColumnOfPermissionTemplatesTableTest.java | 56 ++ ...ermissionTemplateUuidColumnNotNullableTest.java | 43 ++ .../PopulatePermissionTemplatesUuidTest.java | 87 +++ ...emplateUuidColumnToPermTemplatesGroupsTest.java | 66 ++ ...lateIdColumnOfPermTemplatesGroupsTableTest.java | 51 ++ ...tesGroupsTemplateUuidColumnNotNullableTest.java | 43 ++ ...ePermTemplatesGroupsTemplateUuidColumnTest.java | 116 +++ ...TemplateUuidColumnToPermTemplatesUsersTest.java | 67 ++ ...plateIdColumnOfPermTemplatesUsersTableTest.java | 51 ++ ...atesUsersTemplateUuidColumnNotNullableTest.java | 43 ++ ...tePermTemplatesUsersTemplateUuidColumnTest.java | 117 +++ ...lateUuidColumnToPermTplCharacteristicsTest.java | 70 ++ ...eyColumnsOfPermTplCharacteristicsTableTest.java | 52 ++ ...eIdColumnOfPermTplCharacteristicsTableTest.java | 51 ++ ...eyColumnsOfPermTplCharacteristicsTableTest.java | 52 ++ ...teristicsTemplateUuidColumnNotNullableTest.java | 43 ++ ...rmTplCharacteristicsTemplateUuidColumnTest.java | 118 ++++ ...OnUuidColumnOfPermTemplatesGroupsTableTest.java | 51 ++ ...ddUuidColumnToPermTemplatesGroupsTableTest.java | 64 ++ ...DropIdColumnOfPermTemplatesGroupsTableTest.java | 51 ++ ...eyOnIdColumnOfPermTemplatesGroupsTableTest.java | 57 ++ ...rmTemplatesGroupsUuidColumnNotNullableTest.java | 42 ++ .../PopulatePermTemplatesGroupsUuidTest.java | 81 +++ ...yOnUuidColumnOfPermTemplatesUsersTableTest.java | 51 ++ ...AddUuidColumnToPermTemplatesUsersTableTest.java | 64 ++ .../DropIdColumnOfPermTemplatesUsersTableTest.java | 51 ++ ...KeyOnIdColumnOfPermTemplatesUsersTableTest.java | 57 ++ ...ermTemplatesUsersUuidColumnNotNullableTest.java | 42 ++ .../PopulatePermTemplatesUsersUuidTest.java | 81 +++ ...uidColumnOfPermTplCharacteristicsTableTest.java | 51 ++ ...uidColumnToPermTplCharacteristicsTableTest.java | 66 ++ ...pIdColumnOfPermTplCharacteristicsTableTest.java | 51 ++ ...nIdColumnOfPermTplCharacteristicsTableTest.java | 57 ++ ...plCharacteristicsUuidColumnNotNullableTest.java | 42 ++ .../PopulatePermTplCharacteristicsUuidTest.java | 83 +++ ...ryKeyOnUuidColumnOfProjectMeasureTableTest.java | 51 ++ .../AddUuidToProjectMeasuresTest.java | 67 ++ .../DropIdColumnOfProjectMeasuresTableTest.java | 51 ++ ...aryKeyOnIdColumnOfProjectMeasuresTableTest.java | 56 ++ ...keProjectMeasuresUuidColumnNotNullableTest.java | 43 ++ .../PopulateProjectMeasuresUuidTest.java | 82 +++ ...KeyOnUuidColumnOfProjectQProfilesTableTest.java | 49 ++ .../AddUuidColumnToProjectQProfilesTableTest.java | 66 ++ .../DropIdColumnOfProjectQProfilesTableTest.java | 49 ++ ...ryKeyOnIdColumnOfProjectQProfilesTableTest.java | 54 ++ ...eProjectQProfilesUuidColumnNotNullableTest.java | 43 ++ .../PopulateProjectQProfilesUuidTest.java | 80 +++ ...rimaryKeyOnUuidColumnOfPropertiesTableTest.java | 51 ++ .../properties/AddUuidColumnToPropertiesTest.java | 64 ++ .../DropIdColumnOfPropertiesTableTest.java | 51 ++ ...pPrimaryKeyOnIdColumnOfPropertiesTableTest.java | 56 ++ .../MakeNotificationUuidColumnNotNullableTest.java | 43 ++ .../PopulatePropertiesUuidAndCreatedAtTest.java | 84 +++ ...UuidColumnOfQualityGateConditionsTableTest.java | 50 ++ ...UuidColumnToQualityGateConditionsTableTest.java | 66 ++ ...opIdColumnOfQualityGateConditionsTableTest.java | 51 ++ ...OnIdColumnOfQualityGateConditionsTableTest.java | 56 ++ ...ityGateConditionsUuidColumnNotNullableTest.java | 42 ++ .../PopulateQualityGateConditionsUuidTest.java | 81 +++ ...AddPrimaryKeyOnUuidColumnOfQGatesTableTest.java | 50 ++ .../AddQGateUuidColumnForQGateConditionsTest.java | 52 ++ .../qualitygates/DropIdColumnOfQGateTableTest.java | 51 ++ .../DropOrphansQGateConditionsTest.java | 73 ++ .../DropPrimaryKeyOnIdColumnOfQGatesTableTest.java | 56 ++ .../DropQGateIdColumnForQGateConditionsTest.java | 50 ++ ...ueIndexOnUuidColumnOfQualityGatesTableTest.java | 43 ++ ...uidColumnNotNullableForQGateConditionsTest.java | 43 ++ ...ulateQGateUuidColumnForQGateConditionsTest.java | 93 +++ .../AddPrimaryKeyOnUuidColumnOfRulesTableTest.java | 50 ++ .../AddUuidAndTemplateUuidColumnsToRulesTest.java | 66 ++ .../v84/rules/DropIdColumnOfRulesTableTest.java | 50 ++ .../DropPrimaryKeyOnIdColumnOfRulesTableTest.java | 56 ++ .../DropTemplateIdColumnOfRulesTableTest.java | 50 ++ .../rules/MakeRulesUuidColumnNotNullableTest.java | 43 ++ .../v84/rules/PopulateRulesTemplateUuidTest.java | 74 ++ .../version/v84/rules/PopulateRulesUuidTest.java | 73 ++ .../AddIndexToActiveRulesTableTest.java | 51 ++ .../AddRuleUuidColumnToActiveRulesTableTest.java | 79 +++ ...pIndexOnRuleIdColumnOfActiveRulesTableTest.java | 54 ++ .../DropRuleIdColumnOfActiveRulesTableTest.java | 50 ++ ...keActiveRulesRuleUuidColumnNotNullableTest.java | 43 ++ .../PopulateActiveRulesRuleUuidColumnTest.java | 84 +++ .../AddIndexToDeprecatedRuleKeysTableTest.java | 51 ++ ...uleUuidColumnToDeprecatedRuleKeysTableTest.java | 80 +++ ...nRuleIdColumnOfDeprecatedRuleKeysTableTest.java | 54 ++ ...pRuleIdColumnOfDeprecatedRuleKeysTableTest.java | 50 ++ ...catedRuleKeysRuleUuidColumnNotNullableTest.java | 43 ++ ...pulateDeprecatedRuleKeysRuleUuidColumnTest.java | 86 +++ .../rules/issues/AddIndexToIssuesTableTest.java | 51 ++ .../issues/AddRuleUuidColumnToIssuesTableTest.java | 81 +++ .../DropIndexOnRuleIdColumnOfIssuesTableTest.java | 54 ++ .../issues/DropRuleIdColumnOfIssuesTableTest.java | 50 ++ .../issues/PopulateIssuesRuleUuidColumnTest.java | 87 +++ ...nizationUuidColumnOfRulesMetadataTableTest.java | 50 ++ .../AddRuleUuidColumnToRulesMetadataTableTest.java | 80 +++ ...imaryKeyOnIdColumnOfRulesMetadataTableTest.java | 56 ++ .../DropRuleIdColumnOfRulesMetadataTableTest.java | 50 ++ ...RulesMetadataRuleUuidColumnNotNullableTest.java | 43 ++ .../PopulateRulesMetadataRuleUuidColumnTest.java | 85 +++ .../AddIndexesToRulesParametersTableTest.java | 53 ++ ...ddRuleUuidColumnToRulesParametersTableTest.java | 78 ++ ...esOnRuleIdColumnOfRulesParametersTableTest.java | 57 ++ ...DropRuleIdColumnOfRulesParametersTableTest.java | 50 ++ ...lesParametersRuleUuidColumnNotNullableTest.java | 43 ++ .../PopulateRulesParametersRuleUuidColumnTest.java | 83 +++ ...yKeyOnUuidColumnOfRulesParametersTableTest.java | 51 ++ .../AddUuidColumnToRulesParametersTest.java | 67 ++ .../DropIdColumnOfRulesParametersTableTest.java | 51 ++ ...aryKeyOnIdColumnOfRulesParametersTableTest.java | 56 ++ ...keRulesParametersUuidColumnNotNullableTest.java | 43 ++ .../PopulateRulesParametersUuidTest.java | 82 +++ ...ameterUuidColumnToActiveRuleParametersTest.java | 66 ++ ...terIdColumnOfActiveRuleParametersTableTest.java | 51 ++ ...ersRulesParameterUuidColumnNotNullableTest.java | 43 ++ ...ActiveRuleParametersRulesParameterUuidTest.java | 127 ++++ ...aryKeyOnUuidColumnOfRulesProfilesTableTest.java | 49 ++ .../AddUuidColumnToRulesProfilesTableTest.java | 67 ++ .../DropIdColumnOfRulesProfilesTableTest.java | 49 ++ .../DropKeeColumnOfRulesProfilesTableTest.java | 49 ++ ...imaryKeyOnIdColumnOfRulesProfilesTableTest.java | 54 ++ ...ueIndexOnKeeColumnOfRulesProfilesTableTest.java | 54 ++ ...MakeRulesProfilesUuidColumnNotNullableTest.java | 43 ++ .../PopulateRulesProfilesUuidTest.java | 81 +++ ...AddProfileUuidColumnToActiveRulesTableTest.java | 63 ++ ...xOnProfileUuidColumnOfActiveRulesTableTest.java | 51 ++ .../DropProfileIdColumnOfActiveRulesTableTest.java | 49 ++ ...dexOnProfileIdColumnOfActiveRulesTableTest.java | 51 ++ ...ctiveRulesProfileUuidColumnNotNullableTest.java | 43 ++ .../PopulateActiveRulesProfileUuidTest.java | 113 +++ .../PopulateOrgQProfilesRulesProfileUuidTest.java | 137 ++++ ...opulateQProfileChangesRulesProfileUuidTest.java | 136 ++++ ...PrimaryKeyOnUuidColumnOfSnapshotsTableTest.java | 50 ++ .../DropIdColumnOfSnapshotsTableTest.java | 51 ++ ...opPrimaryKeyOnIdColumnOfSnapshotsTableTest.java | 56 ++ .../AddPrimaryKeyOnUuidColumnOfUsersTableTest.java | 49 ++ .../v84/users/DropIdColumnOfUsersTableTest.java | 49 ++ .../DropPrimaryKeyOnIdColumnOfUsersTableTest.java | 54 ++ ...ropUniqueIndexOnUuidColumnOfUsersTableTest.java | 50 ++ .../AddIndexOnUserUuidOfGroupsUsersTableTest.java | 49 ++ ...OnUserUuidAndGroupIdOfGroupsUsersTableTest.java | 51 ++ .../AddUserUuidColumnToGroupsUsersTest.java | 62 ++ .../DropIndexOnUserIdOfGroupsUsersTableTest.java | 50 ++ ...exOnUserIdAndGroupIdOfGroupsUsersTableTest.java | 50 ++ .../DropUserIdColumnOfGroupsUsersTableTest.java | 50 ++ ...keGroupsUsersUserUuidColumnNotNullableTest.java | 43 ++ .../PopulateGroupsUsersUserUuidTest.java | 139 ++++ ...exOnUserUuidOfOrganizationMembersTableTest.java | 49 ++ ...rganizationUuidColumnsOfUserRolesTableTest.java | 51 ++ ...AddUserUuidColumnToOrganizationMembersTest.java | 61 ++ ...ndexOnUserIdOfOrganizationMembersTableTest.java | 50 ++ ...nizationUuidOfOrganizationMembersTableTest.java | 54 ++ ...UserIdColumnOfOrganizationMembersTableTest.java | 51 ++ ...zationMembersUserUuidColumnNotNullableTest.java | 43 ++ .../PopulateOrganizationMembersUserUuidTest.java | 140 ++++ .../AddUserUuidColumnToPermTemplatesUsersTest.java | 65 ++ ...pUserIdColumnOfPermTemplatesUsersTableTest.java | 51 ++ ...emplatesUsersUserUuidColumnNotNullableTest.java | 43 ++ .../PopulatePermTemplatesUsersUserUuidTest.java | 145 ++++ .../AddUserUuidColumnToPropertiesUsersTest.java | 65 ++ .../DropUserIdColumnOfPropertiesTableTest.java | 51 ++ .../properties/PopulatePropertiesUserUuidTest.java | 154 ++++ ...ndQProfileUuidOfQProfileEditUsersTableTest.java | 49 ++ .../AddUserUuidColumnToQProfileEditUsersTest.java | 64 ++ ...ndQProfileUuidOfQProfileEditUsersTableTest.java | 50 ++ ...opUserIdColumnOfQProfileEditUsersTableTest.java | 51 ++ ...fileEditUsersUserUuidColumnNotNullableTest.java | 43 ++ .../PopulateQProfileEditUsersUserUuidTest.java | 145 ++++ .../AddIndexOnUserUuidOfUserRolesTableTest.java | 49 ++ .../AddUserUuidColumnToUserRolesTest.java | 64 ++ .../DropIndexOnUserIdOfUserRolesTableTest.java | 52 ++ .../DropUserIdColumnOfUserRolesTableTest.java | 51 ++ .../userroles/PopulateUserRolesUserUuidTest.java | 145 ++++ ...rimaryKeyOnUuidColumnOfUserTokensTableTest.java | 49 ++ .../usertokens/AddUuidColumnToUserTokensTest.java | 63 ++ .../DropIdColumnOfUserTokensTableTest.java | 49 ++ ...pPrimaryKeyOnIdColumnOfUserTokensTableTest.java | 55 ++ .../MakeUserTokensUuidNotNullableTest.java | 43 ++ .../v84/usertokens/PopulateUserTokensUuidTest.java | 97 +++ .../version/v84/util/AddPrimaryKeyBuilderTest.java | 43 ++ .../v84/util/DropPrimaryKeySqlGeneratorTest.java | 96 +++ .../schema.sql | 10 - .../schema.sql | 9 - .../schema.sql | 10 - .../schema.sql | 10 - .../schema.sql | 10 - .../schema.sql | 10 - .../schema.sql | 9 - .../schema.sql | 9 - .../schema.sql | 11 - .../AddUuidColumnToActiveRulesTableTest/schema.sql | 11 - .../schema.sql | 10 - .../DropIdColumnOfActiveRulesTableTest/schema.sql | 12 - .../schema.sql | 10 - .../schema.sql | 12 - .../schema.sql | 10 - .../schema.sql | 12 - .../schema.sql | 23 - .../PopulateActiveRulesUuidTest/schema.sql | 12 - .../schema.sql | 32 - .../DropIdColumnOfCeActivityTableTest/schema.sql | 33 - .../schema.sql | 33 - .../schema.sql | 16 - .../DropIdColumnOfCeQueueTableTest/schema.sql | 17 - .../schema.sql | 17 - .../schema.sql | 18 - .../schema.sql | 12 - .../AddUuidToDuplicationsIndexTableTest/schema.sql | 13 - .../schema.sql | 13 - .../schema.sql | 13 - .../schema.sql | 13 - .../PopulateDuplicationsIndexUuidTest/schema.sql | 13 - .../schema.sql | 15 - .../DropIdColumnOfEventsTableTest/schema.sql | 16 - .../schema.sql | 16 - .../schema.sql | 18 - .../AddUuidColumnToFileSourcesTableTest/schema.sql | 18 - .../DropIdColumnOfFileSourcesTableTest/schema.sql | 19 - .../schema.sql | 19 - .../schema.sql | 19 - .../PopulateFileSourcesUuidTest/schema.sql | 19 - .../schema.sql | 11 - .../AddUuidColumnToGroupRolesTableTest/schema.sql | 10 - .../DropIdColumnOfGroupRolesTableTest/schema.sql | 11 - .../schema.sql | 11 - .../schema.sql | 11 - .../PopulateGroupRolesUuidTest/schema.sql | 11 - .../schema.sql | 9 - .../AddUuidColumnToGroupsTableTest/schema.sql | 9 - .../DropIdColumnOfGroupsTableTest/schema.sql | 10 - .../schema.sql | 10 - .../MakeGroupsUuidColumnNotNullableTest/schema.sql | 10 - .../v83/groups/PopulateGroupsUuidTest/schema.sql | 10 - .../AddGroupUuidColumnToGroupRolesTest/schema.sql | 10 - .../schema.sql | 10 - .../schema.sql | 11 - .../schema.sql | 11 - .../PopulateGroupRolesGroupUuidTest/schema.sql | 22 - .../AddGroupUuidColumnToGroupsUsersTest/schema.sql | 7 - .../schema.sql | 6 - .../schema.sql | 8 - .../schema.sql | 8 - .../schema.sql | 8 - .../PopulateGroupsUsersGroupUuidTest/schema.sql | 19 - .../schema.sql | 20 - .../schema.sql | 21 - .../schema.sql | 32 - .../schema.sql | 9 - .../schema.sql | 10 - .../schema.sql | 21 - .../schema.sql | 9 - .../schema.sql | 9 - .../schema.sql | 10 - .../schema.sql | 10 - .../schema.sql | 10 - .../schema.sql | 21 - .../schema.sql | 14 - .../schema.sql | 14 - .../DropIdColumnOfIssueChangesTableTest/schema.sql | 15 - .../schema.sql | 15 - .../schema.sql | 15 - .../PopulateIssueChangesUuidTest/schema.sql | 15 - .../schema.sql | 38 - .../DropIdColumnOfIssuesTableTest/schema.sql | 39 - .../schema.sql | 39 - .../schema.sql | 13 - .../AddUuidToManualMeasuresTest/schema.sql | 13 - .../schema.sql | 13 - .../schema.sql | 14 - .../schema.sql | 14 - .../PopulateManualMeasuresUuidTest/schema.sql | 14 - .../schema.sql | 20 - .../AddUuidColumnToMetricsTableTest/schema.sql | 20 - .../DropIdColumnOfMetricsTableTest/schema.sql | 21 - .../schema.sql | 21 - .../schema.sql | 21 - .../v83/metrics/PopulateMetricsUuidTest/schema.sql | 21 - .../schema.sql | 16 - .../schema.sql | 16 - .../schema.sql | 17 - .../schema.sql | 17 - .../schema.sql | 17 - .../PopulateLiveMeasuresMetricUuidTest/schema.sql | 39 - .../schema.sql | 35 - .../schema.sql | 36 - .../schema.sql | 36 - .../schema.sql | 36 - .../schema.sql | 21 - .../schema.sql | 21 - .../schema.sql | 22 - .../schema.sql | 22 - .../schema.sql | 22 - .../schema.sql | 44 -- .../schema.sql | 34 - .../schema.sql | 35 - .../schema.sql | 35 - .../schema.sql | 35 - .../schema.sql | 6 - .../schema.sql | 5 - .../DropIdColumnOfNotificationTableTest/schema.sql | 7 - .../schema.sql | 7 - .../schema.sql | 7 - .../schema.sql | 7 - .../schema.sql | 12 - .../schema.sql | 11 - .../schema.sql | 12 - .../schema.sql | 11 - .../schema.sql | 12 - .../schema.sql | 12 - .../PopulatePermissionTemplatesUuidTest/schema.sql | 12 - .../schema.sql | 9 - .../schema.sql | 10 - .../schema.sql | 10 - .../schema.sql | 23 - .../schema.sql | 9 - .../schema.sql | 10 - .../schema.sql | 10 - .../schema.sql | 23 - .../schema.sql | 10 - .../schema.sql | 11 - .../schema.sql | 11 - .../schema.sql | 11 - .../schema.sql | 11 - .../schema.sql | 24 - .../schema.sql | 9 - .../schema.sql | 9 - .../schema.sql | 10 - .../schema.sql | 10 - .../schema.sql | 10 - .../PopulatePermTemplatesGroupsUuidTest/schema.sql | 10 - .../schema.sql | 9 - .../schema.sql | 9 - .../schema.sql | 10 - .../schema.sql | 10 - .../schema.sql | 10 - .../PopulatePermTemplatesUsersUuidTest/schema.sql | 10 - .../schema.sql | 10 - .../schema.sql | 10 - .../schema.sql | 11 - .../schema.sql | 11 - .../schema.sql | 11 - .../schema.sql | 11 - .../schema.sql | 21 - .../AddUuidToProjectMeasuresTest/schema.sql | 21 - .../schema.sql | 22 - .../schema.sql | 22 - .../schema.sql | 22 - .../PopulateProjectMeasuresUuidTest/schema.sql | 22 - .../schema.sql | 7 - .../schema.sql | 7 - .../schema.sql | 8 - .../schema.sql | 8 - .../schema.sql | 8 - .../PopulateProjectQProfilesUuidTest/schema.sql | 8 - .../schema.sql | 12 - .../AddUuidColumnToPropertiesTest/schema.sql | 12 - .../DropIdColumnOfPropertiesTableTest/schema.sql | 13 - .../schema.sql | 13 - .../schema.sql | 13 - .../MakePropertiesUuidColumnNotNullable/schema.sql | 13 - .../schema.sql | 13 - .../schema.sql | 12 - .../schema.sql | 12 - .../schema.sql | 13 - .../schema.sql | 13 - .../schema.sql | 12 - .../schema.sql | 13 - .../schema.sql | 9 - .../schema.sql | 23 - .../DropIdColumnOfQGateTableTest/schema.sql | 10 - .../DropOrphansQGateConditionsTest/schema.sql | 24 - .../schema.sql | 10 - .../schema.sql | 13 - .../schema.sql | 9 - .../schema.sql | 13 - .../schema.sql | 24 - .../schema.sql | 29 - .../schema.sql | 29 - .../rules/DropIdColumnOfRulesTableTest/schema.sql | 30 - .../schema.sql | 30 - .../schema.sql | 31 - .../MakeRulesUuidColumnNotNullableTest/schema.sql | 31 - .../rules/PopulateRulesTemplateUuidTest/schema.sql | 31 - .../v83/rules/PopulateRulesUuidTest/schema.sql | 31 - .../AddIndexToActiveRulesTableTest/schema.sql | 42 -- .../schema.sql | 42 -- .../schema.sql | 43 -- .../schema.sql | 43 -- .../schema.sql | 43 -- .../schema.sql | 43 -- .../schema.sql | 41 -- .../schema.sql | 41 -- .../schema.sql | 42 -- .../schema.sql | 42 -- .../schema.sql | 42 -- .../schema.sql | 42 -- .../issues/AddIndexToIssuesTableTest/schema.sql | 69 -- .../AddRuleUuidColumnToIssuesTableTest/schema.sql | 69 -- .../schema.sql | 70 -- .../DropRuleIdColumnOfIssuesTableTest/schema.sql | 70 -- .../PopulateIssuesRuleUuidColumnTest/schema.sql | 70 -- .../schema.sql | 50 -- .../schema.sql | 50 -- .../schema.sql | 51 -- .../schema.sql | 51 -- .../schema.sql | 51 -- .../schema.sql | 51 -- .../schema.sql | 41 -- .../schema.sql | 42 -- .../schema.sql | 43 -- .../schema.sql | 43 -- .../schema.sql | 43 -- .../schema.sql | 43 -- .../schema.sql | 11 - .../AddUuidColumnToRulesParametersTest/schema.sql | 11 - .../schema.sql | 12 - .../schema.sql | 12 - .../schema.sql | 12 - .../PopulateRulesParametersUuidTest/schema.sql | 12 - .../schema.sql | 9 - .../schema.sql | 10 - .../schema.sql | 10 - .../schema.sql | 23 - .../schema.sql | 10 - .../schema.sql | 12 - .../schema.sql | 11 - .../schema.sql | 13 - .../schema.sql | 11 - .../schema.sql | 13 - .../schema.sql | 13 - .../PopulateRulesProfilesUuidTest/schema.sql | 13 - .../schema.sql | 11 - .../schema.sql | 11 - .../schema.sql | 12 - .../schema.sql | 12 - .../schema.sql | 26 - .../PopulateActiveRulesProfileUuidTest/schema.sql | 26 - .../schema.sql | 28 - .../schema.sql | 24 - .../schema.sql | 30 - .../DropIdColumnOfSnapshotsTableTest/schema.sql | 31 - .../schema.sql | 31 - .../schema.sql | 10 - .../AddUuidColumnToUserRolesTableTest/schema.sql | 10 - .../DropIdColumnOfUserRolesTableTest/schema.sql | 11 - .../schema.sql | 11 - .../schema.sql | 11 - .../userroles/PopulateUserRolesUuidTest/schema.sql | 11 - .../schema.sql | 29 - .../users/DropIdColumnOfUsersTableTest/schema.sql | 30 - .../schema.sql | 30 - .../schema.sql | 29 - .../schema.sql | 7 - .../schema.sql | 7 - .../AddUserUuidColumnToGroupsUsersTest/schema.sql | 7 - .../schema.sql | 8 - .../schema.sql | 8 - .../schema.sql | 8 - .../schema.sql | 8 - .../PopulateGroupsUsersUserUuidTest/schema.sql | 40 -- .../schema.sql | 7 - .../schema.sql | 7 - .../schema.sql | 7 - .../schema.sql | 8 - .../schema.sql | 8 - .../schema.sql | 7 - .../schema.sql | 8 - .../schema.sql | 40 -- .../schema.sql | 9 - .../schema.sql | 11 - .../schema.sql | 11 - .../schema.sql | 42 -- .../schema.sql | 11 - .../schema.sql | 15 - .../PopulatePropertiesUserUuidTest/schema.sql | 44 -- .../schema.sql | 9 - .../schema.sql | 9 - .../schema.sql | 10 - .../schema.sql | 10 - .../schema.sql | 10 - .../schema.sql | 41 -- .../schema.sql | 10 - .../AddUserUuidColumnToUserRolesTest/schema.sql | 10 - .../schema.sql | 11 - .../schema.sql | 11 - .../PopulateUserRolesUserUuidTest/schema.sql | 42 -- .../schema.sql | 11 - .../AddUuidColumnToUserTokensTest/schema.sql | 11 - .../DropIdColumnOfUserTokensTableTest/schema.sql | 12 - .../schema.sql | 11 - .../MakeUserTokensUuidNotNullableTest/schema.sql | 12 - .../PopulateUserTokensUuidTest/schema.sql | 12 - .../schema.sql | 10 + .../schema.sql | 9 + .../schema.sql | 10 + .../schema.sql | 10 + .../schema.sql | 10 + .../schema.sql | 10 + .../schema.sql | 9 + .../schema.sql | 9 + .../schema.sql | 11 + .../AddUuidColumnToActiveRulesTableTest/schema.sql | 11 + .../schema.sql | 10 + .../DropIdColumnOfActiveRulesTableTest/schema.sql | 12 + .../schema.sql | 10 + .../schema.sql | 12 + .../schema.sql | 10 + .../schema.sql | 12 + .../schema.sql | 23 + .../PopulateActiveRulesUuidTest/schema.sql | 12 + .../schema.sql | 32 + .../DropIdColumnOfCeActivityTableTest/schema.sql | 33 + .../schema.sql | 33 + .../schema.sql | 16 + .../DropIdColumnOfCeQueueTableTest/schema.sql | 17 + .../schema.sql | 17 + .../schema.sql | 18 + .../schema.sql | 12 + .../AddUuidToDuplicationsIndexTableTest/schema.sql | 13 + .../schema.sql | 13 + .../schema.sql | 13 + .../schema.sql | 13 + .../PopulateDuplicationsIndexUuidTest/schema.sql | 13 + .../schema.sql | 15 + .../DropIdColumnOfEventsTableTest/schema.sql | 16 + .../schema.sql | 16 + .../schema.sql | 18 + .../AddUuidColumnToFileSourcesTableTest/schema.sql | 18 + .../DropIdColumnOfFileSourcesTableTest/schema.sql | 19 + .../schema.sql | 19 + .../schema.sql | 19 + .../PopulateFileSourcesUuidTest/schema.sql | 19 + .../schema.sql | 11 + .../AddUuidColumnToGroupRolesTableTest/schema.sql | 10 + .../DropIdColumnOfGroupRolesTableTest/schema.sql | 11 + .../schema.sql | 11 + .../schema.sql | 11 + .../PopulateGroupRolesUuidTest/schema.sql | 11 + .../schema.sql | 9 + .../AddUuidColumnToGroupsTableTest/schema.sql | 9 + .../DropIdColumnOfGroupsTableTest/schema.sql | 10 + .../schema.sql | 10 + .../MakeGroupsUuidColumnNotNullableTest/schema.sql | 10 + .../v84/groups/PopulateGroupsUuidTest/schema.sql | 10 + .../AddGroupUuidColumnToGroupRolesTest/schema.sql | 10 + .../schema.sql | 10 + .../schema.sql | 11 + .../schema.sql | 11 + .../PopulateGroupRolesGroupUuidTest/schema.sql | 22 + .../AddGroupUuidColumnToGroupsUsersTest/schema.sql | 7 + .../schema.sql | 6 + .../schema.sql | 8 + .../schema.sql | 8 + .../schema.sql | 8 + .../PopulateGroupsUsersGroupUuidTest/schema.sql | 19 + .../schema.sql | 20 + .../schema.sql | 21 + .../schema.sql | 32 + .../schema.sql | 9 + .../schema.sql | 10 + .../schema.sql | 21 + .../schema.sql | 9 + .../schema.sql | 9 + .../schema.sql | 10 + .../schema.sql | 10 + .../schema.sql | 10 + .../schema.sql | 21 + .../schema.sql | 14 + .../schema.sql | 14 + .../DropIdColumnOfIssueChangesTableTest/schema.sql | 15 + .../schema.sql | 15 + .../schema.sql | 15 + .../PopulateIssueChangesUuidTest/schema.sql | 15 + .../schema.sql | 38 + .../DropIdColumnOfIssuesTableTest/schema.sql | 39 + .../schema.sql | 39 + .../schema.sql | 13 + .../AddUuidToManualMeasuresTest/schema.sql | 13 + .../schema.sql | 13 + .../schema.sql | 14 + .../schema.sql | 14 + .../PopulateManualMeasuresUuidTest/schema.sql | 14 + .../schema.sql | 20 + .../AddUuidColumnToMetricsTableTest/schema.sql | 20 + .../DropIdColumnOfMetricsTableTest/schema.sql | 21 + .../schema.sql | 21 + .../schema.sql | 21 + .../v84/metrics/PopulateMetricsUuidTest/schema.sql | 21 + .../schema.sql | 16 + .../schema.sql | 16 + .../schema.sql | 17 + .../schema.sql | 17 + .../schema.sql | 17 + .../PopulateLiveMeasuresMetricUuidTest/schema.sql | 39 + .../schema.sql | 35 + .../schema.sql | 36 + .../schema.sql | 36 + .../schema.sql | 36 + .../schema.sql | 21 + .../schema.sql | 21 + .../schema.sql | 22 + .../schema.sql | 22 + .../schema.sql | 22 + .../schema.sql | 44 ++ .../schema.sql | 34 + .../schema.sql | 35 + .../schema.sql | 35 + .../schema.sql | 35 + .../schema.sql | 6 + .../schema.sql | 5 + .../DropIdColumnOfNotificationTableTest/schema.sql | 7 + .../schema.sql | 7 + .../schema.sql | 7 + .../schema.sql | 7 + .../schema.sql | 12 + .../schema.sql | 11 + .../schema.sql | 12 + .../schema.sql | 11 + .../schema.sql | 12 + .../schema.sql | 12 + .../PopulatePermissionTemplatesUuidTest/schema.sql | 12 + .../schema.sql | 9 + .../schema.sql | 10 + .../schema.sql | 10 + .../schema.sql | 23 + .../schema.sql | 9 + .../schema.sql | 10 + .../schema.sql | 10 + .../schema.sql | 23 + .../schema.sql | 10 + .../schema.sql | 11 + .../schema.sql | 11 + .../schema.sql | 11 + .../schema.sql | 11 + .../schema.sql | 24 + .../schema.sql | 9 + .../schema.sql | 9 + .../schema.sql | 10 + .../schema.sql | 10 + .../schema.sql | 10 + .../PopulatePermTemplatesGroupsUuidTest/schema.sql | 10 + .../schema.sql | 9 + .../schema.sql | 9 + .../schema.sql | 10 + .../schema.sql | 10 + .../schema.sql | 10 + .../PopulatePermTemplatesUsersUuidTest/schema.sql | 10 + .../schema.sql | 10 + .../schema.sql | 10 + .../schema.sql | 11 + .../schema.sql | 11 + .../schema.sql | 11 + .../schema.sql | 11 + .../schema.sql | 21 + .../AddUuidToProjectMeasuresTest/schema.sql | 21 + .../schema.sql | 22 + .../schema.sql | 22 + .../schema.sql | 22 + .../PopulateProjectMeasuresUuidTest/schema.sql | 22 + .../schema.sql | 7 + .../schema.sql | 7 + .../schema.sql | 8 + .../schema.sql | 8 + .../schema.sql | 8 + .../PopulateProjectQProfilesUuidTest/schema.sql | 8 + .../schema.sql | 12 + .../AddUuidColumnToPropertiesTest/schema.sql | 12 + .../DropIdColumnOfPropertiesTableTest/schema.sql | 13 + .../schema.sql | 13 + .../schema.sql | 13 + .../MakePropertiesUuidColumnNotNullable/schema.sql | 13 + .../schema.sql | 13 + .../schema.sql | 12 + .../schema.sql | 12 + .../schema.sql | 13 + .../schema.sql | 13 + .../schema.sql | 12 + .../schema.sql | 13 + .../schema.sql | 9 + .../schema.sql | 23 + .../DropIdColumnOfQGateTableTest/schema.sql | 10 + .../DropOrphansQGateConditionsTest/schema.sql | 24 + .../schema.sql | 10 + .../schema.sql | 13 + .../schema.sql | 9 + .../schema.sql | 13 + .../schema.sql | 24 + .../schema.sql | 29 + .../schema.sql | 29 + .../rules/DropIdColumnOfRulesTableTest/schema.sql | 30 + .../schema.sql | 30 + .../schema.sql | 31 + .../MakeRulesUuidColumnNotNullableTest/schema.sql | 31 + .../rules/PopulateRulesTemplateUuidTest/schema.sql | 31 + .../v84/rules/PopulateRulesUuidTest/schema.sql | 31 + .../AddIndexToActiveRulesTableTest/schema.sql | 42 ++ .../schema.sql | 42 ++ .../schema.sql | 43 ++ .../schema.sql | 43 ++ .../schema.sql | 43 ++ .../schema.sql | 43 ++ .../schema.sql | 41 ++ .../schema.sql | 41 ++ .../schema.sql | 42 ++ .../schema.sql | 42 ++ .../schema.sql | 42 ++ .../schema.sql | 42 ++ .../issues/AddIndexToIssuesTableTest/schema.sql | 69 ++ .../AddRuleUuidColumnToIssuesTableTest/schema.sql | 69 ++ .../schema.sql | 70 ++ .../DropRuleIdColumnOfIssuesTableTest/schema.sql | 70 ++ .../PopulateIssuesRuleUuidColumnTest/schema.sql | 70 ++ .../schema.sql | 50 ++ .../schema.sql | 50 ++ .../schema.sql | 51 ++ .../schema.sql | 51 ++ .../schema.sql | 51 ++ .../schema.sql | 51 ++ .../schema.sql | 41 ++ .../schema.sql | 42 ++ .../schema.sql | 43 ++ .../schema.sql | 43 ++ .../schema.sql | 43 ++ .../schema.sql | 43 ++ .../schema.sql | 11 + .../AddUuidColumnToRulesParametersTest/schema.sql | 11 + .../schema.sql | 12 + .../schema.sql | 12 + .../schema.sql | 12 + .../PopulateRulesParametersUuidTest/schema.sql | 12 + .../schema.sql | 9 + .../schema.sql | 10 + .../schema.sql | 10 + .../schema.sql | 23 + .../schema.sql | 10 + .../schema.sql | 12 + .../schema.sql | 11 + .../schema.sql | 13 + .../schema.sql | 11 + .../schema.sql | 13 + .../schema.sql | 13 + .../PopulateRulesProfilesUuidTest/schema.sql | 13 + .../schema.sql | 11 + .../schema.sql | 11 + .../schema.sql | 12 + .../schema.sql | 12 + .../schema.sql | 26 + .../PopulateActiveRulesProfileUuidTest/schema.sql | 26 + .../schema.sql | 28 + .../schema.sql | 24 + .../schema.sql | 30 + .../DropIdColumnOfSnapshotsTableTest/schema.sql | 31 + .../schema.sql | 31 + .../schema.sql | 10 + .../AddUuidColumnToUserRolesTableTest/schema.sql | 10 + .../DropIdColumnOfUserRolesTableTest/schema.sql | 11 + .../schema.sql | 11 + .../schema.sql | 11 + .../userroles/PopulateUserRolesUuidTest/schema.sql | 11 + .../schema.sql | 29 + .../users/DropIdColumnOfUsersTableTest/schema.sql | 30 + .../schema.sql | 30 + .../schema.sql | 29 + .../schema.sql | 7 + .../schema.sql | 7 + .../AddUserUuidColumnToGroupsUsersTest/schema.sql | 7 + .../schema.sql | 8 + .../schema.sql | 8 + .../schema.sql | 8 + .../schema.sql | 8 + .../PopulateGroupsUsersUserUuidTest/schema.sql | 40 ++ .../schema.sql | 7 + .../schema.sql | 7 + .../schema.sql | 7 + .../schema.sql | 8 + .../schema.sql | 8 + .../schema.sql | 7 + .../schema.sql | 8 + .../schema.sql | 40 ++ .../schema.sql | 9 + .../schema.sql | 11 + .../schema.sql | 11 + .../schema.sql | 42 ++ .../schema.sql | 11 + .../schema.sql | 15 + .../PopulatePropertiesUserUuidTest/schema.sql | 44 ++ .../schema.sql | 9 + .../schema.sql | 9 + .../schema.sql | 10 + .../schema.sql | 10 + .../schema.sql | 10 + .../schema.sql | 41 ++ .../schema.sql | 10 + .../AddUserUuidColumnToUserRolesTest/schema.sql | 10 + .../schema.sql | 11 + .../schema.sql | 11 + .../PopulateUserRolesUserUuidTest/schema.sql | 42 ++ .../schema.sql | 11 + .../AddUuidColumnToUserTokensTest/schema.sql | 11 + .../DropIdColumnOfUserTokensTableTest/schema.sql | 12 + .../schema.sql | 11 + .../MakeUserTokensUuidNotNullableTest/schema.sql | 12 + .../PopulateUserTokensUuidTest/schema.sql | 12 + 1881 files changed, 39010 insertions(+), 38961 deletions(-) delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/AddUuidColumnToActiveRuleParametersTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/DropIdColumnOfActiveRuleParametersTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/DropPrimaryKeyOnIdColumnOfActiveRuleParametersTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/MakeActiveRuleParametersUuidColumnNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/PopulateActiveRuleParametersUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/AddActiveRuleUuidColumnToActiveRuleParameters.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/AddIndexOnActiveRuleUuidOfActiveRuleParametersTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/AddPrimaryKeyOnUuidColumnOfActiveRulesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/AddUuidColumnToActiveRulesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/DropActiveRuleIdColumnOfActiveRuleParametersTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/DropIdColumnOfActiveRulesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/DropIndexOnActiveRuleIdOfActiveRuleParametersTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/DropPrimaryKeyOnIdColumnOfActiveRulesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/MakeActiveRuleParametersActiveRuleUuidNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/MakeActiveRulesUuidColumnNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/PopulateActiveRuleParametersActiveRuleUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/PopulateActiveRulesUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/ceactivity/DropIdColumnOfCeActivityTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/cequeue/AddPrimaryKeyOnUuidColumnOfCeQueueTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/cequeue/DropIdColumnOfCeQueueTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/cequeue/DropPrimaryKeyOnIdColumnOfCeQueueTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/cequeue/DropUniqueIndexOnUuidColumnOfCeQueueTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/common/AddUuidColumnToTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/common/DropIdColumn.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/common/DropPrimaryKeyOnIdColumn.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/common/MakeUuidColumnNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/AddUuidToDuplicationsIndexTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/DropIdColumnOfDuplicationsIndexTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/DropPrimaryKeyOnIdColumnOfDuplicationsIndexTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/MakeDuplicationsIndexUuidColumnNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/PopulateDuplicationsIndexUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/events/AddPrimaryKeyOnUuidColumnOfEventsTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/events/DropIdColumnOfEventsTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/events/DropPrimaryKeyOnIdColumnOfEventsTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/filesources/AddPrimaryKeyOnUuidColumnOfFileSourcesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/filesources/AddUuidColumnToFileSourcesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/filesources/DropIdColumnOfFileSourcesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/filesources/DropPrimaryKeyOnIdColumnOfFileSourcesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/filesources/MakeFileSourcesUuidColumnNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/filesources/PopulateFileSourcesUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/grouproles/AddPrimaryKeyOnUuidColumnOfGroupRolesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/grouproles/AddUuidColumnToGroupRolesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/grouproles/DropIdColumnOfGroupRolesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/grouproles/DropPrimaryKeyOnIdColumnOfGroupRolesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/grouproles/MakeGroupRolesUuidColumnNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/grouproles/PopulateGroupRolesUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/AddPrimaryKeyOnUuidColumnOfGroupsTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/AddUuidColumnToGroupsTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/DropIdColumnOfGroupsTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/DropPrimaryKeyOnIdColumnOfGroupsTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/MakeGroupsUuidColumnNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/PopulateGroupsUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/AddGroupUuidColumnToGroupRoles.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/AddIndexOnGroupUuidOfGroupRolesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/DropGroupIdColumnOfGroupRolesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/DropIndexOnGroupIdOfGroupRolesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/PopulateGroupRolesGroupUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/AddGroupUuidColumnToGroupsUsers.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/AddIndexOnGroupUuidOfGroupsUsersTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/DropGroupIdColumnOfGroupsUsersTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/DropIndexOnGroupIdOfGroupsUsersTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/MakeGroupsUsersGroupUuidNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/PopulateGroupsUsersGroupUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/organizations/AddDefaultGroupUuidColumnToOrganizations.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/organizations/DropDefaultGroupIdColumnOfOrganizationsTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/organizations/PopulateOrganizationsDefaultGroupUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/permtemplatesgroups/AddGroupUuidColumnToPermTemplatesGroups.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/permtemplatesgroups/DropGroupIdColumnOfPermTemplatesGroupsTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/permtemplatesgroups/PopulatePermTemplatesGroupsGroupUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/AddGroupUuidColumnToQProfileEditGroups.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/AddIndexOnGroupUuidOfQProfileEditGroupsTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/DropGroupIdColumnOfQProfileEditGroupsTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/DropIndexOnGroupIdOfQProfileEditGroupsTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/MakeQProfileEditGroupsGroupUuidNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/PopulateQProfileEditGroupsGroupUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/AddPrimaryKeyOnUuidColumnOfIssueChangesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/AddUuidColumnToIssueChangesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/DropIdColumnOfIssueChangesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/DropPrimaryKeyOnIdColumnOfIssueChangesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/MakeIssueChangesUuidColumnNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/PopulateIssueChangesUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issues/AddPrimaryKeyOnKeeColumnOfIssuesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issues/DropIdColumnOfIssuesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issues/DropPrimaryKeyOnIdColumnOfIssuesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/AddPrimaryKeyOnUuidColumnOfManualMeasuresTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/AddUuidColumnToManualMeasures.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/DropIdColumnOfManualMeasuresTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/DropPrimaryKeyOnIdColumnOfManualMeasuresTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/MakeManualMeasuresUuidColumnNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/PopulateManualMeasureUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/AddPrimaryKeyOnUuidColumnOfMetricsTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/AddUuidColumnToMetricsTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/DropIdColumnOfMetricsTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/DropPrimaryKeyOnIdColumnOfMetricsTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/MakeMetricsUuidColumnNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/PopulateMetricsUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/AddIndexOnMetricUuidOfLiveMeasuresTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/AddMetricUuidColumnToLiveMeasures.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/DropIndexOnMetricIdOfLiveMeasuresTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/DropMetricIdColumnOfLiveMeasuresTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/MakeLiveMeasuresMetricUuidNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/PopulateLiveMeasuresMetricUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/AddMetricUuidColumnToManualMeasures.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/DropMetricIdColumnOfManualMeasuresTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/MakeManualMeasuresMetricUuidNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/PopulateManualMeasuresMetricUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/AddIndexOnMetricUuidOfProjectMeasuresTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/AddMetricUuidColumnToProjectMeasures.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/DropIndexOnMetricIdOfProjectMeasuresTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/DropMetricIdColumnOfProjectMeasuresTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/MakeProjectMeasuresMetricUuidNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/PopulateProjectMeasuresMetricUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/AddMetricUuidColumnToQualityGateConditions.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/DropMetricIdColumnOfQualityGateConditionsTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/MakeQualityGateConditionsMetricUuidNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/PopulateQualityGateConditionsMetricUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/notifications/AddPrimaryKeyOnUuidColumnOfNotificationTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/notifications/AddUuidAndCreatedAtColumnsToNotification.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/notifications/DropIdColumnOfNotificationTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/notifications/DropPrimaryKeyOnIdColumnOfNotificationTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/notifications/MakeNotificationUuidAndCreatedAtColumnsNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/notifications/PopulateNotificationUuidAndCreatedAt.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/package-info.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/AddUuidColumnToPermissionTemplates.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/DropIdColumnOfPermissionTemplatesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/DropKeeColumnOfPermissionTemplatesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/DropPrimaryKeyOnIdColumnOfPermissionTemplatesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/MakePermissionTemplateUuidColumnNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/PopulatePermissionTemplatesUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/AddTemplateUuidColumnToPermTemplatesGroups.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/DropTemplateIdColumnOfPermTemplatesGroupsTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/MakePermTemplatesGroupsTemplateUuidColumnNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/PopulatePermTemplatesGroupsTemplateUuidColumn.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/AddTemplateUuidColumnToPermTemplatesUsers.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/DropTemplateIdColumnOfPermTemplatesUsersTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/MakePermTemplatesUsersTemplateUuidColumnNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/PopulatePermTemplatesUsersTemplateUuidColumn.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/AddTemplateUuidColumnToPermTplCharacteristics.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/DropTemplateIdColumnOfPermTplCharacteristicsTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/MakePermTplCharacteristicsTemplateUuidColumnNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/PopulatePermTplCharacteristicsTemplateUuidColumn.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/AddUuidColumnToPermTemplatesGroupsTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/DropIdColumnOfPermTemplatesGroupsTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/MakePermTemplatesGroupsUuidColumnNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/PopulatePermTemplatesGroupsUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/AddUuidColumnToPermTemplatesUsersTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/DropIdColumnOfPermTemplatesUsersTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/MakePermTemplatesUsersUuidColumnNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/PopulatePermTemplatesUsersUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/AddUuidColumnToPermTplCharacteristicsTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/DropIdColumnOfPermTplCharacteristicsTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/MakePermTplCharacteristicsUuidColumnNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/PopulatePermTplCharacteristicsUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/AddPrimaryKeyOnUuidColumnOfProjectMeasuresTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/AddUuidColumnToProjectMeasures.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/DropIdColumnOfProjectMeasuresTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/DropPrimaryKeyOnIdColumnOfProjectMeasuresTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/MakeProjectMeasuresUuidColumnNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/PopulateProjectMeasureUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/AddUuidColumnToProjectQProfilesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/DropIdColumnOfProjectQProfilesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/MakeProjectQProfilesUuidColumnNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/PopulateProjectQProfilesUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/properties/AddPrimaryKeyOnUuidColumnOfPropertiesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/properties/AddUuidColumnToProperties.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/properties/DropIdColumnOfPropertiesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/properties/DropPrimaryKeyOnIdColumnOfPropertiesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/properties/MakePropertiesUuidColumnNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/properties/PopulatePropertiesUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/AddUuidColumnToQualityGateConditionsTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/DropIdColumnOfQualityGateConditionsTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/DropPrimaryKeyOnIdColumnOfQualityGateConditionsTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/MakeQualityGateConditionsUuidColumnNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/PopulateQualityGateConditionsUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/AddPrimaryKeyOnUuidColumnOfQGatesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/AddQGateUuidColumnForQGateConditions.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropIdColumnOfQGateTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropOrphansQGateConditions.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropPrimaryKeyOnIdColumnOfQGatesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropQGateIdColumnForQGateConditions.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropUniqueIndexOnUuidColumnOfQualityGatesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/MakeQGateUuidColumnNotNullableForQGateConditions.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/PopulateQGateUuidColumnForQGateConditions.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/AddPrimaryKeyOnUuidColumnOfRulesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/AddUuidAndTemplateUuidColumnsToRules.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/DropIdColumnOfRulesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/DropPrimaryKeyOnIdColumnOfRulesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/DropTemplateIdColumnOfRulesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/MakeRulesUuidColumnNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/PopulateRulesTemplateUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/PopulateRulesUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/AddIndexToActiveRulesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/AddRuleUuidColumnToActiveRulesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/DropIndexOnRuleIdColumnOfActiveRulesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/DropRuleIdColumnOfActiveRulesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/MakeActiveRulesRuleUuidColumnNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/PopulateActiveRulesRuleUuidColumn.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/AddIndexToDeprecatedRuleKeysTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/AddRuleUuidColumnToDeprecatedRuleKeysTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/DropRuleIdColumnOfDeprecatedRuleKeysTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/MakeDeprecatedRuleKeysRuleUuidColumnNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/PopulateDeprecatedRuleKeysRuleUuidColumn.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/issues/AddIndexToIssuesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/issues/AddRuleUuidColumnToIssuesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/issues/DropIndexOnRuleIdColumnOfIssuesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/issues/DropRuleIdColumnOfIssuesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/issues/PopulateIssuesRuleUuidColumn.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/AddRuleUuidColumnToRulesMetadataTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/DropPrimaryKeyOnIdColumnOfRulesMetadataTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/DropRuleIdColumnOfRulesMetadataTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/MakeRulesMetadataRuleUuidColumnNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/PopulateRulesMetadataRuleUuidColumn.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/AddIndexesToRulesParametersTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/AddRuleUuidColumnToRulesParametersTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/DropIndexesOnRuleIdColumnOfRulesParametersTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/DropRuleIdColumnOfRulesParametersTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/MakeRulesParametersRuleUuidColumnNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/PopulateRulesParametersRuleUuidColumn.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/AddPrimaryKeyOnUuidColumnOfRulesParametersTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/AddUuidColumnToRulesParameters.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/DropIdColumnOfRulesParametersTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/DropPrimaryKeyOnIdColumnOfRulesParametersTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/MakeRulesParametersUuidColumnNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/PopulateRulesParametersUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/AddRulesParameterUuidColumnToActiveRuleParameters.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/DropRulesParameterIdColumnOfActiveRuleParametersTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/MakeActiveRuleParametersRulesParameterUuidColumnNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/PopulateActiveRuleParametersRulesParameterUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/AddPrimaryKeyOnUuidColumnOfRulesProfilesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/AddUuidColumnToRulesProfilesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropIdColumnOfRulesProfilesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropKeeColumnOfRulesProfilesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropPrimaryKeyOnIdColumnOfRulesProfilesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropUniqueIndexOnKeeColumnOfRulesProfilesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/MakeRulesProfilesUuidColumnNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/PopulateRulesProfilesUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/AddProfileUuidColumnToActiveRulesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/AddUniqueIndexOnProfileUuidColumnOfActiveRulesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/DropProfileIdColumnOfActiveRulesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/DropUniqueIndexOnProfileIdColumnOfActiveRulesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/MakeActiveRulesProfileUuidColumnNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/PopulateActiveRulesProfileUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/orgqprofiles/PopulateOrgQProfilesRulesProfileUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/qprofilechanges/PopulateQProfileChangesRulesProfileUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/snapshots/issues/AddPrimaryKeyOnUuidColumnOfSnapshotsTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/snapshots/issues/DropIdColumnOfSnapshotsTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/snapshots/issues/DropPrimaryKeyOnIdColumnOfSnapshotsTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/userroles/AddPrimaryKeyOnUuidColumnOfUserRolesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/userroles/AddUuidColumnToUserRolesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/userroles/DropIdColumnOfUserRolesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/userroles/DropPrimaryKeyOnIdColumnOfUserRolesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/userroles/MakeUserRolesUuidColumnNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/userroles/PopulateUserRolesUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/AddPrimaryKeyOnUuidColumnOfUsersTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/DropIdColumnOfUsersTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/DropPrimaryKeyOnIdColumnOfUsersTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/DropUniqueIndexOnUuidColumnOfUsersTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/AddIndexOnUserUuidOfGroupsUsersTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/AddUserUuidColumnToGroupsUsers.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/DropIndexOnUserIdOfGroupsUsersTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/DropUserIdColumnOfGroupsUsersTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/MakeGroupsUsersUserUuidColumnNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/PopulateGroupsUsersUserUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/AddIndexOnUserUuidOfOrganizationMembersTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/AddUserUuidColumnToOrganizationMembers.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/DropIndexOnUserIdOfOrganizationMembersTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/DropUserIdColumnOfOrganizationMembersTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/MakeOrganizationMembersUserUuidColumnNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/PopulateOrganizationMembersUserUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/AddUserUuidColumnToPermTemplatesUsers.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/DropUserIdColumnOfPermTemplatesUsersTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/MakePermTemplatesUsersUserUuidColumnNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/PopulatePermTemplatesUsersUserUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/AddUserUuidColumnToPropertiesUsers.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/DropUserIdColumnOfPropertiesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/PopulatePropertiesUserUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/AddUserUuidColumnToQProfileEditUsers.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/DropUserIdColumnOfQProfileEditUsersTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/MakeQProfileEditUsersUserUuidColumnNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/PopulateQProfileEditUsersUserUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/AddIndexOnUserUuidOfUserRolesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/AddUserUuidColumnToUserRoles.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/DropIndexOnUserIdOfUserRolesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/DropUserIdColumnOfUserRolesTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/PopulateUserRolesUserUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/util/AddUserUuidColumnToTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/util/MakeUserUuidColumnNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/usertokens/AddPrimaryKeyOnUuidColumnOfUserTokensTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/usertokens/AddUuidColumnToUserTokens.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/usertokens/DropIdColumnOfUserTokensTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/usertokens/DropPrimaryKeyOnIdColumnOfUserTokensTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/usertokens/MakeUserTokensUuidNotNullable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/usertokens/PopulateUserTokensUuid.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/util/AddPrimaryKeyBuilder.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/util/DropPrimaryKeySqlGenerator.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/util/SqlHelper.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/DbVersion84.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddUuidColumnToActiveRuleParametersTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropIdColumnOfActiveRuleParametersTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropPrimaryKeyOnIdColumnOfActiveRuleParametersTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/MakeActiveRuleParametersUuidColumnNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/PopulateActiveRuleParametersUuid.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddActiveRuleUuidColumnToActiveRuleParameters.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddIndexOnActiveRuleUuidOfActiveRuleParametersTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddPrimaryKeyOnUuidColumnOfActiveRulesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddUuidColumnToActiveRulesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropActiveRuleIdColumnOfActiveRuleParametersTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropIdColumnOfActiveRulesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropIndexOnActiveRuleIdOfActiveRuleParametersTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropPrimaryKeyOnIdColumnOfActiveRulesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/MakeActiveRuleParametersActiveRuleUuidNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/MakeActiveRulesUuidColumnNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/PopulateActiveRuleParametersActiveRuleUuid.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/PopulateActiveRulesUuid.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropIdColumnOfCeActivityTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/cequeue/AddPrimaryKeyOnUuidColumnOfCeQueueTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropIdColumnOfCeQueueTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropPrimaryKeyOnIdColumnOfCeQueueTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropUniqueIndexOnUuidColumnOfCeQueueTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/common/AddUuidColumnToTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/common/DropIdColumn.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/common/DropPrimaryKeyOnIdColumn.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/common/MakeUuidColumnNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddUuidToDuplicationsIndexTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropIdColumnOfDuplicationsIndexTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropPrimaryKeyOnIdColumnOfDuplicationsIndexTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/MakeDuplicationsIndexUuidColumnNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/PopulateDuplicationsIndexUuid.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/events/AddPrimaryKeyOnUuidColumnOfEventsTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/events/DropIdColumnOfEventsTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/events/DropPrimaryKeyOnIdColumnOfEventsTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/AddPrimaryKeyOnUuidColumnOfFileSourcesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/AddUuidColumnToFileSourcesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/DropIdColumnOfFileSourcesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/DropPrimaryKeyOnIdColumnOfFileSourcesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/MakeFileSourcesUuidColumnNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/PopulateFileSourcesUuid.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/AddPrimaryKeyOnUuidColumnOfGroupRolesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/AddUuidColumnToGroupRolesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/DropIdColumnOfGroupRolesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/DropPrimaryKeyOnIdColumnOfGroupRolesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/MakeGroupRolesUuidColumnNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/PopulateGroupRolesUuid.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/AddPrimaryKeyOnUuidColumnOfGroupsTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/AddUuidColumnToGroupsTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/DropIdColumnOfGroupsTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/DropPrimaryKeyOnIdColumnOfGroupsTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/MakeGroupsUuidColumnNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/PopulateGroupsUuid.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/AddGroupUuidColumnToGroupRoles.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/AddIndexOnGroupUuidOfGroupRolesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/DropGroupIdColumnOfGroupRolesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/DropIndexOnGroupIdOfGroupRolesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/PopulateGroupRolesGroupUuid.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/AddGroupUuidColumnToGroupsUsers.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/AddIndexOnGroupUuidOfGroupsUsersTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/DropGroupIdColumnOfGroupsUsersTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/DropIndexOnGroupIdOfGroupsUsersTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/MakeGroupsUsersGroupUuidNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/PopulateGroupsUsersGroupUuid.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/AddDefaultGroupUuidColumnToOrganizations.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/DropDefaultGroupIdColumnOfOrganizationsTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/PopulateOrganizationsDefaultGroupUuid.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/AddGroupUuidColumnToPermTemplatesGroups.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/DropGroupIdColumnOfPermTemplatesGroupsTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/PopulatePermTemplatesGroupsGroupUuid.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/AddGroupUuidColumnToQProfileEditGroups.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/AddIndexOnGroupUuidOfQProfileEditGroupsTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/DropGroupIdColumnOfQProfileEditGroupsTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/DropIndexOnGroupIdOfQProfileEditGroupsTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/MakeQProfileEditGroupsGroupUuidNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/PopulateQProfileEditGroupsGroupUuid.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddPrimaryKeyOnUuidColumnOfIssueChangesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddUuidColumnToIssueChangesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/DropIdColumnOfIssueChangesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/DropPrimaryKeyOnIdColumnOfIssueChangesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/MakeIssueChangesUuidColumnNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/PopulateIssueChangesUuid.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issues/AddPrimaryKeyOnKeeColumnOfIssuesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issues/DropIdColumnOfIssuesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issues/DropPrimaryKeyOnIdColumnOfIssuesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddPrimaryKeyOnUuidColumnOfManualMeasuresTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddUuidColumnToManualMeasures.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropIdColumnOfManualMeasuresTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropPrimaryKeyOnIdColumnOfManualMeasuresTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/MakeManualMeasuresUuidColumnNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/PopulateManualMeasureUuid.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/AddPrimaryKeyOnUuidColumnOfMetricsTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/AddUuidColumnToMetricsTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/DropIdColumnOfMetricsTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/DropPrimaryKeyOnIdColumnOfMetricsTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/MakeMetricsUuidColumnNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/PopulateMetricsUuid.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddIndexOnMetricUuidOfLiveMeasuresTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddMetricUuidColumnToLiveMeasures.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/DropIndexOnMetricIdOfLiveMeasuresTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/DropMetricIdColumnOfLiveMeasuresTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/MakeLiveMeasuresMetricUuidNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/PopulateLiveMeasuresMetricUuid.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/AddMetricUuidColumnToManualMeasures.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/DropMetricIdColumnOfManualMeasuresTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/MakeManualMeasuresMetricUuidNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/PopulateManualMeasuresMetricUuid.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddIndexOnMetricUuidOfProjectMeasuresTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddMetricUuidColumnToProjectMeasures.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DropIndexOnMetricIdOfProjectMeasuresTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DropMetricIdColumnOfProjectMeasuresTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/MakeProjectMeasuresMetricUuidNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/PopulateProjectMeasuresMetricUuid.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/AddMetricUuidColumnToQualityGateConditions.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/DropMetricIdColumnOfQualityGateConditionsTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/MakeQualityGateConditionsMetricUuidNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/PopulateQualityGateConditionsMetricUuid.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/AddPrimaryKeyOnUuidColumnOfNotificationTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/AddUuidAndCreatedAtColumnsToNotification.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/DropIdColumnOfNotificationTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/DropPrimaryKeyOnIdColumnOfNotificationTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/MakeNotificationUuidAndCreatedAtColumnsNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/PopulateNotificationUuidAndCreatedAt.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/package-info.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddUuidColumnToPermissionTemplates.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropIdColumnOfPermissionTemplatesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropKeeColumnOfPermissionTemplatesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropPrimaryKeyOnIdColumnOfPermissionTemplatesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/MakePermissionTemplateUuidColumnNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/PopulatePermissionTemplatesUuid.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/AddTemplateUuidColumnToPermTemplatesGroups.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/DropTemplateIdColumnOfPermTemplatesGroupsTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/MakePermTemplatesGroupsTemplateUuidColumnNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/PopulatePermTemplatesGroupsTemplateUuidColumn.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/AddTemplateUuidColumnToPermTemplatesUsers.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/DropTemplateIdColumnOfPermTemplatesUsersTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/MakePermTemplatesUsersTemplateUuidColumnNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/PopulatePermTemplatesUsersTemplateUuidColumn.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/AddTemplateUuidColumnToPermTplCharacteristics.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/DropTemplateIdColumnOfPermTplCharacteristicsTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/MakePermTplCharacteristicsTemplateUuidColumnNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/PopulatePermTplCharacteristicsTemplateUuidColumn.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddUuidColumnToPermTemplatesGroupsTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropIdColumnOfPermTemplatesGroupsTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/MakePermTemplatesGroupsUuidColumnNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/PopulatePermTemplatesGroupsUuid.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddUuidColumnToPermTemplatesUsersTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropIdColumnOfPermTemplatesUsersTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/MakePermTemplatesUsersUuidColumnNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/PopulatePermTemplatesUsersUuid.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddUuidColumnToPermTplCharacteristicsTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropIdColumnOfPermTplCharacteristicsTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/MakePermTplCharacteristicsUuidColumnNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/PopulatePermTplCharacteristicsUuid.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddPrimaryKeyOnUuidColumnOfProjectMeasuresTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddUuidColumnToProjectMeasures.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropIdColumnOfProjectMeasuresTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropPrimaryKeyOnIdColumnOfProjectMeasuresTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/MakeProjectMeasuresUuidColumnNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/PopulateProjectMeasureUuid.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddUuidColumnToProjectQProfilesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropIdColumnOfProjectQProfilesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/MakeProjectQProfilesUuidColumnNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/PopulateProjectQProfilesUuid.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/AddPrimaryKeyOnUuidColumnOfPropertiesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/AddUuidColumnToProperties.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/DropIdColumnOfPropertiesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/DropPrimaryKeyOnIdColumnOfPropertiesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/MakePropertiesUuidColumnNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/PopulatePropertiesUuid.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddUuidColumnToQualityGateConditionsTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropIdColumnOfQualityGateConditionsTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropPrimaryKeyOnIdColumnOfQualityGateConditionsTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/MakeQualityGateConditionsUuidColumnNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/PopulateQualityGateConditionsUuid.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddPrimaryKeyOnUuidColumnOfQGatesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddQGateUuidColumnForQGateConditions.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropIdColumnOfQGateTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropOrphansQGateConditions.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropPrimaryKeyOnIdColumnOfQGatesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropQGateIdColumnForQGateConditions.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropUniqueIndexOnUuidColumnOfQualityGatesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/MakeQGateUuidColumnNotNullableForQGateConditions.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/PopulateQGateUuidColumnForQGateConditions.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/AddPrimaryKeyOnUuidColumnOfRulesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/AddUuidAndTemplateUuidColumnsToRules.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/DropIdColumnOfRulesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/DropPrimaryKeyOnIdColumnOfRulesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/DropTemplateIdColumnOfRulesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/MakeRulesUuidColumnNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/PopulateRulesTemplateUuid.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/PopulateRulesUuid.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/AddIndexToActiveRulesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/AddRuleUuidColumnToActiveRulesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/DropIndexOnRuleIdColumnOfActiveRulesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/DropRuleIdColumnOfActiveRulesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/MakeActiveRulesRuleUuidColumnNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/PopulateActiveRulesRuleUuidColumn.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/AddIndexToDeprecatedRuleKeysTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/AddRuleUuidColumnToDeprecatedRuleKeysTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/DropRuleIdColumnOfDeprecatedRuleKeysTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/MakeDeprecatedRuleKeysRuleUuidColumnNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/PopulateDeprecatedRuleKeysRuleUuidColumn.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/AddIndexToIssuesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/AddRuleUuidColumnToIssuesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/DropIndexOnRuleIdColumnOfIssuesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/DropRuleIdColumnOfIssuesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/PopulateIssuesRuleUuidColumn.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddRuleUuidColumnToRulesMetadataTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropPrimaryKeyOnIdColumnOfRulesMetadataTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropRuleIdColumnOfRulesMetadataTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/MakeRulesMetadataRuleUuidColumnNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/PopulateRulesMetadataRuleUuidColumn.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/AddIndexesToRulesParametersTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/AddRuleUuidColumnToRulesParametersTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/DropIndexesOnRuleIdColumnOfRulesParametersTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/DropRuleIdColumnOfRulesParametersTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/MakeRulesParametersRuleUuidColumnNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/PopulateRulesParametersRuleUuidColumn.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddPrimaryKeyOnUuidColumnOfRulesParametersTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddUuidColumnToRulesParameters.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropIdColumnOfRulesParametersTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropPrimaryKeyOnIdColumnOfRulesParametersTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/MakeRulesParametersUuidColumnNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/PopulateRulesParametersUuid.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/AddRulesParameterUuidColumnToActiveRuleParameters.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/DropRulesParameterIdColumnOfActiveRuleParametersTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/MakeActiveRuleParametersRulesParameterUuidColumnNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/PopulateActiveRuleParametersRulesParameterUuid.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddPrimaryKeyOnUuidColumnOfRulesProfilesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddUuidColumnToRulesProfilesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropIdColumnOfRulesProfilesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropKeeColumnOfRulesProfilesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropPrimaryKeyOnIdColumnOfRulesProfilesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropUniqueIndexOnKeeColumnOfRulesProfilesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/MakeRulesProfilesUuidColumnNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/PopulateRulesProfilesUuid.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/AddProfileUuidColumnToActiveRulesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/AddUniqueIndexOnProfileUuidColumnOfActiveRulesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/DropProfileIdColumnOfActiveRulesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/DropUniqueIndexOnProfileIdColumnOfActiveRulesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/MakeActiveRulesProfileUuidColumnNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/PopulateActiveRulesProfileUuid.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/orgqprofiles/PopulateOrgQProfilesRulesProfileUuid.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/qprofilechanges/PopulateQProfileChangesRulesProfileUuid.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/snapshots/issues/AddPrimaryKeyOnUuidColumnOfSnapshotsTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/snapshots/issues/DropIdColumnOfSnapshotsTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/snapshots/issues/DropPrimaryKeyOnIdColumnOfSnapshotsTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/AddPrimaryKeyOnUuidColumnOfUserRolesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/AddUuidColumnToUserRolesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/DropIdColumnOfUserRolesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/DropPrimaryKeyOnIdColumnOfUserRolesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/MakeUserRolesUuidColumnNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/PopulateUserRolesUuid.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/AddPrimaryKeyOnUuidColumnOfUsersTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/DropIdColumnOfUsersTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/DropPrimaryKeyOnIdColumnOfUsersTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/DropUniqueIndexOnUuidColumnOfUsersTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddIndexOnUserUuidOfGroupsUsersTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddUserUuidColumnToGroupsUsers.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropIndexOnUserIdOfGroupsUsersTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropUserIdColumnOfGroupsUsersTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/MakeGroupsUsersUserUuidColumnNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/PopulateGroupsUsersUserUuid.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddIndexOnUserUuidOfOrganizationMembersTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddUserUuidColumnToOrganizationMembers.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropIndexOnUserIdOfOrganizationMembersTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropUserIdColumnOfOrganizationMembersTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/MakeOrganizationMembersUserUuidColumnNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/PopulateOrganizationMembersUserUuid.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/AddUserUuidColumnToPermTemplatesUsers.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/DropUserIdColumnOfPermTemplatesUsersTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/MakePermTemplatesUsersUserUuidColumnNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/PopulatePermTemplatesUsersUserUuid.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/AddUserUuidColumnToPropertiesUsers.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/DropUserIdColumnOfPropertiesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/PopulatePropertiesUserUuid.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/AddUserUuidColumnToQProfileEditUsers.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/DropUserIdColumnOfQProfileEditUsersTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/MakeQProfileEditUsersUserUuidColumnNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/PopulateQProfileEditUsersUserUuid.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/AddIndexOnUserUuidOfUserRolesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/AddUserUuidColumnToUserRoles.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/DropIndexOnUserIdOfUserRolesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/DropUserIdColumnOfUserRolesTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/PopulateUserRolesUserUuid.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/util/AddUserUuidColumnToTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/util/MakeUserUuidColumnNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/AddPrimaryKeyOnUuidColumnOfUserTokensTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/AddUuidColumnToUserTokens.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/DropIdColumnOfUserTokensTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/DropPrimaryKeyOnIdColumnOfUserTokensTable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/MakeUserTokensUuidNotNullable.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/PopulateUserTokensUuid.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/util/AddPrimaryKeyBuilder.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/util/DropPrimaryKeySqlGenerator.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/util/SqlHelper.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/AddUuidColumnToActiveRuleParametersTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/DropIdColumnOfActiveRuleParametersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/DropPrimaryKeyOnIdColumnOfActiveRuleParametersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/MakeActiveRuleParametersUuidColumnNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/PopulateActiveRuleParametersUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/AddActiveRuleUuidColumnToActiveRuleParametersTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/AddIndexOnActiveRuleUuidOfActiveRuleParametersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/AddPrimaryKeyOnUuidColumnOfActiveRulesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/AddUuidColumnToActiveRulesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/DropActiveRuleIdColumnOfActiveRuleParametersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/DropIdColumnOfActiveRulesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/DropIndexOnActiveRuleIdOfActiveRuleParametersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/DropPrimaryKeyOnIdColumnOfActiveRulesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/MakeActiveRuleParametersActiveRuleUuidNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/MakeActiveRulesUuidColumnNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/PopulateActiveRuleParametersActiveRuleUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/PopulateActiveRulesUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/ceactivity/DropIdColumnOfCeActivityTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/cequeue/AddPrimaryKeyOnUuidColumnOfCeQueueTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/cequeue/DropIdColumnOfCeQueueTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/cequeue/DropPrimaryKeyOnIdColumnOfCeQueueTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/cequeue/DropUniqueIndexOnUuidColumnOfCeQueueTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/AddUuidToDuplicationsIndexTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/DropIdColumnOfDuplicationsIndexTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/DropPrimaryKeyOnIdColumnOfDuplicationsIndexTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/MakeDuplicationsIndexUuidColumnNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/PopulateDuplicationsIndexUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/events/AddPrimaryKeyOnUuidColumnOfEventsTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/events/DropIdColumnOfEventsTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/events/DropPrimaryKeyOnIdColumnOfEventsTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/filesources/AddPrimaryKeyOnUuidColumnOfFileSourcesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/filesources/AddUuidColumnToFileSourcesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/filesources/DropIdColumnOfFileSourcesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/filesources/DropPrimaryKeyOnIdColumnOfFileSourcesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/filesources/MakeFileSourcesUuidColumnNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/filesources/PopulateFileSourcesUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/grouproles/AddPrimaryKeyOnUuidColumnOfGroupRolesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/grouproles/AddUuidColumnToGroupRolesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/grouproles/DropIdColumnOfGroupRolesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/grouproles/DropPrimaryKeyOnIdColumnOfGroupRolesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/grouproles/MakeGroupRolesUuidColumnNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/grouproles/PopulateGroupRolesUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/AddPrimaryKeyOnUuidColumnOfGroupsTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/AddUuidColumnToGroupsTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/DropIdColumnOfGroupsTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/DropPrimaryKeyOnIdColumnOfGroupsTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/MakeGroupsUuidColumnNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/PopulateGroupsUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/AddGroupUuidColumnToGroupRolesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/AddIndexOnGroupUuidOfGroupRolesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/DropGroupIdColumnOfGroupRolesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/DropIndexOnGroupIdOfGroupRolesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/PopulateGroupRolesGroupUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/AddGroupUuidColumnToGroupsUsersTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/AddIndexOnGroupUuidOfGroupsUsersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/DropGroupIdColumnOfGroupsUsersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/DropIndexOnGroupIdOfGroupsUsersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/MakeGroupsUsersGroupUuidNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/PopulateGroupsUsersGroupUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/organizations/AddDefaultGroupUuidColumnToOrganizationsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/organizations/DropDefaultGroupIdColumnOfOrganizationsTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/organizations/PopulateOrganizationsDefaultGroupUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/permtemplatesgroups/AddGroupUuidColumnToPermTemplatesGroupsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/permtemplatesgroups/DropGroupIdColumnOfPermTemplatesGroupsTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/permtemplatesgroups/PopulatePermTemplatesGroupsGroupUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/AddGroupUuidColumnToQProfileEditGroupsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/AddIndexOnGroupUuidOfQProfileEditGroupsTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/DropGroupIdColumnOfQProfileEditGroupsTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/DropIndexOnGroupIdOfQProfileEditGroupsTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/MakeQProfileEditGroupsGroupUuidNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/PopulateQProfileEditGroupsGroupUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/AddPrimaryKeyOnUuidColumnOfIssueChangesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/AddUuidColumnToIssueChangesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/DropIdColumnOfIssueChangesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/DropPrimaryKeyOnIdColumnOfIssueChangesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/MakeIssueChangesUuidColumnNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/PopulateIssueChangesUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issues/AddPrimaryKeyOnKeeColumnOfIssuesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issues/DropIdColumnOfIssuesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issues/DropPrimaryKeyOnIdColumnOfIssuesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/AddPrimaryKeyOnUuidColumnOfManualMeasureTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/AddUuidToManualMeasuresTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/DropIdColumnOfManualMeasuresTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/DropPrimaryKeyOnIdColumnOfManualMeasuresTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/MakeManualMeasuresUuidColumnNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/PopulateManualMeasuresUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/AddPrimaryKeyOnUuidColumnOfMetricsTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/AddUuidColumnToMetricsTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/DropIdColumnOfMetricsTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/DropPrimaryKeyOnIdColumnOfMetricsTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/MakeMetricsUuidColumnNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/PopulateMetricsUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/AddIndexOnMetricUuidOfLiveMeasuresTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/AddMetricUuidColumnToLiveMeasuresTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/DropIndexOnMetricIdOfLiveMeasuresTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/DropMetricIdColumnOfLiveMeasuresTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/MakeLiveMeasuresMetricUuidNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/PopulateLiveMeasuresMetricUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/AddMetricUuidColumnToManualMeasuresTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/DropMetricIdColumnOfManualMeasuresTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/MakeManualMeasuresMetricUuidNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/PopulateManualMeasuresMetricUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/AddIndexOnMetricUuidOfProjectMeasuresTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/AddMetricUuidColumnToProjectMeasuresTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/DropIndexOnMetricIdOfProjectMeasuresTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/DropMetricIdColumnOfProjectMeasuresTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/MakeProjectMeasuresMetricUuidNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/PopulateProjectMeasuresMetricUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/AddMetricUuidColumnToQualityGateConditionsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/DropMetricIdColumnOfQualityGateConditionsTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/MakeQualityGateConditionsMetricUuidNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/PopulateQualityGateConditionsMetricUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/notifications/AddPrimaryKeyOnUuidColumnOfNotificationTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/notifications/AddUuidAndCreatedAtColumnsToNotificationTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/notifications/DropIdColumnOfNotificationTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/notifications/DropPrimaryKeyOnIdColumnOfNotificationTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/notifications/MakeNotificationUuidAndCreatedAtColumnsNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/notifications/PopulateNotificationUuidAndCreatedAtTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/AddUuidColumnToPermissionTemplatesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/DropIdColumnOfPermissionTemplatesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/DropKeeColumnOfPermissionTemplatesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/DropPrimaryKeyOnIdColumnOfPermissionTemplatesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/MakePermissionTemplateUuidColumnNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/PopulatePermissionTemplatesUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/AddTemplateUuidColumnToPermTemplatesGroupsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/DropTemplateIdColumnOfPermTemplatesGroupsTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/MakePermTemplatesGroupsTemplateUuidColumnNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/PopulatePermTemplatesGroupsTemplateUuidColumnTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/AddTemplateUuidColumnToPermTemplatesUsersTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/DropTemplateIdColumnOfPermTemplatesUsersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/MakePermTemplatesUsersTemplateUuidColumnNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/PopulatePermTemplatesUsersTemplateUuidColumnTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/AddTemplateUuidColumnToPermTplCharacteristicsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/DropTemplateIdColumnOfPermTplCharacteristicsTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/MakePermTplCharacteristicsTemplateUuidColumnNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/PopulatePermTplCharacteristicsTemplateUuidColumnTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/AddUuidColumnToPermTemplatesGroupsTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/DropIdColumnOfPermTemplatesGroupsTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/MakePermTemplatesGroupsUuidColumnNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/PopulatePermTemplatesGroupsUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/AddUuidColumnToPermTemplatesUsersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/DropIdColumnOfPermTemplatesUsersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/MakePermTemplatesUsersUuidColumnNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/PopulatePermTemplatesUsersUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/AddUuidColumnToPermTplCharacteristicsTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/DropIdColumnOfPermTplCharacteristicsTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/MakePermTplCharacteristicsUuidColumnNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/PopulatePermTplCharacteristicsUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/AddPrimaryKeyOnUuidColumnOfProjectMeasureTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/AddUuidToProjectMeasuresTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/DropIdColumnOfProjectMeasuresTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/DropPrimaryKeyOnIdColumnOfProjectMeasuresTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/MakeProjectMeasuresUuidColumnNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/PopulateProjectMeasuresUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/AddUuidColumnToProjectQProfilesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/DropIdColumnOfProjectQProfilesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/MakeProjectQProfilesUuidColumnNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/PopulateProjectQProfilesUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/properties/AddPrimaryKeyOnUuidColumnOfPropertiesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/properties/AddUuidColumnToPropertiesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/properties/DropIdColumnOfPropertiesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/properties/DropPrimaryKeyOnIdColumnOfPropertiesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/properties/MakeNotificationUuidColumnNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/properties/PopulatePropertiesUuidAndCreatedAtTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/AddUuidColumnToQualityGateConditionsTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/DropIdColumnOfQualityGateConditionsTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/DropPrimaryKeyOnIdColumnOfQualityGateConditionsTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/MakeQualityGateConditionsUuidColumnNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/PopulateQualityGateConditionsUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/AddPrimaryKeyOnUuidColumnOfQGatesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/AddQGateUuidColumnForQGateConditionsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropIdColumnOfQGateTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropOrphansQGateConditionsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropPrimaryKeyOnIdColumnOfQGatesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropQGateIdColumnForQGateConditionsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropUniqueIndexOnUuidColumnOfQualityGatesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/MakeQGateUuidColumnNotNullableForQGateConditionsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/PopulateQGateUuidColumnForQGateConditionsTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/AddPrimaryKeyOnUuidColumnOfRulesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/AddUuidAndTemplateUuidColumnsToRulesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/DropIdColumnOfRulesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/DropPrimaryKeyOnIdColumnOfRulesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/DropTemplateIdColumnOfRulesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/MakeRulesUuidColumnNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/PopulateRulesTemplateUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/PopulateRulesUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/AddIndexToActiveRulesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/AddRuleUuidColumnToActiveRulesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/DropIndexOnRuleIdColumnOfActiveRulesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/DropRuleIdColumnOfActiveRulesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/MakeActiveRulesRuleUuidColumnNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/PopulateActiveRulesRuleUuidColumnTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/AddIndexToDeprecatedRuleKeysTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/AddRuleUuidColumnToDeprecatedRuleKeysTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/DropRuleIdColumnOfDeprecatedRuleKeysTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/MakeDeprecatedRuleKeysRuleUuidColumnNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/PopulateDeprecatedRuleKeysRuleUuidColumnTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/issues/AddIndexToIssuesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/issues/AddRuleUuidColumnToIssuesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/issues/DropIndexOnRuleIdColumnOfIssuesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/issues/DropRuleIdColumnOfIssuesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/issues/PopulateIssuesRuleUuidColumnTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/AddRuleUuidColumnToRulesMetadataTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/DropPrimaryKeyOnIdColumnOfRulesMetadataTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/DropRuleIdColumnOfRulesMetadataTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/MakeRulesMetadataRuleUuidColumnNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/PopulateRulesMetadataRuleUuidColumnTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/AddIndexesToRulesParametersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/AddRuleUuidColumnToRulesParametersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/DropIndexesOnRuleIdColumnOfRulesParametersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/DropRuleIdColumnOfRulesParametersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/MakeRulesParametersRuleUuidColumnNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/PopulateRulesParametersRuleUuidColumnTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/AddPrimaryKeyOnUuidColumnOfRulesParametersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/AddUuidColumnToRulesParametersTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/DropIdColumnOfRulesParametersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/DropPrimaryKeyOnIdColumnOfRulesParametersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/MakeRulesParametersUuidColumnNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/PopulateRulesParametersUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/AddRulesParameterUuidColumnToActiveRuleParametersTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/DropRulesParameterIdColumnOfActiveRuleParametersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/MakeActiveRuleParametersRulesParameterUuidColumnNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/PopulateActiveRuleParametersRulesParameterUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/AddPrimaryKeyOnUuidColumnOfRulesProfilesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/AddUuidColumnToRulesProfilesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropIdColumnOfRulesProfilesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropKeeColumnOfRulesProfilesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropPrimaryKeyOnIdColumnOfRulesProfilesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropUniqueIndexOnKeeColumnOfRulesProfilesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/MakeRulesProfilesUuidColumnNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/PopulateRulesProfilesUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/AddProfileUuidColumnToActiveRulesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/AddUniqueIndexOnProfileUuidColumnOfActiveRulesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/DropProfileIdColumnOfActiveRulesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/DropUniqueIndexOnProfileIdColumnOfActiveRulesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/MakeActiveRulesProfileUuidColumnNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/PopulateActiveRulesProfileUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/orgqprofiles/PopulateOrgQProfilesRulesProfileUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/qprofilechanges/PopulateQProfileChangesRulesProfileUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/snapshots/AddPrimaryKeyOnUuidColumnOfSnapshotsTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/snapshots/DropIdColumnOfSnapshotsTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/snapshots/DropPrimaryKeyOnIdColumnOfSnapshotsTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/AddPrimaryKeyOnUuidColumnOfUsersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/DropIdColumnOfUsersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/DropPrimaryKeyOnIdColumnOfUsersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/DropUniqueIndexOnUuidColumnOfUsersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/AddIndexOnUserUuidOfGroupsUsersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/AddUserUuidColumnToGroupsUsersTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/DropIndexOnUserIdOfGroupsUsersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/DropUserIdColumnOfGroupsUsersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/MakeGroupsUsersUserUuidColumnNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/PopulateGroupsUsersUserUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/AddIndexOnUserUuidOfOrganizationMembersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/AddUserUuidColumnToOrganizationMembersTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/DropIndexOnUserIdOfOrganizationMembersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/DropUserIdColumnOfOrganizationMembersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/MakeOrganizationMembersUserUuidColumnNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/PopulateOrganizationMembersUserUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/AddUserUuidColumnToPermTemplatesUsersTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/DropUserIdColumnOfPermTemplatesUsersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/MakePermTemplatesUsersUserUuidColumnNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/PopulatePermTemplatesUsersUserUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/AddUserUuidColumnToPropertiesUsersTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/DropUserIdColumnOfPropertiesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/PopulatePropertiesUserUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/AddUserUuidColumnToQProfileEditUsersTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/DropUserIdColumnOfQProfileEditUsersTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/MakeQProfileEditUsersUserUuidColumnNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/PopulateQProfileEditUsersUserUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/AddIndexOnUserUuidOfUserRolesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/AddUserUuidColumnToUserRolesTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/DropIndexOnUserIdOfUserRolesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/DropUserIdColumnOfUserRolesTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/PopulateUserRolesUserUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/usertokens/AddPrimaryKeyOnUuidColumnOfUserTokensTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/usertokens/AddUuidColumnToUserTokensTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/usertokens/DropIdColumnOfUserTokensTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/usertokens/DropPrimaryKeyOnIdColumnOfUserTokensTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/usertokens/MakeUserTokensUuidNotNullableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/usertokens/PopulateUserTokensUuidTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/util/AddPrimaryKeyBuilderTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/util/DropPrimaryKeySqlGeneratorTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/DbVersion84Test.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddUuidColumnToActiveRuleParametersTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropIdColumnOfActiveRuleParametersTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropPrimaryKeyOnIdColumnOfActiveRuleParametersTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/MakeActiveRuleParametersUuidColumnNotNullableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/PopulateActiveRuleParametersUuidTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddActiveRuleUuidColumnToActiveRuleParametersTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddIndexOnActiveRuleUuidOfActiveRuleParametersTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddPrimaryKeyOnUuidColumnOfActiveRulesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddUuidColumnToActiveRulesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropActiveRuleIdColumnOfActiveRuleParametersTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropIdColumnOfActiveRulesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropIndexOnActiveRuleIdOfActiveRuleParametersTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropPrimaryKeyOnIdColumnOfActiveRulesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/MakeActiveRuleParametersActiveRuleUuidNotNullableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/MakeActiveRulesUuidColumnNotNullableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/PopulateActiveRuleParametersActiveRuleUuidTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/PopulateActiveRulesUuidTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropIdColumnOfCeActivityTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/cequeue/AddPrimaryKeyOnUuidColumnOfCeQueueTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropIdColumnOfCeQueueTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropPrimaryKeyOnIdColumnOfCeQueueTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropUniqueIndexOnUuidColumnOfCeQueueTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddUuidToDuplicationsIndexTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropIdColumnOfDuplicationsIndexTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropPrimaryKeyOnIdColumnOfDuplicationsIndexTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/MakeDuplicationsIndexUuidColumnNotNullableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/PopulateDuplicationsIndexUuidTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/events/AddPrimaryKeyOnUuidColumnOfEventsTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/events/DropIdColumnOfEventsTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/events/DropPrimaryKeyOnIdColumnOfEventsTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/AddPrimaryKeyOnUuidColumnOfFileSourcesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/AddUuidColumnToFileSourcesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/DropIdColumnOfFileSourcesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/DropPrimaryKeyOnIdColumnOfFileSourcesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/MakeFileSourcesUuidColumnNotNullableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/PopulateFileSourcesUuidTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/AddPrimaryKeyOnUuidColumnOfGroupRolesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/AddUuidColumnToGroupRolesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/DropIdColumnOfGroupRolesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/DropPrimaryKeyOnIdColumnOfGroupRolesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/MakeGroupRolesUuidColumnNotNullableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/PopulateGroupRolesUuidTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/AddPrimaryKeyOnUuidColumnOfGroupsTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/AddUuidColumnToGroupsTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/DropIdColumnOfGroupsTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/DropPrimaryKeyOnIdColumnOfGroupsTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/MakeGroupsUuidColumnNotNullableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/PopulateGroupsUuidTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/AddGroupUuidColumnToGroupRolesTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/AddIndexOnGroupUuidOfGroupRolesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/DropGroupIdColumnOfGroupRolesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/DropIndexOnGroupIdOfGroupRolesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/PopulateGroupRolesGroupUuidTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/AddGroupUuidColumnToGroupsUsersTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/AddIndexOnGroupUuidOfGroupsUsersTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/DropGroupIdColumnOfGroupsUsersTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/DropIndexOnGroupIdOfGroupsUsersTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/MakeGroupsUsersGroupUuidNotNullableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/PopulateGroupsUsersGroupUuidTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/AddDefaultGroupUuidColumnToOrganizationsTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/DropDefaultGroupIdColumnOfOrganizationsTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/PopulateOrganizationsDefaultGroupUuidTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/AddGroupUuidColumnToPermTemplatesGroupsTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/DropGroupIdColumnOfPermTemplatesGroupsTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/PopulatePermTemplatesGroupsGroupUuidTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/AddGroupUuidColumnToQProfileEditGroupsTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/AddIndexOnGroupUuidOfQProfileEditGroupsTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/DropGroupIdColumnOfQProfileEditGroupsTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/DropIndexOnGroupIdOfQProfileEditGroupsTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/MakeQProfileEditGroupsGroupUuidNotNullableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/PopulateQProfileEditGroupsGroupUuidTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddPrimaryKeyOnUuidColumnOfIssueChangesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddUuidColumnToIssueChangesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/DropIdColumnOfIssueChangesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/DropPrimaryKeyOnIdColumnOfIssueChangesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/MakeIssueChangesUuidColumnNotNullableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/PopulateIssueChangesUuidTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issues/AddPrimaryKeyOnKeeColumnOfIssuesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issues/DropIdColumnOfIssuesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issues/DropPrimaryKeyOnIdColumnOfIssuesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddPrimaryKeyOnUuidColumnOfManualMeasureTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddUuidToManualMeasuresTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropIdColumnOfManualMeasuresTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropPrimaryKeyOnIdColumnOfManualMeasuresTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/MakeManualMeasuresUuidColumnNotNullableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/PopulateManualMeasuresUuidTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/AddPrimaryKeyOnUuidColumnOfMetricsTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/AddUuidColumnToMetricsTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/DropIdColumnOfMetricsTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/DropPrimaryKeyOnIdColumnOfMetricsTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/MakeMetricsUuidColumnNotNullableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/PopulateMetricsUuidTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddIndexOnMetricUuidOfLiveMeasuresTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddMetricUuidColumnToLiveMeasuresTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/DropIndexOnMetricIdOfLiveMeasuresTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/DropMetricIdColumnOfLiveMeasuresTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/MakeLiveMeasuresMetricUuidNotNullableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/PopulateLiveMeasuresMetricUuidTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/AddMetricUuidColumnToManualMeasuresTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/DropMetricIdColumnOfManualMeasuresTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/MakeManualMeasuresMetricUuidNotNullableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/PopulateManualMeasuresMetricUuidTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddIndexOnMetricUuidOfProjectMeasuresTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddMetricUuidColumnToProjectMeasuresTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DropIndexOnMetricIdOfProjectMeasuresTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DropMetricIdColumnOfProjectMeasuresTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/MakeProjectMeasuresMetricUuidNotNullableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/PopulateProjectMeasuresMetricUuidTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/AddMetricUuidColumnToQualityGateConditionsTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/DropMetricIdColumnOfQualityGateConditionsTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/MakeQualityGateConditionsMetricUuidNotNullableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/PopulateQualityGateConditionsMetricUuidTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/AddPrimaryKeyOnUuidColumnOfNotificationTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/AddUuidAndCreatedAtColumnsToNotificationTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/DropIdColumnOfNotificationTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/DropPrimaryKeyOnIdColumnOfNotificationTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/MakeNotificationUuidAndCreatedAtColumnsNotNullableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/PopulateNotificationUuidAndCreatedAtTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddUuidColumnToPermissionTemplatesTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropIdColumnOfPermissionTemplatesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropKeeColumnOfPermissionTemplatesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropPrimaryKeyOnIdColumnOfPermissionTemplatesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/MakePermissionTemplateUuidColumnNotNullableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/PopulatePermissionTemplatesUuidTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/AddTemplateUuidColumnToPermTemplatesGroupsTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/DropTemplateIdColumnOfPermTemplatesGroupsTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/MakePermTemplatesGroupsTemplateUuidColumnNotNullableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/PopulatePermTemplatesGroupsTemplateUuidColumnTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/AddTemplateUuidColumnToPermTemplatesUsersTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/DropTemplateIdColumnOfPermTemplatesUsersTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/MakePermTemplatesUsersTemplateUuidColumnNotNullableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/PopulatePermTemplatesUsersTemplateUuidColumnTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/AddTemplateUuidColumnToPermTplCharacteristicsTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/DropTemplateIdColumnOfPermTplCharacteristicsTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/MakePermTplCharacteristicsTemplateUuidColumnNotNullableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/PopulatePermTplCharacteristicsTemplateUuidColumnTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddUuidColumnToPermTemplatesGroupsTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropIdColumnOfPermTemplatesGroupsTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/MakePermTemplatesGroupsUuidColumnNotNullableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/PopulatePermTemplatesGroupsUuidTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddUuidColumnToPermTemplatesUsersTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropIdColumnOfPermTemplatesUsersTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/MakePermTemplatesUsersUuidColumnNotNullableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/PopulatePermTemplatesUsersUuidTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddUuidColumnToPermTplCharacteristicsTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropIdColumnOfPermTplCharacteristicsTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/MakePermTplCharacteristicsUuidColumnNotNullableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/PopulatePermTplCharacteristicsUuidTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddPrimaryKeyOnUuidColumnOfProjectMeasureTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddUuidToProjectMeasuresTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropIdColumnOfProjectMeasuresTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropPrimaryKeyOnIdColumnOfProjectMeasuresTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/MakeProjectMeasuresUuidColumnNotNullableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/PopulateProjectMeasuresUuidTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddUuidColumnToProjectQProfilesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropIdColumnOfProjectQProfilesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/MakeProjectQProfilesUuidColumnNotNullableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/PopulateProjectQProfilesUuidTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/AddPrimaryKeyOnUuidColumnOfPropertiesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/AddUuidColumnToPropertiesTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/DropIdColumnOfPropertiesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/DropPrimaryKeyOnIdColumnOfPropertiesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/MakeNotificationUuidColumnNotNullableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/PopulatePropertiesUuidAndCreatedAtTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddUuidColumnToQualityGateConditionsTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropIdColumnOfQualityGateConditionsTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropPrimaryKeyOnIdColumnOfQualityGateConditionsTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/MakeQualityGateConditionsUuidColumnNotNullableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/PopulateQualityGateConditionsUuidTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddPrimaryKeyOnUuidColumnOfQGatesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddQGateUuidColumnForQGateConditionsTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropIdColumnOfQGateTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropOrphansQGateConditionsTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropPrimaryKeyOnIdColumnOfQGatesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropQGateIdColumnForQGateConditionsTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropUniqueIndexOnUuidColumnOfQualityGatesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/MakeQGateUuidColumnNotNullableForQGateConditionsTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/PopulateQGateUuidColumnForQGateConditionsTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/AddPrimaryKeyOnUuidColumnOfRulesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/AddUuidAndTemplateUuidColumnsToRulesTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/DropIdColumnOfRulesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/DropPrimaryKeyOnIdColumnOfRulesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/DropTemplateIdColumnOfRulesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/MakeRulesUuidColumnNotNullableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/PopulateRulesTemplateUuidTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/PopulateRulesUuidTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/AddIndexToActiveRulesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/AddRuleUuidColumnToActiveRulesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/DropIndexOnRuleIdColumnOfActiveRulesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/DropRuleIdColumnOfActiveRulesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/MakeActiveRulesRuleUuidColumnNotNullableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/PopulateActiveRulesRuleUuidColumnTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/AddIndexToDeprecatedRuleKeysTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/AddRuleUuidColumnToDeprecatedRuleKeysTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/DropRuleIdColumnOfDeprecatedRuleKeysTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/MakeDeprecatedRuleKeysRuleUuidColumnNotNullableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/PopulateDeprecatedRuleKeysRuleUuidColumnTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/AddIndexToIssuesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/AddRuleUuidColumnToIssuesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/DropIndexOnRuleIdColumnOfIssuesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/DropRuleIdColumnOfIssuesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/PopulateIssuesRuleUuidColumnTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddRuleUuidColumnToRulesMetadataTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropPrimaryKeyOnIdColumnOfRulesMetadataTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropRuleIdColumnOfRulesMetadataTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/MakeRulesMetadataRuleUuidColumnNotNullableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/PopulateRulesMetadataRuleUuidColumnTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/AddIndexesToRulesParametersTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/AddRuleUuidColumnToRulesParametersTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/DropIndexesOnRuleIdColumnOfRulesParametersTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/DropRuleIdColumnOfRulesParametersTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/MakeRulesParametersRuleUuidColumnNotNullableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/PopulateRulesParametersRuleUuidColumnTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddPrimaryKeyOnUuidColumnOfRulesParametersTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddUuidColumnToRulesParametersTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropIdColumnOfRulesParametersTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropPrimaryKeyOnIdColumnOfRulesParametersTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/MakeRulesParametersUuidColumnNotNullableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/PopulateRulesParametersUuidTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/AddRulesParameterUuidColumnToActiveRuleParametersTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/DropRulesParameterIdColumnOfActiveRuleParametersTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/MakeActiveRuleParametersRulesParameterUuidColumnNotNullableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/PopulateActiveRuleParametersRulesParameterUuidTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddPrimaryKeyOnUuidColumnOfRulesProfilesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddUuidColumnToRulesProfilesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropIdColumnOfRulesProfilesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropKeeColumnOfRulesProfilesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropPrimaryKeyOnIdColumnOfRulesProfilesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropUniqueIndexOnKeeColumnOfRulesProfilesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/MakeRulesProfilesUuidColumnNotNullableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/PopulateRulesProfilesUuidTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/AddProfileUuidColumnToActiveRulesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/AddUniqueIndexOnProfileUuidColumnOfActiveRulesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/DropProfileIdColumnOfActiveRulesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/DropUniqueIndexOnProfileIdColumnOfActiveRulesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/MakeActiveRulesProfileUuidColumnNotNullableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/PopulateActiveRulesProfileUuidTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/orgqprofiles/PopulateOrgQProfilesRulesProfileUuidTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/qprofilechanges/PopulateQProfileChangesRulesProfileUuidTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/snapshots/AddPrimaryKeyOnUuidColumnOfSnapshotsTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/snapshots/DropIdColumnOfSnapshotsTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/snapshots/DropPrimaryKeyOnIdColumnOfSnapshotsTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/AddPrimaryKeyOnUuidColumnOfUsersTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/DropIdColumnOfUsersTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/DropPrimaryKeyOnIdColumnOfUsersTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/DropUniqueIndexOnUuidColumnOfUsersTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddIndexOnUserUuidOfGroupsUsersTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddUserUuidColumnToGroupsUsersTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropIndexOnUserIdOfGroupsUsersTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropUserIdColumnOfGroupsUsersTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/MakeGroupsUsersUserUuidColumnNotNullableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/PopulateGroupsUsersUserUuidTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddIndexOnUserUuidOfOrganizationMembersTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddUserUuidColumnToOrganizationMembersTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropIndexOnUserIdOfOrganizationMembersTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropUserIdColumnOfOrganizationMembersTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/MakeOrganizationMembersUserUuidColumnNotNullableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/PopulateOrganizationMembersUserUuidTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/AddUserUuidColumnToPermTemplatesUsersTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/DropUserIdColumnOfPermTemplatesUsersTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/MakePermTemplatesUsersUserUuidColumnNotNullableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/PopulatePermTemplatesUsersUserUuidTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/AddUserUuidColumnToPropertiesUsersTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/DropUserIdColumnOfPropertiesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/PopulatePropertiesUserUuidTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/AddUserUuidColumnToQProfileEditUsersTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/DropUserIdColumnOfQProfileEditUsersTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/MakeQProfileEditUsersUserUuidColumnNotNullableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/PopulateQProfileEditUsersUserUuidTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/AddIndexOnUserUuidOfUserRolesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/AddUserUuidColumnToUserRolesTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/DropIndexOnUserIdOfUserRolesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/DropUserIdColumnOfUserRolesTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/PopulateUserRolesUserUuidTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/AddPrimaryKeyOnUuidColumnOfUserTokensTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/AddUuidColumnToUserTokensTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/DropIdColumnOfUserTokensTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/DropPrimaryKeyOnIdColumnOfUserTokensTableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/MakeUserTokensUuidNotNullableTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/PopulateUserTokensUuidTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/util/AddPrimaryKeyBuilderTest.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/util/DropPrimaryKeySqlGeneratorTest.java delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/AddUuidColumnToActiveRuleParametersTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/DropIdColumnOfActiveRuleParametersTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/DropPrimaryKeyOnIdColumnOfActiveRuleParametersTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/MakeActiveRuleParametersUuidColumnNotNullableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/PopulateActiveRuleParametersUuidTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/AddActiveRuleUuidColumnToActiveRuleParametersTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/AddIndexOnActiveRuleUuidOfActiveRuleParametersTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/AddPrimaryKeyOnUuidColumnOfActiveRulesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/AddUuidColumnToActiveRulesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/DropActiveRuleIdColumnOfActiveRuleParametersTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/DropIdColumnOfActiveRulesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/DropIndexOnActiveRuleIdOfActiveRuleParametersTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/DropPrimaryKeyOnIdColumnOfActiveRulesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/MakeActiveRuleParametersActiveRuleUuidNotNullableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/MakeActiveRulesUuidColumnNotNullableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/PopulateActiveRuleParametersActiveRuleUuidTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/PopulateActiveRulesUuidTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/ceactivity/DropIdColumnOfCeActivityTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/cequeue/AddPrimaryKeyOnUuidColumnOfCeQueueTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/cequeue/DropIdColumnOfCeQueueTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/cequeue/DropPrimaryKeyOnIdColumnOfCeQueueTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/cequeue/DropUniqueIndexOnUuidColumnOfCeQueueTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/AddUuidToDuplicationsIndexTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/DropIdColumnOfDuplicationsIndexTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/DropPrimaryKeyOnIdColumnOfDuplicationsIndexTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/MakeDuplicationsIndexUuidColumnNotNullableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/PopulateDuplicationsIndexUuidTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/events/AddPrimaryKeyOnUuidColumnOfEventsTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/events/DropIdColumnOfEventsTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/events/DropPrimaryKeyOnIdColumnOfEventsTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/filesources/AddPrimaryKeyOnUuidColumnOfFileSourcesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/filesources/AddUuidColumnToFileSourcesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/filesources/DropIdColumnOfFileSourcesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/filesources/DropPrimaryKeyOnIdColumnOfFileSourcesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/filesources/MakeFileSourcesUuidColumnNotNullableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/filesources/PopulateFileSourcesUuidTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/grouproles/AddPrimaryKeyOnUuidColumnOfGroupRolesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/grouproles/AddUuidColumnToGroupRolesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/grouproles/DropIdColumnOfGroupRolesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/grouproles/DropPrimaryKeyOnIdColumnOfGroupRolesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/grouproles/MakeGroupRolesUuidColumnNotNullableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/grouproles/PopulateGroupRolesUuidTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/AddPrimaryKeyOnUuidColumnOfGroupsTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/AddUuidColumnToGroupsTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/DropIdColumnOfGroupsTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/DropPrimaryKeyOnIdColumnOfGroupsTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/MakeGroupsUuidColumnNotNullableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/PopulateGroupsUuidTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/AddGroupUuidColumnToGroupRolesTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/AddIndexOnGroupUuidOfGroupRolesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/DropGroupIdColumnOfGroupRolesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/DropIndexOnGroupIdOfGroupRolesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/PopulateGroupRolesGroupUuidTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/AddGroupUuidColumnToGroupsUsersTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/AddIndexOnGroupUuidOfGroupsUsersTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/DropGroupIdColumnOfGroupsUsersTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/DropIndexOnGroupIdOfGroupsUsersTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/MakeGroupsUsersGroupUuidNotNullableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/PopulateGroupsUsersGroupUuidTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/organizations/AddDefaultGroupUuidColumnToOrganizationsTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/organizations/DropDefaultGroupIdColumnOfOrganizationsTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/organizations/PopulateOrganizationsDefaultGroupUuidTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/permtemplatesgroups/AddGroupUuidColumnToPermTemplatesGroupsTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/permtemplatesgroups/DropGroupIdColumnOfPermTemplatesGroupsTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/permtemplatesgroups/PopulatePermTemplatesGroupsGroupUuidTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/AddGroupUuidColumnToQProfileEditGroupsTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/AddIndexOnGroupUuidOfQProfileEditGroupsTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/DropGroupIdColumnOfQProfileEditGroupsTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/DropIndexOnGroupIdOfQProfileEditGroupsTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/MakeQProfileEditGroupsGroupUuidNotNullableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/PopulateQProfileEditGroupsGroupUuidTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issuechanges/AddPrimaryKeyOnUuidColumnOfIssueChangesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issuechanges/AddUuidColumnToIssueChangesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issuechanges/DropIdColumnOfIssueChangesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issuechanges/DropPrimaryKeyOnIdColumnOfIssueChangesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issuechanges/MakeIssueChangesUuidColumnNotNullableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issuechanges/PopulateIssueChangesUuidTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issues/AddPrimaryKeyOnKeeColumnOfIssuesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issues/DropIdColumnOfIssuesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issues/DropPrimaryKeyOnIdColumnOfIssuesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/manualmeasures/AddPrimaryKeyOnUuidColumnOfManualMeasureTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/manualmeasures/AddUuidToManualMeasuresTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/manualmeasures/DropIdColumnOfManualMeasuresTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/manualmeasures/DropPrimaryKeyOnIdColumnOfManualMeasuresTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/manualmeasures/MakeManualMeasuresUuidColumnNotNullableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/manualmeasures/PopulateManualMeasuresUuidTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/AddPrimaryKeyOnUuidColumnOfMetricsTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/AddUuidColumnToMetricsTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/DropIdColumnOfMetricsTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/DropPrimaryKeyOnIdColumnOfMetricsTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/MakeMetricsUuidColumnNotNullableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/PopulateMetricsUuidTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/AddIndexOnMetricUuidOfLiveMeasuresTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/AddMetricUuidColumnToLiveMeasuresTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/DropIndexOnMetricIdOfLiveMeasuresTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/DropMetricIdColumnOfLiveMeasuresTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/MakeLiveMeasuresMetricUuidNotNullableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/PopulateLiveMeasuresMetricUuidTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/AddMetricUuidColumnToManualMeasuresTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/DropMetricIdColumnOfManualMeasuresTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/MakeManualMeasuresMetricUuidNotNullableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/PopulateManualMeasuresMetricUuidTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/AddIndexOnMetricUuidOfProjectMeasuresTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/AddMetricUuidColumnToProjectMeasuresTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/DropIndexOnMetricIdOfProjectMeasuresTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/DropMetricIdColumnOfProjectMeasuresTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/MakeProjectMeasuresMetricUuidNotNullableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/PopulateProjectMeasuresMetricUuidTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/AddMetricUuidColumnToQualityGateConditionsTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/DropMetricIdColumnOfQualityGateConditionsTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/MakeQualityGateConditionsMetricUuidNotNullableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/PopulateQualityGateConditionsMetricUuidTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/notifications/AddPrimaryKeyOnUuidColumnOfNotificationTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/notifications/AddUuidAndCreatedAtColumnsToNotificationTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/notifications/DropIdColumnOfNotificationTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/notifications/DropPrimaryKeyOnIdColumnOfNotificationTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/notifications/MakeNotificationUuidAndCreatedAtColumnsNotNullableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/notifications/PopulateNotificationUuidAndCreatedAtTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/AddUuidColumnToPermissionTemplatesTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/DropIdColumnOfPermissionTemplatesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/DropKeeColumnOfPermissionTemplatesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/DropPrimaryKeyOnIdColumnOfPermissionTemplatesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/MakePermissionTemplateUuidColumnNotNullableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/PopulatePermissionTemplatesUuidTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/AddTemplateUuidColumnToPermTemplatesGroupsTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/DropTemplateIdColumnOfPermTemplatesGroupsTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/MakePermTemplatesGroupsTemplateUuidColumnNotNullableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/PopulatePermTemplatesGroupsTemplateUuidColumnTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/AddTemplateUuidColumnToPermTemplatesUsersTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/DropTemplateIdColumnOfPermTemplatesUsersTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/MakePermTemplatesUsersTemplateUuidColumnNotNullableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/PopulatePermTemplatesUsersTemplateUuidColumnTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/AddTemplateUuidColumnToPermTplCharacteristicsTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/DropTemplateIdColumnOfPermTplCharacteristicsTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/MakePermTplCharacteristicsTemplateUuidColumnNotNullableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/PopulatePermTplCharacteristicsTemplateUuidColumnTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/AddUuidColumnToPermTemplatesGroupsTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/DropIdColumnOfPermTemplatesGroupsTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/MakePermTemplatesGroupsUuidColumnNotNullableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/PopulatePermTemplatesGroupsUuidTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/AddUuidColumnToPermTemplatesUsersTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/DropIdColumnOfPermTemplatesUsersTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/MakePermTemplatesUsersUuidColumnNotNullableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/PopulatePermTemplatesUsersUuidTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/AddUuidColumnToPermTplCharacteristicsTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/DropIdColumnOfPermTplCharacteristicsTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/MakePermTplCharacteristicsUuidColumnNotNullableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/PopulatePermTplCharacteristicsUuidTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectmeasures/AddPrimaryKeyOnUuidColumnOfProjectMeasureTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectmeasures/AddUuidToProjectMeasuresTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectmeasures/DropIdColumnOfProjectMeasuresTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectmeasures/DropPrimaryKeyOnIdColumnOfProjectMeasuresTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectmeasures/MakeProjectMeasuresUuidColumnNotNullableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectmeasures/PopulateProjectMeasuresUuidTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/AddUuidColumnToProjectQProfilesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/DropIdColumnOfProjectQProfilesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/MakeProjectQProfilesUuidColumnNotNullableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/PopulateProjectQProfilesUuidTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/properties/AddPrimaryKeyOnUuidColumnOfPropertiesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/properties/AddUuidColumnToPropertiesTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/properties/DropIdColumnOfPropertiesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/properties/DropPrimaryKeyOnIdColumnOfPropertiesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/properties/MakeNotificationUuidColumnNotNullableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/properties/MakePropertiesUuidColumnNotNullable/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/properties/PopulatePropertiesUuidAndCreatedAtTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/AddUuidColumnToQualityGateConditionsTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/DropIdColumnOfQualityGateConditionsTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/DropPrimaryKeyOnIdColumnOfQualityGateConditionsTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/MakeQualityGateConditionsUuidColumnNotNullableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/PopulateQualityGateConditionsUuidTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygates/AddPrimaryKeyOnUuidColumnOfQGatesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygates/AddQGateUuidColumnForQGateConditionsTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropIdColumnOfQGateTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropOrphansQGateConditionsTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropPrimaryKeyOnIdColumnOfQGatesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropQGateIdColumnForQGateConditionsTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropUniqueIndexOnUuidColumnOfQualityGatesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygates/MakeQGateUuidColumnNotNullableForQGateConditionsTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygates/PopulateQGateUuidColumnForQGateConditionsTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/AddPrimaryKeyOnUuidColumnOfRulesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/AddUuidAndTemplateUuidColumnsToRulesTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/DropIdColumnOfRulesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/DropPrimaryKeyOnIdColumnOfRulesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/DropTemplateIdColumnOfRulesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/MakeRulesUuidColumnNotNullableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/PopulateRulesTemplateUuidTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/PopulateRulesUuidTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/activerules/AddIndexToActiveRulesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/activerules/AddRuleUuidColumnToActiveRulesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/activerules/DropIndexOnRuleIdColumnOfActiveRulesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/activerules/DropRuleIdColumnOfActiveRulesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/activerules/MakeActiveRulesRuleUuidColumnNotNullableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/activerules/PopulateActiveRulesRuleUuidColumnTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/AddIndexToDeprecatedRuleKeysTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/AddRuleUuidColumnToDeprecatedRuleKeysTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/DropRuleIdColumnOfDeprecatedRuleKeysTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/MakeDeprecatedRuleKeysRuleUuidColumnNotNullableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/PopulateDeprecatedRuleKeysRuleUuidColumnTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/issues/AddIndexToIssuesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/issues/AddRuleUuidColumnToIssuesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/issues/DropIndexOnRuleIdColumnOfIssuesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/issues/DropRuleIdColumnOfIssuesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/issues/PopulateIssuesRuleUuidColumnTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/AddRuleUuidColumnToRulesMetadataTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/DropPrimaryKeyOnIdColumnOfRulesMetadataTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/DropRuleIdColumnOfRulesMetadataTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/MakeRulesMetadataRuleUuidColumnNotNullableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/PopulateRulesMetadataRuleUuidColumnTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/AddIndexesToRulesParametersTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/AddRuleUuidColumnToRulesParametersTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/DropIndexesOnRuleIdColumnOfRulesParametersTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/DropRuleIdColumnOfRulesParametersTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/MakeRulesParametersRuleUuidColumnNotNullableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/PopulateRulesParametersRuleUuidColumnTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesparameters/AddPrimaryKeyOnUuidColumnOfRulesParametersTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesparameters/AddUuidColumnToRulesParametersTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesparameters/DropIdColumnOfRulesParametersTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesparameters/DropPrimaryKeyOnIdColumnOfRulesParametersTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesparameters/MakeRulesParametersUuidColumnNotNullableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesparameters/PopulateRulesParametersUuidTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/AddRulesParameterUuidColumnToActiveRuleParametersTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/DropRulesParameterIdColumnOfActiveRuleParametersTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/MakeActiveRuleParametersRulesParameterUuidColumnNotNullableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/PopulateActiveRuleParametersRulesParameterUuidTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/AddPrimaryKeyOnUuidColumnOfRulesProfilesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/AddUuidColumnToRulesProfilesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropIdColumnOfRulesProfilesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropKeeColumnOfRulesProfilesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropPrimaryKeyOnIdColumnOfRulesProfilesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropUniqueIndexOnKeeColumnOfRulesProfilesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/MakeRulesProfilesUuidColumnNotNullableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/PopulateRulesProfilesUuidTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/AddProfileUuidColumnToActiveRulesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/AddUniqueIndexOnProfileUuidColumnOfActiveRulesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/DropProfileIdColumnOfActiveRulesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/DropUniqueIndexOnProfileIdColumnOfActiveRulesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/MakeActiveRulesProfileUuidColumnNotNullableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/PopulateActiveRulesProfileUuidTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/orgqprofiles/PopulateOrgQProfilesRulesProfileUuidTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/qprofilechanges/PopulateQProfileChangesRulesProfileUuidTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/snapshots/AddPrimaryKeyOnUuidColumnOfSnapshotsTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/snapshots/DropIdColumnOfSnapshotsTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/snapshots/DropPrimaryKeyOnIdColumnOfSnapshotsTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/userroles/AddPrimaryKeyOnUuidColumnOfUserRolesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/userroles/AddUuidColumnToUserRolesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/userroles/DropIdColumnOfUserRolesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/userroles/DropPrimaryKeyOnIdColumnOfUserRolesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/userroles/MakeUserRolesUuidColumnNotNullableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/userroles/PopulateUserRolesUuidTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/AddPrimaryKeyOnUuidColumnOfUsersTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/DropIdColumnOfUsersTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/DropPrimaryKeyOnIdColumnOfUsersTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/DropUniqueIndexOnUuidColumnOfUsersTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/AddIndexOnUserUuidOfGroupsUsersTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/AddUserUuidColumnToGroupsUsersTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/DropIndexOnUserIdOfGroupsUsersTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/DropUserIdColumnOfGroupsUsersTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/MakeGroupsUsersUserUuidColumnNotNullableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/PopulateGroupsUsersUserUuidTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/AddIndexOnUserUuidOfOrganizationMembersTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/AddUserUuidColumnToOrganizationMembersTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/DropIndexOnUserIdOfOrganizationMembersTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/DropUserIdColumnOfOrganizationMembersTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/MakeOrganizationMembersUserUuidColumnNotNullableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/PopulateOrganizationMembersUserUuidTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/AddUserUuidColumnToPermTemplatesUsersTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/DropUserIdColumnOfPermTemplatesUsersTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/MakePermTemplatesUsersUserUuidColumnNotNullableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/PopulatePermTemplatesUsersUserUuidTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/AddUserUuidColumnToPropertiesUsersTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/DropUserIdColumnOfPropertiesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/PopulatePropertiesUserUuidTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/AddUserUuidColumnToQProfileEditUsersTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/DropUserIdColumnOfQProfileEditUsersTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/MakeQProfileEditUsersUserUuidColumnNotNullableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/PopulateQProfileEditUsersUserUuidTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/AddIndexOnUserUuidOfUserRolesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/AddUserUuidColumnToUserRolesTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/DropIndexOnUserIdOfUserRolesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/DropUserIdColumnOfUserRolesTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/PopulateUserRolesUserUuidTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/usertokens/AddPrimaryKeyOnUuidColumnOfUserTokensTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/usertokens/AddUuidColumnToUserTokensTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/usertokens/DropIdColumnOfUserTokensTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/usertokens/DropPrimaryKeyOnIdColumnOfUserTokensTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/usertokens/MakeUserTokensUuidNotNullableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/usertokens/PopulateUserTokensUuidTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddUuidColumnToActiveRuleParametersTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropIdColumnOfActiveRuleParametersTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropPrimaryKeyOnIdColumnOfActiveRuleParametersTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/MakeActiveRuleParametersUuidColumnNotNullableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/PopulateActiveRuleParametersUuidTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/AddActiveRuleUuidColumnToActiveRuleParametersTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/AddIndexOnActiveRuleUuidOfActiveRuleParametersTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/AddPrimaryKeyOnUuidColumnOfActiveRulesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/AddUuidColumnToActiveRulesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/DropActiveRuleIdColumnOfActiveRuleParametersTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/DropIdColumnOfActiveRulesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/DropIndexOnActiveRuleIdOfActiveRuleParametersTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/DropPrimaryKeyOnIdColumnOfActiveRulesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/MakeActiveRuleParametersActiveRuleUuidNotNullableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/MakeActiveRulesUuidColumnNotNullableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/PopulateActiveRuleParametersActiveRuleUuidTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/PopulateActiveRulesUuidTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropIdColumnOfCeActivityTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/cequeue/AddPrimaryKeyOnUuidColumnOfCeQueueTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/cequeue/DropIdColumnOfCeQueueTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/cequeue/DropPrimaryKeyOnIdColumnOfCeQueueTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/cequeue/DropUniqueIndexOnUuidColumnOfCeQueueTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddUuidToDuplicationsIndexTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropIdColumnOfDuplicationsIndexTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropPrimaryKeyOnIdColumnOfDuplicationsIndexTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/MakeDuplicationsIndexUuidColumnNotNullableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/PopulateDuplicationsIndexUuidTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/events/AddPrimaryKeyOnUuidColumnOfEventsTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/events/DropIdColumnOfEventsTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/events/DropPrimaryKeyOnIdColumnOfEventsTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/filesources/AddPrimaryKeyOnUuidColumnOfFileSourcesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/filesources/AddUuidColumnToFileSourcesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/filesources/DropIdColumnOfFileSourcesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/filesources/DropPrimaryKeyOnIdColumnOfFileSourcesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/filesources/MakeFileSourcesUuidColumnNotNullableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/filesources/PopulateFileSourcesUuidTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/grouproles/AddPrimaryKeyOnUuidColumnOfGroupRolesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/grouproles/AddUuidColumnToGroupRolesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/grouproles/DropIdColumnOfGroupRolesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/grouproles/DropPrimaryKeyOnIdColumnOfGroupRolesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/grouproles/MakeGroupRolesUuidColumnNotNullableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/grouproles/PopulateGroupRolesUuidTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/AddPrimaryKeyOnUuidColumnOfGroupsTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/AddUuidColumnToGroupsTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/DropIdColumnOfGroupsTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/DropPrimaryKeyOnIdColumnOfGroupsTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/MakeGroupsUuidColumnNotNullableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/PopulateGroupsUuidTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/AddGroupUuidColumnToGroupRolesTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/AddIndexOnGroupUuidOfGroupRolesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/DropGroupIdColumnOfGroupRolesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/DropIndexOnGroupIdOfGroupRolesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/PopulateGroupRolesGroupUuidTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/AddGroupUuidColumnToGroupsUsersTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/AddIndexOnGroupUuidOfGroupsUsersTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/DropGroupIdColumnOfGroupsUsersTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/DropIndexOnGroupIdOfGroupsUsersTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/MakeGroupsUsersGroupUuidNotNullableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/PopulateGroupsUsersGroupUuidTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/organizations/AddDefaultGroupUuidColumnToOrganizationsTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/organizations/DropDefaultGroupIdColumnOfOrganizationsTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/organizations/PopulateOrganizationsDefaultGroupUuidTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/AddGroupUuidColumnToPermTemplatesGroupsTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/DropGroupIdColumnOfPermTemplatesGroupsTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/PopulatePermTemplatesGroupsGroupUuidTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/AddGroupUuidColumnToQProfileEditGroupsTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/AddIndexOnGroupUuidOfQProfileEditGroupsTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/DropGroupIdColumnOfQProfileEditGroupsTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/DropIndexOnGroupIdOfQProfileEditGroupsTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/MakeQProfileEditGroupsGroupUuidNotNullableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/PopulateQProfileEditGroupsGroupUuidTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddPrimaryKeyOnUuidColumnOfIssueChangesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddUuidColumnToIssueChangesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issuechanges/DropIdColumnOfIssueChangesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issuechanges/DropPrimaryKeyOnIdColumnOfIssueChangesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issuechanges/MakeIssueChangesUuidColumnNotNullableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issuechanges/PopulateIssueChangesUuidTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issues/AddPrimaryKeyOnKeeColumnOfIssuesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issues/DropIdColumnOfIssuesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issues/DropPrimaryKeyOnIdColumnOfIssuesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddPrimaryKeyOnUuidColumnOfManualMeasureTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddUuidToManualMeasuresTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropIdColumnOfManualMeasuresTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropPrimaryKeyOnIdColumnOfManualMeasuresTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/manualmeasures/MakeManualMeasuresUuidColumnNotNullableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/manualmeasures/PopulateManualMeasuresUuidTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/AddPrimaryKeyOnUuidColumnOfMetricsTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/AddUuidColumnToMetricsTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/DropIdColumnOfMetricsTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/DropPrimaryKeyOnIdColumnOfMetricsTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/MakeMetricsUuidColumnNotNullableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/PopulateMetricsUuidTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddIndexOnMetricUuidOfLiveMeasuresTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddMetricUuidColumnToLiveMeasuresTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/DropIndexOnMetricIdOfLiveMeasuresTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/DropMetricIdColumnOfLiveMeasuresTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/MakeLiveMeasuresMetricUuidNotNullableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/PopulateLiveMeasuresMetricUuidTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/AddMetricUuidColumnToManualMeasuresTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/DropMetricIdColumnOfManualMeasuresTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/MakeManualMeasuresMetricUuidNotNullableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/PopulateManualMeasuresMetricUuidTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddIndexOnMetricUuidOfProjectMeasuresTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddMetricUuidColumnToProjectMeasuresTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DropIndexOnMetricIdOfProjectMeasuresTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DropMetricIdColumnOfProjectMeasuresTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/MakeProjectMeasuresMetricUuidNotNullableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/PopulateProjectMeasuresMetricUuidTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/AddMetricUuidColumnToQualityGateConditionsTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/DropMetricIdColumnOfQualityGateConditionsTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/MakeQualityGateConditionsMetricUuidNotNullableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/PopulateQualityGateConditionsMetricUuidTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/notifications/AddPrimaryKeyOnUuidColumnOfNotificationTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/notifications/AddUuidAndCreatedAtColumnsToNotificationTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/notifications/DropIdColumnOfNotificationTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/notifications/DropPrimaryKeyOnIdColumnOfNotificationTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/notifications/MakeNotificationUuidAndCreatedAtColumnsNotNullableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/notifications/PopulateNotificationUuidAndCreatedAtTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddUuidColumnToPermissionTemplatesTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropIdColumnOfPermissionTemplatesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropKeeColumnOfPermissionTemplatesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropPrimaryKeyOnIdColumnOfPermissionTemplatesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/MakePermissionTemplateUuidColumnNotNullableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/PopulatePermissionTemplatesUuidTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/AddTemplateUuidColumnToPermTemplatesGroupsTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/DropTemplateIdColumnOfPermTemplatesGroupsTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/MakePermTemplatesGroupsTemplateUuidColumnNotNullableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/PopulatePermTemplatesGroupsTemplateUuidColumnTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/AddTemplateUuidColumnToPermTemplatesUsersTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/DropTemplateIdColumnOfPermTemplatesUsersTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/MakePermTemplatesUsersTemplateUuidColumnNotNullableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/PopulatePermTemplatesUsersTemplateUuidColumnTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/AddTemplateUuidColumnToPermTplCharacteristicsTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/DropTemplateIdColumnOfPermTplCharacteristicsTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/MakePermTplCharacteristicsTemplateUuidColumnNotNullableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/PopulatePermTplCharacteristicsTemplateUuidColumnTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddUuidColumnToPermTemplatesGroupsTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropIdColumnOfPermTemplatesGroupsTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/MakePermTemplatesGroupsUuidColumnNotNullableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/PopulatePermTemplatesGroupsUuidTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddUuidColumnToPermTemplatesUsersTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropIdColumnOfPermTemplatesUsersTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/MakePermTemplatesUsersUuidColumnNotNullableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/PopulatePermTemplatesUsersUuidTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddUuidColumnToPermTplCharacteristicsTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropIdColumnOfPermTplCharacteristicsTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/MakePermTplCharacteristicsUuidColumnNotNullableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/PopulatePermTplCharacteristicsUuidTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddPrimaryKeyOnUuidColumnOfProjectMeasureTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddUuidToProjectMeasuresTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropIdColumnOfProjectMeasuresTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropPrimaryKeyOnIdColumnOfProjectMeasuresTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/MakeProjectMeasuresUuidColumnNotNullableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/PopulateProjectMeasuresUuidTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddUuidColumnToProjectQProfilesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropIdColumnOfProjectQProfilesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/MakeProjectQProfilesUuidColumnNotNullableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/PopulateProjectQProfilesUuidTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/AddPrimaryKeyOnUuidColumnOfPropertiesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/AddUuidColumnToPropertiesTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/DropIdColumnOfPropertiesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/DropPrimaryKeyOnIdColumnOfPropertiesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/MakeNotificationUuidColumnNotNullableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/MakePropertiesUuidColumnNotNullable/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/PopulatePropertiesUuidAndCreatedAtTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddUuidColumnToQualityGateConditionsTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropIdColumnOfQualityGateConditionsTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropPrimaryKeyOnIdColumnOfQualityGateConditionsTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/MakeQualityGateConditionsUuidColumnNotNullableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/PopulateQualityGateConditionsUuidTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddPrimaryKeyOnUuidColumnOfQGatesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddQGateUuidColumnForQGateConditionsTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropIdColumnOfQGateTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropOrphansQGateConditionsTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropPrimaryKeyOnIdColumnOfQGatesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropQGateIdColumnForQGateConditionsTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropUniqueIndexOnUuidColumnOfQualityGatesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/MakeQGateUuidColumnNotNullableForQGateConditionsTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/PopulateQGateUuidColumnForQGateConditionsTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/AddPrimaryKeyOnUuidColumnOfRulesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/AddUuidAndTemplateUuidColumnsToRulesTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/DropIdColumnOfRulesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/DropPrimaryKeyOnIdColumnOfRulesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/DropTemplateIdColumnOfRulesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/MakeRulesUuidColumnNotNullableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/PopulateRulesTemplateUuidTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/PopulateRulesUuidTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/activerules/AddIndexToActiveRulesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/activerules/AddRuleUuidColumnToActiveRulesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/activerules/DropIndexOnRuleIdColumnOfActiveRulesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/activerules/DropRuleIdColumnOfActiveRulesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/activerules/MakeActiveRulesRuleUuidColumnNotNullableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/activerules/PopulateActiveRulesRuleUuidColumnTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/AddIndexToDeprecatedRuleKeysTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/AddRuleUuidColumnToDeprecatedRuleKeysTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/DropRuleIdColumnOfDeprecatedRuleKeysTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/MakeDeprecatedRuleKeysRuleUuidColumnNotNullableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/PopulateDeprecatedRuleKeysRuleUuidColumnTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/issues/AddIndexToIssuesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/issues/AddRuleUuidColumnToIssuesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/issues/DropIndexOnRuleIdColumnOfIssuesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/issues/DropRuleIdColumnOfIssuesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/issues/PopulateIssuesRuleUuidColumnTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddRuleUuidColumnToRulesMetadataTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropPrimaryKeyOnIdColumnOfRulesMetadataTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropRuleIdColumnOfRulesMetadataTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/MakeRulesMetadataRuleUuidColumnNotNullableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/PopulateRulesMetadataRuleUuidColumnTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/AddIndexesToRulesParametersTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/AddRuleUuidColumnToRulesParametersTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/DropIndexesOnRuleIdColumnOfRulesParametersTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/DropRuleIdColumnOfRulesParametersTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/MakeRulesParametersRuleUuidColumnNotNullableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/PopulateRulesParametersRuleUuidColumnTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddPrimaryKeyOnUuidColumnOfRulesParametersTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddUuidColumnToRulesParametersTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropIdColumnOfRulesParametersTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropPrimaryKeyOnIdColumnOfRulesParametersTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/MakeRulesParametersUuidColumnNotNullableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/PopulateRulesParametersUuidTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/AddRulesParameterUuidColumnToActiveRuleParametersTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/DropRulesParameterIdColumnOfActiveRuleParametersTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/MakeActiveRuleParametersRulesParameterUuidColumnNotNullableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/PopulateActiveRuleParametersRulesParameterUuidTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddPrimaryKeyOnUuidColumnOfRulesProfilesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddUuidColumnToRulesProfilesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropIdColumnOfRulesProfilesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropKeeColumnOfRulesProfilesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropPrimaryKeyOnIdColumnOfRulesProfilesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropUniqueIndexOnKeeColumnOfRulesProfilesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/MakeRulesProfilesUuidColumnNotNullableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/PopulateRulesProfilesUuidTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/AddProfileUuidColumnToActiveRulesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/AddUniqueIndexOnProfileUuidColumnOfActiveRulesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/DropProfileIdColumnOfActiveRulesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/DropUniqueIndexOnProfileIdColumnOfActiveRulesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/MakeActiveRulesProfileUuidColumnNotNullableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/PopulateActiveRulesProfileUuidTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/orgqprofiles/PopulateOrgQProfilesRulesProfileUuidTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/qprofilechanges/PopulateQProfileChangesRulesProfileUuidTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/snapshots/AddPrimaryKeyOnUuidColumnOfSnapshotsTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/snapshots/DropIdColumnOfSnapshotsTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/snapshots/DropPrimaryKeyOnIdColumnOfSnapshotsTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/userroles/AddPrimaryKeyOnUuidColumnOfUserRolesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/userroles/AddUuidColumnToUserRolesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/userroles/DropIdColumnOfUserRolesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/userroles/DropPrimaryKeyOnIdColumnOfUserRolesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/userroles/MakeUserRolesUuidColumnNotNullableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/userroles/PopulateUserRolesUuidTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/AddPrimaryKeyOnUuidColumnOfUsersTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/DropIdColumnOfUsersTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/DropPrimaryKeyOnIdColumnOfUsersTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/DropUniqueIndexOnUuidColumnOfUsersTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddIndexOnUserUuidOfGroupsUsersTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddUserUuidColumnToGroupsUsersTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropIndexOnUserIdOfGroupsUsersTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropUserIdColumnOfGroupsUsersTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/MakeGroupsUsersUserUuidColumnNotNullableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/PopulateGroupsUsersUserUuidTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddIndexOnUserUuidOfOrganizationMembersTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddUserUuidColumnToOrganizationMembersTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropIndexOnUserIdOfOrganizationMembersTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropUserIdColumnOfOrganizationMembersTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/MakeOrganizationMembersUserUuidColumnNotNullableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/PopulateOrganizationMembersUserUuidTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/AddUserUuidColumnToPermTemplatesUsersTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/DropUserIdColumnOfPermTemplatesUsersTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/MakePermTemplatesUsersUserUuidColumnNotNullableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/PopulatePermTemplatesUsersUserUuidTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/AddUserUuidColumnToPropertiesUsersTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/DropUserIdColumnOfPropertiesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/PopulatePropertiesUserUuidTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/AddUserUuidColumnToQProfileEditUsersTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/DropUserIdColumnOfQProfileEditUsersTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/MakeQProfileEditUsersUserUuidColumnNotNullableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/PopulateQProfileEditUsersUserUuidTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/AddIndexOnUserUuidOfUserRolesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/AddUserUuidColumnToUserRolesTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/DropIndexOnUserIdOfUserRolesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/DropUserIdColumnOfUserRolesTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/PopulateUserRolesUserUuidTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/usertokens/AddPrimaryKeyOnUuidColumnOfUserTokensTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/usertokens/AddUuidColumnToUserTokensTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/usertokens/DropIdColumnOfUserTokensTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/usertokens/DropPrimaryKeyOnIdColumnOfUserTokensTableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/usertokens/MakeUserTokensUuidNotNullableTest/schema.sql create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/usertokens/PopulateUserTokensUuidTest/schema.sql (limited to 'server/sonar-db-migration') diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/MigrationConfigurationModule.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/MigrationConfigurationModule.java index 765b0d6c047..5732d5dcbfb 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/MigrationConfigurationModule.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/MigrationConfigurationModule.java @@ -29,8 +29,9 @@ import org.sonar.server.platform.db.migration.version.v80.DbVersion80; import org.sonar.server.platform.db.migration.version.v81.DbVersion81; import org.sonar.server.platform.db.migration.version.v82.DbVersion82; import org.sonar.server.platform.db.migration.version.v83.DbVersion83; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v83.util.SqlHelper; +import org.sonar.server.platform.db.migration.version.v84.DbVersion84; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; +import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; public class MigrationConfigurationModule extends Module { @Override @@ -42,6 +43,7 @@ public class MigrationConfigurationModule extends Module { DbVersion81.class, DbVersion82.class, DbVersion83.class, + DbVersion84.class, // migration steps MigrationStepRegistryImpl.class, diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/DbVersion83.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/DbVersion83.java index 73716cd4e5e..000f8bcf457 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/DbVersion83.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/DbVersion83.java @@ -21,325 +21,15 @@ package org.sonar.server.platform.db.migration.version.v83; import org.sonar.server.platform.db.migration.step.MigrationStepRegistry; import org.sonar.server.platform.db.migration.version.DbVersion; -import org.sonar.server.platform.db.migration.version.v83.activeruleparameters.AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTable; -import org.sonar.server.platform.db.migration.version.v83.activeruleparameters.AddUuidColumnToActiveRuleParametersTable; -import org.sonar.server.platform.db.migration.version.v83.activeruleparameters.DropIdColumnOfActiveRuleParametersTable; -import org.sonar.server.platform.db.migration.version.v83.activeruleparameters.DropPrimaryKeyOnIdColumnOfActiveRuleParametersTable; -import org.sonar.server.platform.db.migration.version.v83.activeruleparameters.MakeActiveRuleParametersUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v83.activeruleparameters.PopulateActiveRuleParametersUuid; -import org.sonar.server.platform.db.migration.version.v83.activerules.AddActiveRuleUuidColumnToActiveRuleParameters; -import org.sonar.server.platform.db.migration.version.v83.activerules.AddIndexOnActiveRuleUuidOfActiveRuleParametersTable; -import org.sonar.server.platform.db.migration.version.v83.activerules.AddPrimaryKeyOnUuidColumnOfActiveRulesTable; -import org.sonar.server.platform.db.migration.version.v83.activerules.AddUuidColumnToActiveRulesTable; -import org.sonar.server.platform.db.migration.version.v83.activerules.DropActiveRuleIdColumnOfActiveRuleParametersTable; -import org.sonar.server.platform.db.migration.version.v83.activerules.DropIdColumnOfActiveRulesTable; -import org.sonar.server.platform.db.migration.version.v83.activerules.DropIndexOnActiveRuleIdOfActiveRuleParametersTable; -import org.sonar.server.platform.db.migration.version.v83.activerules.DropPrimaryKeyOnIdColumnOfActiveRulesTable; -import org.sonar.server.platform.db.migration.version.v83.activerules.MakeActiveRuleParametersActiveRuleUuidNotNullable; -import org.sonar.server.platform.db.migration.version.v83.activerules.MakeActiveRulesUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v83.activerules.PopulateActiveRuleParametersActiveRuleUuid; -import org.sonar.server.platform.db.migration.version.v83.activerules.PopulateActiveRulesUuid; -import org.sonar.server.platform.db.migration.version.v83.ceactivity.AddPrimaryKeyOnUuidColumnOfCeActivityTable; -import org.sonar.server.platform.db.migration.version.v83.ceactivity.DropIdColumnOfCeActivityTable; -import org.sonar.server.platform.db.migration.version.v83.ceactivity.DropPrimaryKeyOnIdColumnOfCeActivityTable; -import org.sonar.server.platform.db.migration.version.v83.cequeue.AddPrimaryKeyOnUuidColumnOfCeQueueTable; -import org.sonar.server.platform.db.migration.version.v83.cequeue.DropIdColumnOfCeQueueTable; -import org.sonar.server.platform.db.migration.version.v83.cequeue.DropPrimaryKeyOnIdColumnOfCeQueueTable; -import org.sonar.server.platform.db.migration.version.v83.cequeue.DropUniqueIndexOnUuidColumnOfCeQueueTable; -import org.sonar.server.platform.db.migration.version.v83.duplicationsindex.AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTable; -import org.sonar.server.platform.db.migration.version.v83.duplicationsindex.AddUuidToDuplicationsIndexTable; -import org.sonar.server.platform.db.migration.version.v83.duplicationsindex.DropIdColumnOfDuplicationsIndexTable; -import org.sonar.server.platform.db.migration.version.v83.duplicationsindex.DropPrimaryKeyOnIdColumnOfDuplicationsIndexTable; -import org.sonar.server.platform.db.migration.version.v83.duplicationsindex.MakeDuplicationsIndexUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v83.duplicationsindex.PopulateDuplicationsIndexUuid; -import org.sonar.server.platform.db.migration.version.v83.events.AddPrimaryKeyOnUuidColumnOfEventsTable; -import org.sonar.server.platform.db.migration.version.v83.events.DropIdColumnOfEventsTable; -import org.sonar.server.platform.db.migration.version.v83.events.DropPrimaryKeyOnIdColumnOfEventsTable; -import org.sonar.server.platform.db.migration.version.v83.filesources.AddPrimaryKeyOnUuidColumnOfFileSourcesTable; -import org.sonar.server.platform.db.migration.version.v83.filesources.AddUuidColumnToFileSourcesTable; -import org.sonar.server.platform.db.migration.version.v83.filesources.DropIdColumnOfFileSourcesTable; -import org.sonar.server.platform.db.migration.version.v83.filesources.DropPrimaryKeyOnIdColumnOfFileSourcesTable; -import org.sonar.server.platform.db.migration.version.v83.filesources.MakeFileSourcesUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v83.filesources.PopulateFileSourcesUuid; import org.sonar.server.platform.db.migration.version.v83.grouproles.AddComponentUuidColumnToGroupRoles; -import org.sonar.server.platform.db.migration.version.v83.grouproles.AddPrimaryKeyOnUuidColumnOfGroupRolesTable; -import org.sonar.server.platform.db.migration.version.v83.grouproles.AddUuidColumnToGroupRolesTable; -import org.sonar.server.platform.db.migration.version.v83.grouproles.DropIdColumnOfGroupRolesTable; -import org.sonar.server.platform.db.migration.version.v83.grouproles.DropPrimaryKeyOnIdColumnOfGroupRolesTable; import org.sonar.server.platform.db.migration.version.v83.grouproles.DropResourceIdFromGroupRolesTable; -import org.sonar.server.platform.db.migration.version.v83.grouproles.MakeGroupRolesUuidColumnNotNullable; import org.sonar.server.platform.db.migration.version.v83.grouproles.MigrateResourceIdToUuidInGroupRoles; -import org.sonar.server.platform.db.migration.version.v83.grouproles.PopulateGroupRolesUuid; -import org.sonar.server.platform.db.migration.version.v83.groups.AddPrimaryKeyOnUuidColumnOfGroupsTable; -import org.sonar.server.platform.db.migration.version.v83.groups.AddUuidColumnToGroupsTable; -import org.sonar.server.platform.db.migration.version.v83.groups.DropIdColumnOfGroupsTable; -import org.sonar.server.platform.db.migration.version.v83.groups.DropPrimaryKeyOnIdColumnOfGroupsTable; -import org.sonar.server.platform.db.migration.version.v83.groups.MakeGroupsUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v83.groups.PopulateGroupsUuid; -import org.sonar.server.platform.db.migration.version.v83.groups.grouproles.AddGroupUuidColumnToGroupRoles; -import org.sonar.server.platform.db.migration.version.v83.groups.grouproles.AddIndexOnGroupUuidOfGroupRolesTable; -import org.sonar.server.platform.db.migration.version.v83.groups.grouproles.DropGroupIdColumnOfGroupRolesTable; -import org.sonar.server.platform.db.migration.version.v83.groups.grouproles.DropIndexOnGroupIdOfGroupRolesTable; -import org.sonar.server.platform.db.migration.version.v83.groups.grouproles.PopulateGroupRolesGroupUuid; -import org.sonar.server.platform.db.migration.version.v83.groups.groupsusers.AddGroupUuidColumnToGroupsUsers; -import org.sonar.server.platform.db.migration.version.v83.groups.groupsusers.AddIndexOnGroupUuidOfGroupsUsersTable; -import org.sonar.server.platform.db.migration.version.v83.groups.groupsusers.DropGroupIdColumnOfGroupsUsersTable; -import org.sonar.server.platform.db.migration.version.v83.groups.groupsusers.DropIndexOnGroupIdOfGroupsUsersTable; -import org.sonar.server.platform.db.migration.version.v83.groups.groupsusers.MakeGroupsUsersGroupUuidNotNullable; -import org.sonar.server.platform.db.migration.version.v83.groups.groupsusers.PopulateGroupsUsersGroupUuid; -import org.sonar.server.platform.db.migration.version.v83.groups.organizations.AddDefaultGroupUuidColumnToOrganizations; -import org.sonar.server.platform.db.migration.version.v83.groups.organizations.DropDefaultGroupIdColumnOfOrganizationsTable; -import org.sonar.server.platform.db.migration.version.v83.groups.organizations.PopulateOrganizationsDefaultGroupUuid; -import org.sonar.server.platform.db.migration.version.v83.groups.permtemplatesgroups.AddGroupUuidColumnToPermTemplatesGroups; -import org.sonar.server.platform.db.migration.version.v83.groups.permtemplatesgroups.DropGroupIdColumnOfPermTemplatesGroupsTable; -import org.sonar.server.platform.db.migration.version.v83.groups.permtemplatesgroups.PopulatePermTemplatesGroupsGroupUuid; -import org.sonar.server.platform.db.migration.version.v83.groups.qprofileeditgroups.AddGroupUuidColumnToQProfileEditGroups; -import org.sonar.server.platform.db.migration.version.v83.groups.qprofileeditgroups.AddIndexOnGroupUuidOfQProfileEditGroupsTable; -import org.sonar.server.platform.db.migration.version.v83.groups.qprofileeditgroups.DropGroupIdColumnOfQProfileEditGroupsTable; -import org.sonar.server.platform.db.migration.version.v83.groups.qprofileeditgroups.DropIndexOnGroupIdOfQProfileEditGroupsTable; -import org.sonar.server.platform.db.migration.version.v83.groups.qprofileeditgroups.MakeQProfileEditGroupsGroupUuidNotNullable; -import org.sonar.server.platform.db.migration.version.v83.groups.qprofileeditgroups.PopulateQProfileEditGroupsGroupUuid; -import org.sonar.server.platform.db.migration.version.v83.issuechanges.AddPrimaryKeyOnUuidColumnOfIssueChangesTable; -import org.sonar.server.platform.db.migration.version.v83.issuechanges.AddUuidColumnToIssueChangesTable; -import org.sonar.server.platform.db.migration.version.v83.issuechanges.DropIdColumnOfIssueChangesTable; -import org.sonar.server.platform.db.migration.version.v83.issuechanges.DropPrimaryKeyOnIdColumnOfIssueChangesTable; -import org.sonar.server.platform.db.migration.version.v83.issuechanges.MakeIssueChangesUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v83.issuechanges.PopulateIssueChangesUuid; -import org.sonar.server.platform.db.migration.version.v83.issues.AddPrimaryKeyOnKeeColumnOfIssuesTable; -import org.sonar.server.platform.db.migration.version.v83.issues.DropIdColumnOfIssuesTable; -import org.sonar.server.platform.db.migration.version.v83.issues.DropPrimaryKeyOnIdColumnOfIssuesTable; -import org.sonar.server.platform.db.migration.version.v83.manualmeasures.AddPrimaryKeyOnUuidColumnOfManualMeasuresTable; -import org.sonar.server.platform.db.migration.version.v83.manualmeasures.AddUuidColumnToManualMeasures; -import org.sonar.server.platform.db.migration.version.v83.manualmeasures.DropIdColumnOfManualMeasuresTable; -import org.sonar.server.platform.db.migration.version.v83.manualmeasures.DropPrimaryKeyOnIdColumnOfManualMeasuresTable; -import org.sonar.server.platform.db.migration.version.v83.manualmeasures.MakeManualMeasuresUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v83.manualmeasures.PopulateManualMeasureUuid; -import org.sonar.server.platform.db.migration.version.v83.metrics.AddPrimaryKeyOnUuidColumnOfMetricsTable; -import org.sonar.server.platform.db.migration.version.v83.metrics.AddUuidColumnToMetricsTable; -import org.sonar.server.platform.db.migration.version.v83.metrics.DropIdColumnOfMetricsTable; -import org.sonar.server.platform.db.migration.version.v83.metrics.DropPrimaryKeyOnIdColumnOfMetricsTable; -import org.sonar.server.platform.db.migration.version.v83.metrics.MakeMetricsUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v83.metrics.PopulateMetricsUuid; -import org.sonar.server.platform.db.migration.version.v83.metrics.livemeasures.AddIndexOnMetricUuidOfLiveMeasuresTable; -import org.sonar.server.platform.db.migration.version.v83.metrics.livemeasures.AddMetricUuidColumnToLiveMeasures; -import org.sonar.server.platform.db.migration.version.v83.metrics.livemeasures.DropIndexOnMetricIdOfLiveMeasuresTable; -import org.sonar.server.platform.db.migration.version.v83.metrics.livemeasures.DropMetricIdColumnOfLiveMeasuresTable; -import org.sonar.server.platform.db.migration.version.v83.metrics.livemeasures.MakeLiveMeasuresMetricUuidNotNullable; -import org.sonar.server.platform.db.migration.version.v83.metrics.livemeasures.PopulateLiveMeasuresMetricUuid; -import org.sonar.server.platform.db.migration.version.v83.metrics.manualmeasures.AddMetricUuidColumnToManualMeasures; -import org.sonar.server.platform.db.migration.version.v83.metrics.manualmeasures.DropMetricIdColumnOfManualMeasuresTable; -import org.sonar.server.platform.db.migration.version.v83.metrics.manualmeasures.MakeManualMeasuresMetricUuidNotNullable; -import org.sonar.server.platform.db.migration.version.v83.metrics.manualmeasures.PopulateManualMeasuresMetricUuid; -import org.sonar.server.platform.db.migration.version.v83.metrics.projectmeasures.AddIndexOnMetricUuidOfProjectMeasuresTable; -import org.sonar.server.platform.db.migration.version.v83.metrics.projectmeasures.AddMetricUuidColumnToProjectMeasures; -import org.sonar.server.platform.db.migration.version.v83.metrics.projectmeasures.DropIndexOnMetricIdOfProjectMeasuresTable; -import org.sonar.server.platform.db.migration.version.v83.metrics.projectmeasures.DropMetricIdColumnOfProjectMeasuresTable; -import org.sonar.server.platform.db.migration.version.v83.metrics.projectmeasures.MakeProjectMeasuresMetricUuidNotNullable; -import org.sonar.server.platform.db.migration.version.v83.metrics.projectmeasures.PopulateProjectMeasuresMetricUuid; -import org.sonar.server.platform.db.migration.version.v83.metrics.qualitygateconditions.AddMetricUuidColumnToQualityGateConditions; -import org.sonar.server.platform.db.migration.version.v83.metrics.qualitygateconditions.DropMetricIdColumnOfQualityGateConditionsTable; -import org.sonar.server.platform.db.migration.version.v83.metrics.qualitygateconditions.MakeQualityGateConditionsMetricUuidNotNullable; -import org.sonar.server.platform.db.migration.version.v83.metrics.qualitygateconditions.PopulateQualityGateConditionsMetricUuid; -import org.sonar.server.platform.db.migration.version.v83.notifications.AddPrimaryKeyOnUuidColumnOfNotificationTable; -import org.sonar.server.platform.db.migration.version.v83.notifications.AddUuidAndCreatedAtColumnsToNotification; -import org.sonar.server.platform.db.migration.version.v83.notifications.DropIdColumnOfNotificationTable; -import org.sonar.server.platform.db.migration.version.v83.notifications.DropPrimaryKeyOnIdColumnOfNotificationTable; -import org.sonar.server.platform.db.migration.version.v83.notifications.MakeNotificationUuidAndCreatedAtColumnsNotNullable; -import org.sonar.server.platform.db.migration.version.v83.notifications.PopulateNotificationUuidAndCreatedAt; -import org.sonar.server.platform.db.migration.version.v83.permissiontemplates.AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTable; -import org.sonar.server.platform.db.migration.version.v83.permissiontemplates.AddUuidColumnToPermissionTemplates; -import org.sonar.server.platform.db.migration.version.v83.permissiontemplates.DropIdColumnOfPermissionTemplatesTable; -import org.sonar.server.platform.db.migration.version.v83.permissiontemplates.DropKeeColumnOfPermissionTemplatesTable; -import org.sonar.server.platform.db.migration.version.v83.permissiontemplates.DropPrimaryKeyOnIdColumnOfPermissionTemplatesTable; -import org.sonar.server.platform.db.migration.version.v83.permissiontemplates.MakePermissionTemplateUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v83.permissiontemplates.PopulatePermissionTemplatesUuid; -import org.sonar.server.platform.db.migration.version.v83.permissiontemplates.fk.permtemplatesgroups.AddTemplateUuidColumnToPermTemplatesGroups; -import org.sonar.server.platform.db.migration.version.v83.permissiontemplates.fk.permtemplatesgroups.DropTemplateIdColumnOfPermTemplatesGroupsTable; -import org.sonar.server.platform.db.migration.version.v83.permissiontemplates.fk.permtemplatesgroups.MakePermTemplatesGroupsTemplateUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v83.permissiontemplates.fk.permtemplatesgroups.PopulatePermTemplatesGroupsTemplateUuidColumn; -import org.sonar.server.platform.db.migration.version.v83.permissiontemplates.fk.permtemplatesusers.AddTemplateUuidColumnToPermTemplatesUsers; -import org.sonar.server.platform.db.migration.version.v83.permissiontemplates.fk.permtemplatesusers.DropTemplateIdColumnOfPermTemplatesUsersTable; -import org.sonar.server.platform.db.migration.version.v83.permissiontemplates.fk.permtemplatesusers.MakePermTemplatesUsersTemplateUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v83.permissiontemplates.fk.permtemplatesusers.PopulatePermTemplatesUsersTemplateUuidColumn; -import org.sonar.server.platform.db.migration.version.v83.permissiontemplates.fk.permtplcharacteristics.AddTemplateUuidColumnToPermTplCharacteristics; -import org.sonar.server.platform.db.migration.version.v83.permissiontemplates.fk.permtplcharacteristics.AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTable; -import org.sonar.server.platform.db.migration.version.v83.permissiontemplates.fk.permtplcharacteristics.DropTemplateIdColumnOfPermTplCharacteristicsTable; -import org.sonar.server.platform.db.migration.version.v83.permissiontemplates.fk.permtplcharacteristics.DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTable; -import org.sonar.server.platform.db.migration.version.v83.permissiontemplates.fk.permtplcharacteristics.MakePermTplCharacteristicsTemplateUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v83.permissiontemplates.fk.permtplcharacteristics.PopulatePermTplCharacteristicsTemplateUuidColumn; -import org.sonar.server.platform.db.migration.version.v83.permtemplatesgroups.AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTable; -import org.sonar.server.platform.db.migration.version.v83.permtemplatesgroups.AddUuidColumnToPermTemplatesGroupsTable; -import org.sonar.server.platform.db.migration.version.v83.permtemplatesgroups.DropIdColumnOfPermTemplatesGroupsTable; -import org.sonar.server.platform.db.migration.version.v83.permtemplatesgroups.DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTable; -import org.sonar.server.platform.db.migration.version.v83.permtemplatesgroups.MakePermTemplatesGroupsUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v83.permtemplatesgroups.PopulatePermTemplatesGroupsUuid; -import org.sonar.server.platform.db.migration.version.v83.permtemplatesusers.AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTable; -import org.sonar.server.platform.db.migration.version.v83.permtemplatesusers.AddUuidColumnToPermTemplatesUsersTable; -import org.sonar.server.platform.db.migration.version.v83.permtemplatesusers.DropIdColumnOfPermTemplatesUsersTable; -import org.sonar.server.platform.db.migration.version.v83.permtemplatesusers.DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTable; -import org.sonar.server.platform.db.migration.version.v83.permtemplatesusers.MakePermTemplatesUsersUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v83.permtemplatesusers.PopulatePermTemplatesUsersUuid; -import org.sonar.server.platform.db.migration.version.v83.permtplcharacteristics.AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTable; -import org.sonar.server.platform.db.migration.version.v83.permtplcharacteristics.AddUuidColumnToPermTplCharacteristicsTable; -import org.sonar.server.platform.db.migration.version.v83.permtplcharacteristics.DropIdColumnOfPermTplCharacteristicsTable; -import org.sonar.server.platform.db.migration.version.v83.permtplcharacteristics.DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTable; -import org.sonar.server.platform.db.migration.version.v83.permtplcharacteristics.MakePermTplCharacteristicsUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v83.permtplcharacteristics.PopulatePermTplCharacteristicsUuid; -import org.sonar.server.platform.db.migration.version.v83.projectmeasures.AddPrimaryKeyOnUuidColumnOfProjectMeasuresTable; -import org.sonar.server.platform.db.migration.version.v83.projectmeasures.AddUuidColumnToProjectMeasures; -import org.sonar.server.platform.db.migration.version.v83.projectmeasures.DropIdColumnOfProjectMeasuresTable; -import org.sonar.server.platform.db.migration.version.v83.projectmeasures.DropPrimaryKeyOnIdColumnOfProjectMeasuresTable; -import org.sonar.server.platform.db.migration.version.v83.projectmeasures.MakeProjectMeasuresUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v83.projectmeasures.PopulateProjectMeasureUuid; -import org.sonar.server.platform.db.migration.version.v83.projectqprofiles.AddPrimaryKeyOnUuidColumnOfProjectQProfilesTable; -import org.sonar.server.platform.db.migration.version.v83.projectqprofiles.AddUuidColumnToProjectQProfilesTable; -import org.sonar.server.platform.db.migration.version.v83.projectqprofiles.DropIdColumnOfProjectQProfilesTable; -import org.sonar.server.platform.db.migration.version.v83.projectqprofiles.DropPrimaryKeyOnIdColumnOfProjectQProfilesTable; -import org.sonar.server.platform.db.migration.version.v83.projectqprofiles.MakeProjectQProfilesUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v83.projectqprofiles.PopulateProjectQProfilesUuid; import org.sonar.server.platform.db.migration.version.v83.properties.AddComponentUuidColumnToProperties; -import org.sonar.server.platform.db.migration.version.v83.properties.AddPrimaryKeyOnUuidColumnOfPropertiesTable; -import org.sonar.server.platform.db.migration.version.v83.properties.AddUuidColumnToProperties; -import org.sonar.server.platform.db.migration.version.v83.properties.DropIdColumnOfPropertiesTable; -import org.sonar.server.platform.db.migration.version.v83.properties.DropPrimaryKeyOnIdColumnOfPropertiesTable; import org.sonar.server.platform.db.migration.version.v83.properties.DropResourceIdFromPropertiesTable; -import org.sonar.server.platform.db.migration.version.v83.properties.MakePropertiesUuidColumnNotNullable; import org.sonar.server.platform.db.migration.version.v83.properties.MigrateResourceIdToUuidInProperties; -import org.sonar.server.platform.db.migration.version.v83.properties.PopulatePropertiesUuid; -import org.sonar.server.platform.db.migration.version.v83.qualitygateconditions.AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTable; -import org.sonar.server.platform.db.migration.version.v83.qualitygateconditions.AddUuidColumnToQualityGateConditionsTable; -import org.sonar.server.platform.db.migration.version.v83.qualitygateconditions.DropIdColumnOfQualityGateConditionsTable; -import org.sonar.server.platform.db.migration.version.v83.qualitygateconditions.DropPrimaryKeyOnIdColumnOfQualityGateConditionsTable; -import org.sonar.server.platform.db.migration.version.v83.qualitygateconditions.MakeQualityGateConditionsUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v83.qualitygateconditions.PopulateQualityGateConditionsUuid; -import org.sonar.server.platform.db.migration.version.v83.qualitygates.AddPrimaryKeyOnUuidColumnOfQGatesTable; -import org.sonar.server.platform.db.migration.version.v83.qualitygates.AddQGateUuidColumnForQGateConditions; -import org.sonar.server.platform.db.migration.version.v83.qualitygates.DropIdColumnOfQGateTable; -import org.sonar.server.platform.db.migration.version.v83.qualitygates.DropOrphansQGateConditions; -import org.sonar.server.platform.db.migration.version.v83.qualitygates.DropPrimaryKeyOnIdColumnOfQGatesTable; -import org.sonar.server.platform.db.migration.version.v83.qualitygates.DropQGateIdColumnForQGateConditions; -import org.sonar.server.platform.db.migration.version.v83.qualitygates.DropUniqueIndexOnUuidColumnOfQualityGatesTable; -import org.sonar.server.platform.db.migration.version.v83.qualitygates.MakeQGateUuidColumnNotNullableForQGateConditions; -import org.sonar.server.platform.db.migration.version.v83.qualitygates.PopulateQGateUuidColumnForQGateConditions; -import org.sonar.server.platform.db.migration.version.v83.rules.AddPrimaryKeyOnUuidColumnOfRulesTable; -import org.sonar.server.platform.db.migration.version.v83.rules.AddUuidAndTemplateUuidColumnsToRules; -import org.sonar.server.platform.db.migration.version.v83.rules.DropIdColumnOfRulesTable; -import org.sonar.server.platform.db.migration.version.v83.rules.DropPrimaryKeyOnIdColumnOfRulesTable; -import org.sonar.server.platform.db.migration.version.v83.rules.DropTemplateIdColumnOfRulesTable; -import org.sonar.server.platform.db.migration.version.v83.rules.MakeRulesUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v83.rules.PopulateRulesTemplateUuid; -import org.sonar.server.platform.db.migration.version.v83.rules.PopulateRulesUuid; -import org.sonar.server.platform.db.migration.version.v83.rules.activerules.AddIndexToActiveRulesTable; -import org.sonar.server.platform.db.migration.version.v83.rules.activerules.AddRuleUuidColumnToActiveRulesTable; -import org.sonar.server.platform.db.migration.version.v83.rules.activerules.DropIndexOnRuleIdColumnOfActiveRulesTable; -import org.sonar.server.platform.db.migration.version.v83.rules.activerules.DropRuleIdColumnOfActiveRulesTable; -import org.sonar.server.platform.db.migration.version.v83.rules.activerules.MakeActiveRulesRuleUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v83.rules.activerules.PopulateActiveRulesRuleUuidColumn; -import org.sonar.server.platform.db.migration.version.v83.rules.deprecatedrulekeys.AddIndexToDeprecatedRuleKeysTable; -import org.sonar.server.platform.db.migration.version.v83.rules.deprecatedrulekeys.AddRuleUuidColumnToDeprecatedRuleKeysTable; -import org.sonar.server.platform.db.migration.version.v83.rules.deprecatedrulekeys.DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTable; -import org.sonar.server.platform.db.migration.version.v83.rules.deprecatedrulekeys.DropRuleIdColumnOfDeprecatedRuleKeysTable; -import org.sonar.server.platform.db.migration.version.v83.rules.deprecatedrulekeys.MakeDeprecatedRuleKeysRuleUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v83.rules.deprecatedrulekeys.PopulateDeprecatedRuleKeysRuleUuidColumn; -import org.sonar.server.platform.db.migration.version.v83.rules.issues.AddIndexToIssuesTable; -import org.sonar.server.platform.db.migration.version.v83.rules.issues.AddRuleUuidColumnToIssuesTable; -import org.sonar.server.platform.db.migration.version.v83.rules.issues.DropIndexOnRuleIdColumnOfIssuesTable; -import org.sonar.server.platform.db.migration.version.v83.rules.issues.DropRuleIdColumnOfIssuesTable; -import org.sonar.server.platform.db.migration.version.v83.rules.issues.PopulateIssuesRuleUuidColumn; -import org.sonar.server.platform.db.migration.version.v83.rules.rulesmetadata.AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTable; -import org.sonar.server.platform.db.migration.version.v83.rules.rulesmetadata.AddRuleUuidColumnToRulesMetadataTable; -import org.sonar.server.platform.db.migration.version.v83.rules.rulesmetadata.DropPrimaryKeyOnIdColumnOfRulesMetadataTable; -import org.sonar.server.platform.db.migration.version.v83.rules.rulesmetadata.DropRuleIdColumnOfRulesMetadataTable; -import org.sonar.server.platform.db.migration.version.v83.rules.rulesmetadata.MakeRulesMetadataRuleUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v83.rules.rulesmetadata.PopulateRulesMetadataRuleUuidColumn; -import org.sonar.server.platform.db.migration.version.v83.rules.rulesparameters.AddIndexesToRulesParametersTable; -import org.sonar.server.platform.db.migration.version.v83.rules.rulesparameters.AddRuleUuidColumnToRulesParametersTable; -import org.sonar.server.platform.db.migration.version.v83.rules.rulesparameters.DropIndexesOnRuleIdColumnOfRulesParametersTable; -import org.sonar.server.platform.db.migration.version.v83.rules.rulesparameters.DropRuleIdColumnOfRulesParametersTable; -import org.sonar.server.platform.db.migration.version.v83.rules.rulesparameters.MakeRulesParametersRuleUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v83.rules.rulesparameters.PopulateRulesParametersRuleUuidColumn; -import org.sonar.server.platform.db.migration.version.v83.rulesparameters.AddPrimaryKeyOnUuidColumnOfRulesParametersTable; -import org.sonar.server.platform.db.migration.version.v83.rulesparameters.AddUuidColumnToRulesParameters; -import org.sonar.server.platform.db.migration.version.v83.rulesparameters.DropIdColumnOfRulesParametersTable; -import org.sonar.server.platform.db.migration.version.v83.rulesparameters.DropPrimaryKeyOnIdColumnOfRulesParametersTable; -import org.sonar.server.platform.db.migration.version.v83.rulesparameters.MakeRulesParametersUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v83.rulesparameters.PopulateRulesParametersUuid; -import org.sonar.server.platform.db.migration.version.v83.rulesparameters.fk.AddRulesParameterUuidColumnToActiveRuleParameters; -import org.sonar.server.platform.db.migration.version.v83.rulesparameters.fk.DropRulesParameterIdColumnOfActiveRuleParametersTable; -import org.sonar.server.platform.db.migration.version.v83.rulesparameters.fk.MakeActiveRuleParametersRulesParameterUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v83.rulesparameters.fk.PopulateActiveRuleParametersRulesParameterUuid; -import org.sonar.server.platform.db.migration.version.v83.rulesprofiles.AddPrimaryKeyOnUuidColumnOfRulesProfilesTable; -import org.sonar.server.platform.db.migration.version.v83.rulesprofiles.AddUuidColumnToRulesProfilesTable; -import org.sonar.server.platform.db.migration.version.v83.rulesprofiles.DropIdColumnOfRulesProfilesTable; -import org.sonar.server.platform.db.migration.version.v83.rulesprofiles.DropKeeColumnOfRulesProfilesTable; -import org.sonar.server.platform.db.migration.version.v83.rulesprofiles.DropPrimaryKeyOnIdColumnOfRulesProfilesTable; -import org.sonar.server.platform.db.migration.version.v83.rulesprofiles.DropUniqueIndexOnKeeColumnOfRulesProfilesTable; -import org.sonar.server.platform.db.migration.version.v83.rulesprofiles.MakeRulesProfilesUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v83.rulesprofiles.PopulateRulesProfilesUuid; -import org.sonar.server.platform.db.migration.version.v83.rulesprofiles.fk.activerules.AddProfileUuidColumnToActiveRulesTable; -import org.sonar.server.platform.db.migration.version.v83.rulesprofiles.fk.activerules.AddUniqueIndexOnProfileUuidColumnOfActiveRulesTable; -import org.sonar.server.platform.db.migration.version.v83.rulesprofiles.fk.activerules.DropProfileIdColumnOfActiveRulesTable; -import org.sonar.server.platform.db.migration.version.v83.rulesprofiles.fk.activerules.DropUniqueIndexOnProfileIdColumnOfActiveRulesTable; -import org.sonar.server.platform.db.migration.version.v83.rulesprofiles.fk.activerules.MakeActiveRulesProfileUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v83.rulesprofiles.fk.activerules.PopulateActiveRulesProfileUuid; -import org.sonar.server.platform.db.migration.version.v83.rulesprofiles.fk.orgqprofiles.PopulateOrgQProfilesRulesProfileUuid; -import org.sonar.server.platform.db.migration.version.v83.rulesprofiles.fk.qprofilechanges.PopulateQProfileChangesRulesProfileUuid; -import org.sonar.server.platform.db.migration.version.v83.snapshots.issues.AddPrimaryKeyOnUuidColumnOfSnapshotsTable; -import org.sonar.server.platform.db.migration.version.v83.snapshots.issues.DropIdColumnOfSnapshotsTable; -import org.sonar.server.platform.db.migration.version.v83.snapshots.issues.DropPrimaryKeyOnIdColumnOfSnapshotsTable; import org.sonar.server.platform.db.migration.version.v83.userroles.AddComponentUuidColumnToUserRoles; -import org.sonar.server.platform.db.migration.version.v83.userroles.AddPrimaryKeyOnUuidColumnOfUserRolesTable; -import org.sonar.server.platform.db.migration.version.v83.userroles.AddUuidColumnToUserRolesTable; -import org.sonar.server.platform.db.migration.version.v83.userroles.DropIdColumnOfUserRolesTable; -import org.sonar.server.platform.db.migration.version.v83.userroles.DropPrimaryKeyOnIdColumnOfUserRolesTable; import org.sonar.server.platform.db.migration.version.v83.userroles.DropResourceIdFromUserRolesTable; -import org.sonar.server.platform.db.migration.version.v83.userroles.MakeUserRolesUuidColumnNotNullable; import org.sonar.server.platform.db.migration.version.v83.userroles.MigrateResourceIdToUuidInUserRoles; -import org.sonar.server.platform.db.migration.version.v83.userroles.PopulateUserRolesUuid; -import org.sonar.server.platform.db.migration.version.v83.users.AddPrimaryKeyOnUuidColumnOfUsersTable; -import org.sonar.server.platform.db.migration.version.v83.users.DropIdColumnOfUsersTable; -import org.sonar.server.platform.db.migration.version.v83.users.DropPrimaryKeyOnIdColumnOfUsersTable; -import org.sonar.server.platform.db.migration.version.v83.users.DropUniqueIndexOnUuidColumnOfUsersTable; -import org.sonar.server.platform.db.migration.version.v83.users.fk.groupsusers.AddIndexOnUserUuidOfGroupsUsersTable; -import org.sonar.server.platform.db.migration.version.v83.users.fk.groupsusers.AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTable; -import org.sonar.server.platform.db.migration.version.v83.users.fk.groupsusers.AddUserUuidColumnToGroupsUsers; -import org.sonar.server.platform.db.migration.version.v83.users.fk.groupsusers.DropIndexOnUserIdOfGroupsUsersTable; -import org.sonar.server.platform.db.migration.version.v83.users.fk.groupsusers.DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTable; -import org.sonar.server.platform.db.migration.version.v83.users.fk.groupsusers.DropUserIdColumnOfGroupsUsersTable; -import org.sonar.server.platform.db.migration.version.v83.users.fk.groupsusers.MakeGroupsUsersUserUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v83.users.fk.groupsusers.PopulateGroupsUsersUserUuid; -import org.sonar.server.platform.db.migration.version.v83.users.fk.organizationmembers.AddIndexOnUserUuidOfOrganizationMembersTable; -import org.sonar.server.platform.db.migration.version.v83.users.fk.organizationmembers.AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTable; -import org.sonar.server.platform.db.migration.version.v83.users.fk.organizationmembers.AddUserUuidColumnToOrganizationMembers; -import org.sonar.server.platform.db.migration.version.v83.users.fk.organizationmembers.DropIndexOnUserIdOfOrganizationMembersTable; -import org.sonar.server.platform.db.migration.version.v83.users.fk.organizationmembers.DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTable; -import org.sonar.server.platform.db.migration.version.v83.users.fk.organizationmembers.DropUserIdColumnOfOrganizationMembersTable; -import org.sonar.server.platform.db.migration.version.v83.users.fk.organizationmembers.MakeOrganizationMembersUserUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v83.users.fk.organizationmembers.PopulateOrganizationMembersUserUuid; -import org.sonar.server.platform.db.migration.version.v83.users.fk.permtemplatesusers.AddUserUuidColumnToPermTemplatesUsers; -import org.sonar.server.platform.db.migration.version.v83.users.fk.permtemplatesusers.DropUserIdColumnOfPermTemplatesUsersTable; -import org.sonar.server.platform.db.migration.version.v83.users.fk.permtemplatesusers.MakePermTemplatesUsersUserUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v83.users.fk.permtemplatesusers.PopulatePermTemplatesUsersUserUuid; -import org.sonar.server.platform.db.migration.version.v83.users.fk.properties.AddUserUuidColumnToPropertiesUsers; -import org.sonar.server.platform.db.migration.version.v83.users.fk.properties.DropUserIdColumnOfPropertiesTable; -import org.sonar.server.platform.db.migration.version.v83.users.fk.properties.PopulatePropertiesUserUuid; -import org.sonar.server.platform.db.migration.version.v83.users.fk.qprofileeditusers.AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTable; -import org.sonar.server.platform.db.migration.version.v83.users.fk.qprofileeditusers.AddUserUuidColumnToQProfileEditUsers; -import org.sonar.server.platform.db.migration.version.v83.users.fk.qprofileeditusers.DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTable; -import org.sonar.server.platform.db.migration.version.v83.users.fk.qprofileeditusers.DropUserIdColumnOfQProfileEditUsersTable; -import org.sonar.server.platform.db.migration.version.v83.users.fk.qprofileeditusers.MakeQProfileEditUsersUserUuidColumnNotNullable; -import org.sonar.server.platform.db.migration.version.v83.users.fk.qprofileeditusers.PopulateQProfileEditUsersUserUuid; -import org.sonar.server.platform.db.migration.version.v83.users.fk.userroles.AddIndexOnUserUuidOfUserRolesTable; -import org.sonar.server.platform.db.migration.version.v83.users.fk.userroles.AddUserUuidColumnToUserRoles; -import org.sonar.server.platform.db.migration.version.v83.users.fk.userroles.DropIndexOnUserIdOfUserRolesTable; -import org.sonar.server.platform.db.migration.version.v83.users.fk.userroles.DropUserIdColumnOfUserRolesTable; -import org.sonar.server.platform.db.migration.version.v83.users.fk.userroles.PopulateUserRolesUserUuid; -import org.sonar.server.platform.db.migration.version.v83.usertokens.AddPrimaryKeyOnUuidColumnOfUserTokensTable; -import org.sonar.server.platform.db.migration.version.v83.usertokens.AddUuidColumnToUserTokens; -import org.sonar.server.platform.db.migration.version.v83.usertokens.DropIdColumnOfUserTokensTable; -import org.sonar.server.platform.db.migration.version.v83.usertokens.DropPrimaryKeyOnIdColumnOfUserTokensTable; -import org.sonar.server.platform.db.migration.version.v83.usertokens.MakeUserTokensUuidNotNullable; -import org.sonar.server.platform.db.migration.version.v83.usertokens.PopulateUserTokensUuid; public class DbVersion83 implements DbVersion { @Override @@ -358,446 +48,6 @@ public class DbVersion83 implements DbVersion { .add(3310, "Remove column 'resource_id' in 'user_roles'", DropResourceIdFromUserRolesTable.class) .add(3311, "Remove column 'id' in 'components'", DropIdFromComponentsTable.class) - // Migration on EVENTS table - .add(3400, "Drop primary key on 'ID' column of 'EVENTS' table", DropPrimaryKeyOnIdColumnOfEventsTable.class) - .add(3401, "Add primary key on 'UUID' column of 'EVENTS' table", AddPrimaryKeyOnUuidColumnOfEventsTable.class) - .add(3402, "Drop column 'ID' of 'EVENTS' table", DropIdColumnOfEventsTable.class) - - // Migrations of NOTIFICATIONS table - .add(3403, "Add 'uuid' and 'createdAt' columns for notifications", AddUuidAndCreatedAtColumnsToNotification.class) - .add(3404, "Populate 'uuid' and 'createdAt columns for notifications", PopulateNotificationUuidAndCreatedAt.class) - .add(3405, "Make 'uuid' and 'createdAt' column not nullable for notifications", MakeNotificationUuidAndCreatedAtColumnsNotNullable.class) - .add(3406, "Drop primary key on 'ID' column of 'NOTIFICATIONS' table", DropPrimaryKeyOnIdColumnOfNotificationTable.class) - .add(3407, "Add primary key on 'UUID' column of 'NOTIFICATIONS' table", AddPrimaryKeyOnUuidColumnOfNotificationTable.class) - .add(3408, "Drop column 'ID' of 'NOTIFICATIONS' table", DropIdColumnOfNotificationTable.class) - - // Migration on ISSUES table - .add(3409, "Drop primary key on 'ID' column of 'ISSUES' table", DropPrimaryKeyOnIdColumnOfIssuesTable.class) - .add(3410, "Add primary key on 'KEE' column of 'ISSUES' table", AddPrimaryKeyOnKeeColumnOfIssuesTable.class) - .add(3411, "Drop column 'ID' of 'ISSUES' table", DropIdColumnOfIssuesTable.class) - - // Migration on SNAPSHOTS table - .add(3412, "Drop primary key on 'ID' column of 'SNAPSHOTS' table", DropPrimaryKeyOnIdColumnOfSnapshotsTable.class) - .add(3413, "Add primary key on 'UUID' column of 'SNAPSHOTS' table", AddPrimaryKeyOnUuidColumnOfSnapshotsTable.class) - .add(3414, "Drop column 'ID' of 'SNAPSHOTS' table", DropIdColumnOfSnapshotsTable.class) - - // Migration on CE_QUEUE table - .add(3415, "Drop unique index on 'uuid' column of 'CE_QUEUE' table", DropUniqueIndexOnUuidColumnOfCeQueueTable.class) - .add(3416, "Drop primary key on 'ID' column of 'CE_QUEUE' table", DropPrimaryKeyOnIdColumnOfCeQueueTable.class) - .add(3417, "Add primary key on 'UUID' column of 'CE_QUEUE' table", AddPrimaryKeyOnUuidColumnOfCeQueueTable.class) - .add(3418, "Drop column 'ID' of 'CE_QUEUE' table", DropIdColumnOfCeQueueTable.class) - - // Migration on CE_ACTIVITY table - .add(3419, "Drop primary key on 'ID' column of 'CE_ACTIVITY' table", DropPrimaryKeyOnIdColumnOfCeActivityTable.class) - .add(3420, "Add primary key on 'UUID' column of 'CE_ACTIVITY' table", AddPrimaryKeyOnUuidColumnOfCeActivityTable.class) - .add(3421, "Drop column 'ID' of 'CE_ACTIVITY' table", DropIdColumnOfCeActivityTable.class) - - // Migration of DUPLICATIONS_INDEX table - .add(3422, "Add 'uuid' columns for DUPLICATIONS_INDEX", AddUuidToDuplicationsIndexTable.class) - .add(3423, "Populate 'uuid' columns for DUPLICATIONS_INDEX", PopulateDuplicationsIndexUuid.class) - .add(3424, "Make 'uuid' column not nullable for DUPLICATIONS_INDEX", MakeDuplicationsIndexUuidColumnNotNullable.class) - .add(3425, "Drop primary key on 'ID' column of 'DUPLICATIONS_INDEX' table", DropPrimaryKeyOnIdColumnOfDuplicationsIndexTable.class) - .add(3426, "Add primary key on 'UUID' column of 'DUPLICATIONS_INDEX' table", AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTable.class) - .add(3427, "Drop column 'ID' of 'DUPLICATIONS_INDEX' table", DropIdColumnOfDuplicationsIndexTable.class) - - // Migration of ACTIVE_RULE_PARAMS table - .add(3428, "Add 'uuid' column for 'ACTIVE_RULE_PARAMS' table", AddUuidColumnToActiveRuleParametersTable.class) - .add(3429, "Populate 'uuid' column for 'ACTIVE_RULE_PARAMS' table", PopulateActiveRuleParametersUuid.class) - .add(3430, "Make 'uuid' column not nullable for 'ACTIVE_RULE_PARAMS' table", MakeActiveRuleParametersUuidColumnNotNullable.class) - .add(3431, "Drop primary key on 'ID' column of 'ACTIVE_RULE_PARAMS' table", DropPrimaryKeyOnIdColumnOfActiveRuleParametersTable.class) - .add(3432, "Add primary key on 'UUID' column of 'ACTIVE_RULE_PARAMS' table", AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTable.class) - .add(3433, "Drop column 'ID' of 'ACTIVE_RULE_PARAMS' table", DropIdColumnOfActiveRuleParametersTable.class) - - // Migration on PROJECT_MEASURES table - .add(3434, "Add 'uuid' columns for 'PROJECT_MEASURES'", AddUuidColumnToProjectMeasures.class) - .add(3435, "Populate 'uuid' column for 'PROJECT_MEASURES'", PopulateProjectMeasureUuid.class) - .add(3436, "Make 'uuid' column not nullable for 'PROJECT_MEASURES'", MakeProjectMeasuresUuidColumnNotNullable.class) - .add(3437, "Drop primary key on 'ID' column of 'PROJECT_MEASURES' table", DropPrimaryKeyOnIdColumnOfProjectMeasuresTable.class) - .add(3438, "Add primary key on 'UUID' column of 'PROJECT_MEASURES' table", AddPrimaryKeyOnUuidColumnOfProjectMeasuresTable.class) - .add(3439, "Drop column 'ID' of 'PROJECT_MEASURES' table", DropIdColumnOfProjectMeasuresTable.class) - - // Migration of USER_TOKENS table - .add(3440, "Add 'UUID' column on 'USER_TOKENS' table", AddUuidColumnToUserTokens.class) - .add(3441, "Populate 'uuid' for 'USER_TOKENS'", PopulateUserTokensUuid.class) - .add(3442, "Make 'uuid' column not nullable for user_tokens", MakeUserTokensUuidNotNullable.class) - .add(3443, "Drop primary key on 'ID' column of 'USER_TOKENS' table", DropPrimaryKeyOnIdColumnOfUserTokensTable.class) - .add(3444, "Add primary key on 'UUID' column of 'USER_TOKENS' table", AddPrimaryKeyOnUuidColumnOfUserTokensTable.class) - .add(3445, "Drop column 'ID' of 'USER_TOKENS' table", DropIdColumnOfUserTokensTable.class) - - // Migration on PROJECT_QPROFILES table - .add(3446, "Add 'uuid' column for 'PROJECT_QPROFILES'", AddUuidColumnToProjectQProfilesTable.class) - .add(3447, "Populate 'uuid' column for 'PROJECT_QPROFILES'", PopulateProjectQProfilesUuid.class) - .add(3448, "Make 'uuid' column not nullable for 'PROJECT_QPROFILES'", MakeProjectQProfilesUuidColumnNotNullable.class) - .add(3449, "Drop primary key on 'ID' column of 'PROJECT_QPROFILES' table", DropPrimaryKeyOnIdColumnOfProjectQProfilesTable.class) - .add(3450, "Add primary key on 'UUID' column of 'PROJECT_QPROFILES' table", AddPrimaryKeyOnUuidColumnOfProjectQProfilesTable.class) - .add(3451, "Drop column 'ID' of 'PROJECT_QPROFILES' table", DropIdColumnOfProjectQProfilesTable.class) - - // Migration of MANUAL_MEASURES table - .add(3452, "Add 'uuid' column for 'MANUAL_MEASURES'", AddUuidColumnToManualMeasures.class) - .add(3453, "Populate 'uuid' column for 'MANUAL_MEASURES'", PopulateManualMeasureUuid.class) - .add(3454, "Make 'uuid' column not nullable for 'MANUAL_MEASURES'", MakeManualMeasuresUuidColumnNotNullable.class) - .add(3455, "Drop primary key on 'ID' column of 'MANUAL_MEASURES' table", DropPrimaryKeyOnIdColumnOfManualMeasuresTable.class) - .add(3456, "Add primary key on 'UUID' column of 'MANUAL_MEASURES' table", AddPrimaryKeyOnUuidColumnOfManualMeasuresTable.class) - .add(3457, "Drop column 'ID' of 'MANUAL_MEASURES' table", DropIdColumnOfManualMeasuresTable.class) - - // Migration of GROUP_ROLES table - .add(3458, "Add 'UUID' column on 'GROUP_ROLES' table", AddUuidColumnToGroupRolesTable.class) - .add(3459, "Populate 'uuid' for 'GROUP_ROLES'", PopulateGroupRolesUuid.class) - .add(3460, "Make 'uuid' column not nullable for 'GROUP_ROLES'", MakeGroupRolesUuidColumnNotNullable.class) - .add(3461, "Drop primary key on 'ID' column of 'GROUP_ROLES' table", DropPrimaryKeyOnIdColumnOfGroupRolesTable.class) - .add(3462, "Add primary key on 'UUID' column of 'GROUP_ROLES' table", AddPrimaryKeyOnUuidColumnOfGroupRolesTable.class) - .add(3463, "Drop column 'ID' of 'GROUP_ROLES' table", DropIdColumnOfGroupRolesTable.class) - - // Migration of USER_ROLES table - .add(3464, "Add 'UUID' column on 'USER_ROLES' table", AddUuidColumnToUserRolesTable.class) - .add(3465, "Populate 'uuid' for 'USER_ROLES'", PopulateUserRolesUuid.class) - .add(3466, "Make 'uuid' column not nullable for 'USER_ROLES'", MakeUserRolesUuidColumnNotNullable.class) - .add(3467, "Drop primary key on 'ID' column of 'USER_ROLES' table", DropPrimaryKeyOnIdColumnOfUserRolesTable.class) - .add(3468, "Add primary key on 'UUID' column of 'USER_ROLES' table", AddPrimaryKeyOnUuidColumnOfUserRolesTable.class) - .add(3469, "Drop column 'ID' of 'USER_ROLES' table", DropIdColumnOfUserRolesTable.class) - - // Migration of FILE_SOURCES table - .add(3470, "Add 'UUID' column on 'FILE_SOURCES' table", AddUuidColumnToFileSourcesTable.class) - .add(3471, "Populate 'uuid' for 'FILE_SOURCES'", PopulateFileSourcesUuid.class) - .add(3472, "Make 'uuid' column not nullable for 'FILE_SOURCES'", MakeFileSourcesUuidColumnNotNullable.class) - .add(3473, "Drop primary key on 'ID' column of 'FILE_SOURCES' table", DropPrimaryKeyOnIdColumnOfFileSourcesTable.class) - .add(3474, "Add primary key on 'UUID' column of 'FILE_SOURCES' table", AddPrimaryKeyOnUuidColumnOfFileSourcesTable.class) - .add(3475, "Drop column 'ID' of 'FILE_SOURCES' table", DropIdColumnOfFileSourcesTable.class) - - // Migration of ISSUE_CHANGES table - .add(3476, "Add 'UUID' column on 'ISSUE_CHANGES' table", AddUuidColumnToIssueChangesTable.class) - .add(3477, "Populate 'uuid' for 'ISSUE_CHANGES'", PopulateIssueChangesUuid.class) - .add(3478, "Make 'uuid' column not nullable for 'ISSUE_CHANGES'", MakeIssueChangesUuidColumnNotNullable.class) - .add(3479, "Drop primary key on 'ID' column of 'ISSUE_CHANGES' table", DropPrimaryKeyOnIdColumnOfIssueChangesTable.class) - .add(3480, "Add primary key on 'UUID' column of 'ISSUE_CHANGES' table", AddPrimaryKeyOnUuidColumnOfIssueChangesTable.class) - .add(3481, "Drop column 'ID' of 'ISSUE_CHANGES' table", DropIdColumnOfIssueChangesTable.class) - - // Migration of QUALITY_GATE_CONDITIONS table - .add(3482, "Add 'UUID' column on 'QUALITY_GATE_CONDITIONS' table", AddUuidColumnToQualityGateConditionsTable.class) - .add(3483, "Populate 'uuid' for 'QUALITY_GATE_CONDITIONS'", PopulateQualityGateConditionsUuid.class) - .add(3484, "Make 'uuid' column not nullable for 'QUALITY_GATE_CONDITIONS'", MakeQualityGateConditionsUuidColumnNotNullable.class) - .add(3485, "Drop primary key on 'ID' column of 'QUALITY_GATE_CONDITIONS' table", DropPrimaryKeyOnIdColumnOfQualityGateConditionsTable.class) - .add(3486, "Add primary key on 'UUID' column of 'QUALITY_GATE_CONDITIONS' table", AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTable.class) - .add(3487, "Drop column 'ID' of 'QUALITY_GATE_CONDITIONS' table", DropIdColumnOfQualityGateConditionsTable.class) - - // Migration of PERM_TEMPLATES_GROUPS table - .add(3488, "Add 'UUID' column on 'PERM_TEMPLATES_GROUPS' table", AddUuidColumnToPermTemplatesGroupsTable.class) - .add(3489, "Populate 'uuid' for 'PERM_TEMPLATES_GROUPS'", PopulatePermTemplatesGroupsUuid.class) - .add(3490, "Make 'uuid' column not nullable for 'PERM_TEMPLATES_GROUPS'", MakePermTemplatesGroupsUuidColumnNotNullable.class) - .add(3491, "Drop primary key on 'ID' column of 'PERM_TEMPLATES_GROUPS' table", DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTable.class) - .add(3492, "Add primary key on 'UUID' column of 'PERM_TEMPLATES_GROUPS' table", AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTable.class) - .add(3493, "Drop column 'ID' of 'PERM_TEMPLATES_GROUPS' table", DropIdColumnOfPermTemplatesGroupsTable.class) - - // Migration of PERM_TPL_CHARACTERISTICS table - .add(3494, "Add 'UUID' column on 'PERM_TPL_CHARACTERISTICS' table", AddUuidColumnToPermTplCharacteristicsTable.class) - .add(3495, "Populate 'uuid' for 'PERM_TPL_CHARACTERISTICS'", PopulatePermTplCharacteristicsUuid.class) - .add(3496, "Make 'uuid' column not nullable for 'PERM_TPL_CHARACTERISTICS'", MakePermTplCharacteristicsUuidColumnNotNullable.class) - .add(3497, "Drop primary key on 'ID' column of 'PERM_TPL_CHARACTERISTICS' table", DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTable.class) - .add(3498, "Add primary key on 'UUID' column of 'PERM_TPL_CHARACTERISTICS' table", AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTable.class) - .add(3499, "Drop column 'ID' of 'PERM_TPL_CHARACTERISTICS' table", DropIdColumnOfPermTplCharacteristicsTable.class) - - // Migration of PERM_TEMPLATES_USERS table - .add(3500, "Add 'UUID' column on 'PERM_TEMPLATES_USERS' table", AddUuidColumnToPermTemplatesUsersTable.class) - .add(3501, "Populate 'uuid' for 'PERM_TEMPLATES_USERS'", PopulatePermTemplatesUsersUuid.class) - .add(3502, "Make 'uuid' column not nullable for 'PERM_TEMPLATES_USERS'", MakePermTemplatesUsersUuidColumnNotNullable.class) - .add(3503, "Drop primary key on 'ID' column of 'PERM_TEMPLATES_USERS' table", DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTable.class) - .add(3504, "Add primary key on 'UUID' column of 'PERM_TEMPLATES_USERS' table", AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTable.class) - .add(3505, "Drop column 'ID' of 'PERM_TEMPLATES_USERS' table", DropIdColumnOfPermTemplatesUsersTable.class) - - // Migration of ACTIVE_RULES table - .add(3506, "Add 'UUID' column on 'ACTIVE_RULES' table", AddUuidColumnToActiveRulesTable.class) - .add(3507, "Populate 'uuid' for 'ACTIVE_RULES'", PopulateActiveRulesUuid.class) - .add(3508, "Make 'uuid' column not nullable for 'ACTIVE_RULES'", MakeActiveRulesUuidColumnNotNullable.class) - - // Migration of FK in ACTIVE_RULE_PARAMETERS to ACTIVE_RULES - .add(3509, "Add 'active_rule_uuid' column on 'ACTIVE_RULE_PARAMETERS' table", AddActiveRuleUuidColumnToActiveRuleParameters.class) - .add(3510, "Populate 'active_rule_uuid' for 'ACTIVE_RULE_PARAMETERS'", PopulateActiveRuleParametersActiveRuleUuid.class) - .add(3511, "Make 'active_rule_uuid' column not nullable for 'ACTIVE_RULE_PARAMETERS'", MakeActiveRuleParametersActiveRuleUuidNotNullable.class) - .add(3512, "Drop index on 'active_rule_id' column of 'ACTIVE_RULE_PARAMETERS' table", DropIndexOnActiveRuleIdOfActiveRuleParametersTable.class) - .add(3513, "Add index on 'active_rule_uuid' column of 'ACTIVE_RULE_PARAMETERS' table", AddIndexOnActiveRuleUuidOfActiveRuleParametersTable.class) - - // Finish migration of ACTIVE_RULES - .add(3514, "Drop primary key on 'ID' column of 'ACTIVE_RULES' table", DropPrimaryKeyOnIdColumnOfActiveRulesTable.class) - .add(3515, "Add primary key on 'UUID' column of 'ACTIVE_RULES' table", AddPrimaryKeyOnUuidColumnOfActiveRulesTable.class) - .add(3516, "Drop column 'ID' of 'ACTIVE_RULES' table", DropIdColumnOfActiveRulesTable.class) - .add(3517, "Drop column 'active_rule_id' of 'ACTIVE_RULE_PARAMETERS' table", DropActiveRuleIdColumnOfActiveRuleParametersTable.class) - - // Migration on RULES_PARAMETERS table - populate uuid column - .add(3518, "Add 'uuid' column for 'RULES_PARAMETERS'", AddUuidColumnToRulesParameters.class) - .add(3519, "Populate 'uuid' column for 'RULES_PARAMETERS'", PopulateRulesParametersUuid.class) - .add(3520, "Make 'uuid' column not nullable for 'RULES_PARAMETERS'", MakeRulesParametersUuidColumnNotNullable.class) - - // Migration of ACTIVE_RULE_PARAMS FK to RULES_PARAMETERS, switch from ruleParamId to ruleParamUuid - .add(3521, "Add 'rules_parameter_uuid' column for 'ACTIVE_RULE_PARAMS' table", AddRulesParameterUuidColumnToActiveRuleParameters.class) - .add(3522, "Populate 'rules_parameter_uuid' column for 'ACTIVE_RULE_PARAMS' table", PopulateActiveRuleParametersRulesParameterUuid.class) - .add(3523, "Make 'rules_parameter_uuid' column not nullable for 'ACTIVE_RULE_PARAMS' table", MakeActiveRuleParametersRulesParameterUuidColumnNotNullable.class) - .add(3524, "Drop column 'rules_parameter_id' of 'ACTIVE_RULE_PARAMS' table", DropRulesParameterIdColumnOfActiveRuleParametersTable.class) - - // Migration on RULES_PARAMETERS table change PK - .add(3525, "Drop primary key on 'ID' column of 'RULES_PARAMETERS' table", DropPrimaryKeyOnIdColumnOfRulesParametersTable.class) - .add(3526, "Add primary key on 'UUID' column of 'RULES_PARAMETERS' table", AddPrimaryKeyOnUuidColumnOfRulesParametersTable.class) - .add(3527, "Drop column 'ID' of 'RULES_PARAMETERS' table", DropIdColumnOfRulesParametersTable.class) - - // Migration of METRICS table - .add(3528, "Add 'UUID' column on 'METRICS' table", AddUuidColumnToMetricsTable.class) - .add(3529, "Populate 'uuid' for 'METRICS'", PopulateMetricsUuid.class) - .add(3530, "Make 'uuid' column not nullable for 'METRICS'", MakeMetricsUuidColumnNotNullable.class) - - // Migration of FK in PROJECT_MEASURES to METRICS - .add(3531, "Add 'metric_uuid' column on 'PROJECT_MEASURES' table", AddMetricUuidColumnToProjectMeasures.class) - .add(3532, "Populate 'metric_uuid' for 'PROJECT_MEASURES'", PopulateProjectMeasuresMetricUuid.class) - .add(3533, "Make 'metric_uuid' column not nullable for 'PROJECT_MEASURES'", MakeProjectMeasuresMetricUuidNotNullable.class) - .add(3534, "Drop index on 'metric_id' and 'analysis_uuid' columns of 'PROJECT_MEASURES' table", DropIndexOnMetricIdOfProjectMeasuresTable.class) - .add(3535, "Add index on 'metric_uuid' and 'analysis_uuid' columns of 'PROJECT_MEASURES' table", AddIndexOnMetricUuidOfProjectMeasuresTable.class) - - // Migration of FK in QUALITY_GATE_CONDITIONS to METRICS - .add(3536, "Add 'metric_uuid' column on 'QUALITY_GATE_CONDITIONS' table", AddMetricUuidColumnToQualityGateConditions.class) - .add(3537, "Populate 'metric_uuid' for 'QUALITY_GATE_CONDITIONS'", PopulateQualityGateConditionsMetricUuid.class) - .add(3538, "Make 'metric_uuid' column not nullable for 'QUALITY_GATE_CONDITIONS'", MakeQualityGateConditionsMetricUuidNotNullable.class) - - // Migration of FK in LIVE_MEASURES to METRICS - .add(3539, "Add 'metric_uuid' column on 'LIVE_MEASURES' table", AddMetricUuidColumnToLiveMeasures.class) - .add(3540, "Populate 'metric_uuid' for 'LIVE_MEASURES'", PopulateLiveMeasuresMetricUuid.class) - .add(3541, "Make 'metric_uuid' column not nullable for 'LIVE_MEASURES'", MakeLiveMeasuresMetricUuidNotNullable.class) - .add(3542, "Drop index on 'metric_id' column of 'LIVE_MEASURES' table", DropIndexOnMetricIdOfLiveMeasuresTable.class) - .add(3543, "Add index on 'metric_uuid' column of 'LIVE_MEASURES' table", AddIndexOnMetricUuidOfLiveMeasuresTable.class) - - // Migration of FK in MANUAL_MEASURES to METRICS - .add(3544, "Add 'metric_uuid' column on 'MANUAL_MEASURES' table", AddMetricUuidColumnToManualMeasures.class) - .add(3545, "Populate 'metric_uuid' for 'MANUAL_MEASURES'", PopulateManualMeasuresMetricUuid.class) - .add(3546, "Make 'metric_uuid' column not nullable for 'MANUAL_MEASURES'", MakeManualMeasuresMetricUuidNotNullable.class) - - // Finish migration of METRICS - .add(3547, "Drop primary key on 'ID' column of 'METRICS' table", DropPrimaryKeyOnIdColumnOfMetricsTable.class) - .add(3548, "Add primary key on 'UUID' column of 'METRICS' table", AddPrimaryKeyOnUuidColumnOfMetricsTable.class) - .add(3549, "Drop column 'METRIC_ID' of 'PROJECT_MEASURES' table", DropMetricIdColumnOfProjectMeasuresTable.class) - .add(3550, "Drop column 'METRIC_ID' of 'QUALITY_GATE_CONDITIONS' table", DropMetricIdColumnOfQualityGateConditionsTable.class) - .add(3551, "Drop column 'METRIC_ID' of 'LIVE_MEASURES' table", DropMetricIdColumnOfLiveMeasuresTable.class) - .add(3552, "Drop column 'METRIC_ID' of 'MANUAL_MEASURES' table", DropMetricIdColumnOfManualMeasuresTable.class) - .add(3553, "Drop column 'ID' of 'METRICS' table", DropIdColumnOfMetricsTable.class) - - // Migration of PERMISSION_TEMPLATES table - .add(3554, "Add 'UUID' column on 'PERMISSION_TEMPLATES' table", AddUuidColumnToPermissionTemplates.class) - .add(3555, "Populate 'uuid' for 'PERMISSION_TEMPLATES'", PopulatePermissionTemplatesUuid.class) - .add(3556, "Make 'uuid' column not nullable for user_tokens", MakePermissionTemplateUuidColumnNotNullable.class) - - // Migration of PERM_TEMPLATES_GROUPS FK to PERMISSION_TEMPLATES, switch from templateId to templateUuid - .add(3557, "Add 'template_uuid' column for 'PERM_TEMPLATES_GROUPS' table", AddTemplateUuidColumnToPermTemplatesGroups.class) - .add(3558, "Populate 'template_uuid' column for 'PERM_TEMPLATES_GROUPS' table", PopulatePermTemplatesGroupsTemplateUuidColumn.class) - .add(3559, "Make 'template_uuid' column not nullable for 'PERM_TEMPLATES_GROUPS' table", MakePermTemplatesGroupsTemplateUuidColumnNotNullable.class) - .add(3560, "Drop column 'template_id' of 'PERM_TEMPLATES_GROUPS' table", DropTemplateIdColumnOfPermTemplatesGroupsTable.class) - - // Migration of PERM_TEMPLATES_USERS FK to PERMISSION_TEMPLATES, switch from templateId to templateUuid - .add(3561, "Add 'template_uuid' column for 'PERM_TEMPLATES_USERS' table", AddTemplateUuidColumnToPermTemplatesUsers.class) - .add(3562, "Populate 'template_uuid' column for 'PERM_TEMPLATES_USERS' table", PopulatePermTemplatesUsersTemplateUuidColumn.class) - .add(3563, "Make 'template_uuid' column not nullable for 'PERM_TEMPLATES_USERS' table", MakePermTemplatesUsersTemplateUuidColumnNotNullable.class) - .add(3564, "Drop column 'template_id' of 'PERM_TEMPLATES_USERS' table", DropTemplateIdColumnOfPermTemplatesUsersTable.class) - - // Migration of PERM_TPL_CHARACTERISTICS FK to PERMISSION_TEMPLATES, switch from templateId to templateUuid - .add(3565, "Add 'template_uuid' column for 'PERM_TPL_CHARACTERISTICS' table", AddTemplateUuidColumnToPermTplCharacteristics.class) - .add(3566, "Populate 'template_uuid' column for 'PERM_TPL_CHARACTERISTICS' table", PopulatePermTplCharacteristicsTemplateUuidColumn.class) - .add(3567, "Make 'template_uuid' column not nullable for 'PERM_TPL_CHARACTERISTICS' table", MakePermTplCharacteristicsTemplateUuidColumnNotNullable.class) - .add(3568, "Drop unique constraint on 'template_id', 'permission_key' columns 'PERM_TPL_CHARACTERISTICS' table", - DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTable.class) - .add(3569, "Add unique constraint on 'template_uuid', 'permission_key' columns 'PERM_TPL_CHARACTERISTICS' table", - AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTable.class) - - .add(3570, "Drop column 'template_id' of 'PERM_TPL_CHARACTERISTICS' table", DropTemplateIdColumnOfPermTplCharacteristicsTable.class) - - .add(3571, "Drop primary key on 'ID' column of 'PERMISSION_TEMPLATES' table", DropPrimaryKeyOnIdColumnOfPermissionTemplatesTable.class) - .add(3572, "Add primary key on 'UUID' column of 'PERMISSION_TEMPLATES' table", AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTable.class) - - .add(3573, "Drop column 'ID' of 'PERMISSION_TEMPLATES' table", DropIdColumnOfPermissionTemplatesTable.class) - .add(3574, "Drop column 'KEE' of 'PERMISSION_TEMPLATES' table", DropKeeColumnOfPermissionTemplatesTable.class) - - // Migration on RULES_PROFILES table - .add(3575, "Add 'uuid' column for 'RULES_PROFILES'", AddUuidColumnToRulesProfilesTable.class) - .add(3576, "Populate 'uuid' column for 'RULES_PROFILES'", PopulateRulesProfilesUuid.class) - .add(3577, "Make 'uuid' column not nullable for 'RULES_PROFILES'", MakeRulesProfilesUuidColumnNotNullable.class) - - // Migration of ORG_QPROFILES FK to RULES_PROFILES - .add(3578, "Populate 'rules_profile_uuid' column for 'ORG_QPROFILES' table", PopulateOrgQProfilesRulesProfileUuid.class) - - // Migration of QPROFILE_CHANGES FK to RULES_PROFILES - .add(3579, "Populate 'rules_profile_uuid' column for 'QPROFILE_CHANGES' table", PopulateQProfileChangesRulesProfileUuid.class) - - // Migration of ACTIVE_RULES FK to RULES_PROFILES, switch from profile_id to profile_uuid - .add(3580, "Add 'profile_uuid' column for 'ACTIVE_RULES' table", AddProfileUuidColumnToActiveRulesTable.class) - .add(3581, "Populate 'profile_uuid' column for 'ACTIVE_RULES' table", PopulateActiveRulesProfileUuid.class) - .add(3582, "Make 'profile_uuid' column not nullable for 'ACTIVE_RULES' table", MakeActiveRulesProfileUuidColumnNotNullable.class) - - .add(3583, "Drop unique constraint on 'profile_id', 'rule_id' columns 'ACTIVE_RULES' table", DropUniqueIndexOnProfileIdColumnOfActiveRulesTable.class) - .add(3584, "Add unique constraint on 'profile_uuid', 'rule_id' columns 'ACTIVE_RULES' table", AddUniqueIndexOnProfileUuidColumnOfActiveRulesTable.class) - - .add(3585, "Drop column 'profile_id' of 'ACTIVE_RULES' table", DropProfileIdColumnOfActiveRulesTable.class) - - .add(3586, "Drop unique constraint on 'kee' columns 'RULES_PROFILES' table", DropUniqueIndexOnKeeColumnOfRulesProfilesTable.class) - .add(3587, "Drop column 'kee' of 'RULES_PROFILES' table", DropKeeColumnOfRulesProfilesTable.class) - - .add(3588, "Drop primary key on 'ID' column of 'RULES_PROFILES' table", DropPrimaryKeyOnIdColumnOfRulesProfilesTable.class) - .add(3589, "Add primary key on 'UUID' column of 'RULES_PROFILES' table", AddPrimaryKeyOnUuidColumnOfRulesProfilesTable.class) - .add(3590, "Drop column 'ID' of 'RULES_PROFILES' table", DropIdColumnOfRulesProfilesTable.class) - - // Migration of PROPERTIES table - .add(3591, "Add 'uuid' column for 'PROPERTIES'", AddUuidColumnToProperties.class) - .add(3592, "Populate 'uuid' for 'PROPERTIES'", PopulatePropertiesUuid.class) - .add(3593, "Make 'uuid' column not nullable for 'PROPERTIES'", MakePropertiesUuidColumnNotNullable.class) - .add(3594, "Drop primary key on 'ID' column of 'PROPERTIES' table", DropPrimaryKeyOnIdColumnOfPropertiesTable.class) - .add(3595, "Add primary key on 'UUID' column of 'PROPERTIES' table", AddPrimaryKeyOnUuidColumnOfPropertiesTable.class) - .add(3596, "Drop column 'ID' of 'PROPERTIES' table", DropIdColumnOfPropertiesTable.class) - - // Migration of GROUPS table - .add(3597, "Add 'UUID' column on 'GROUPS' table", AddUuidColumnToGroupsTable.class) - .add(3598, "Populate 'uuid' for 'GROUPS'", PopulateGroupsUuid.class) - .add(3599, "Make 'uuid' column not nullable for 'GROUPS'", MakeGroupsUuidColumnNotNullable.class) - - // Migration of FK in GROUP_ROLES to GROUPS - .add(3600, "Add 'group_uuid' column on 'GROUP_ROLES' table", AddGroupUuidColumnToGroupRoles.class) - .add(3601, "Populate 'group_uuid' for 'GROUP_ROLES'", PopulateGroupRolesGroupUuid.class) - .add(3602, "Drop index on 'group_id' column of 'GROUP_ROLES' table", DropIndexOnGroupIdOfGroupRolesTable.class) - .add(3603, "Add index on 'group_uuid' column of 'GROUP_ROLES' table", AddIndexOnGroupUuidOfGroupRolesTable.class) - - // Migration of FK in GROUPS_USERS to GROUPS - .add(3604, "Add 'group_uuid' column on 'GROUPS_USERS' table", AddGroupUuidColumnToGroupsUsers.class) - .add(3605, "Populate 'group_uuid' for 'GROUPS_USERS'", PopulateGroupsUsersGroupUuid.class) - .add(3606, "Make 'group_uuid' column not nullable for 'GROUPS_USERS'", MakeGroupsUsersGroupUuidNotNullable.class) - .add(3607, "Drop index on 'group_id' column of 'GROUPS_USERS' table", DropIndexOnGroupIdOfGroupsUsersTable.class) - .add(3608, "Add index on 'group_uuid' column of 'GROUPS_USERS' table", AddIndexOnGroupUuidOfGroupsUsersTable.class) - - // Migration of FK in ORGANIZATIONS to GROUPS - .add(3609, "Add 'default_group_uuid' column on 'ORGANIZATIONS' table", AddDefaultGroupUuidColumnToOrganizations.class) - .add(3610, "Populate 'default_group_uuid' for 'ORGANIZATIONS'", PopulateOrganizationsDefaultGroupUuid.class) - - // Migration of FK in PERM_TEMPLATES_GROUPS to GROUPS - .add(3611, "Add 'group_uuid' column on 'PERM_TEMPLATES_GROUPS' table", AddGroupUuidColumnToPermTemplatesGroups.class) - .add(3612, "Populate 'group_uuid' for 'PERM_TEMPLATES_GROUPS'", PopulatePermTemplatesGroupsGroupUuid.class) - - // Migration of FK in QPROFILE_EDIT_GROUPS to GROUPS - .add(3613, "Add 'group_uuid' column on 'QPROFILE_EDIT_GROUPS' table", AddGroupUuidColumnToQProfileEditGroups.class) - .add(3614, "Populate 'group_uuid' for 'QPROFILE_EDIT_GROUPS'", PopulateQProfileEditGroupsGroupUuid.class) - .add(3615, "Make 'group_uuid' column not nullable for 'QPROFILE_EDIT_GROUPS'", MakeQProfileEditGroupsGroupUuidNotNullable.class) - .add(3616, "Drop index on 'group_id' column of 'QPROFILE_EDIT_GROUPS' table", DropIndexOnGroupIdOfQProfileEditGroupsTable.class) - .add(3617, "Add index on 'group_uuid' column of 'QPROFILE_EDIT_GROUPS' table", AddIndexOnGroupUuidOfQProfileEditGroupsTable.class) - - // Finish migration of Groups - .add(3618, "Drop primary key on 'ID' column of 'GROUPS' table", DropPrimaryKeyOnIdColumnOfGroupsTable.class) - .add(3619, "Add primary key on 'UUID' column of 'GROUPS' table", AddPrimaryKeyOnUuidColumnOfGroupsTable.class) - - .add(3620, "Drop column 'group_id' of 'GROUP_ROLES' table", DropGroupIdColumnOfGroupRolesTable.class) - .add(3621, "Drop column 'group_id' of 'GROUPS_USERS' table", DropGroupIdColumnOfGroupsUsersTable.class) - .add(3622, "Drop column 'group_id' of 'ORGANIZATIONS' table", DropDefaultGroupIdColumnOfOrganizationsTable.class) - .add(3623, "Drop column 'group_id' of 'PERM_TEMPLATES_GROUPS' table", DropGroupIdColumnOfPermTemplatesGroupsTable.class) - .add(3624, "Drop column 'group_id' of 'QPROFILE_EDIT_GROUPS' table", DropGroupIdColumnOfQProfileEditGroupsTable.class) - .add(3625, "Drop column 'ID' of 'GROUPS' table", DropIdColumnOfGroupsTable.class) - - // Migration of QUALITY_GATES_CONDITIONS FK to QUALITY_GATES, switch from qgate_id to qgate_uuid - .add(3626, "Add 'qgate_uuid' column for quality gates conditions", AddQGateUuidColumnForQGateConditions.class) - .add(3627, "Populate 'qgate_uuid' column for quality gates conditions", PopulateQGateUuidColumnForQGateConditions.class) - .add(3628, "drop orphans quality gates conditions", DropOrphansQGateConditions.class) - .add(3629, "Make 'qgate_uuid' column not nullable for quality gates conditions", MakeQGateUuidColumnNotNullableForQGateConditions.class) - .add(3630, "Drop 'qgate_id' column for quality gates conditions", DropQGateIdColumnForQGateConditions.class) - - // Migrations of QUALITY_GATES table - .add(3631, "Drop primary key on 'ID' column of 'QUALITY_GATES' table", DropPrimaryKeyOnIdColumnOfQGatesTable.class) - .add(3632, "drop unique index on 'UUID' column of 'QUALITY_GATES' table", DropUniqueIndexOnUuidColumnOfQualityGatesTable.class) - .add(3633, "Add primary key on 'UUID' column of 'QUALITY_GATES' table", AddPrimaryKeyOnUuidColumnOfQGatesTable.class) - .add(3634, "Drop column 'ID' of 'QUALITY_GATES' table", DropIdColumnOfQGateTable.class) - - // Migration of FK in GROUPS_USERS to USERS - .add(3635, "Add 'user_uuid' column on 'GROUPS_USERS' table", AddUserUuidColumnToGroupsUsers.class) - .add(3636, "Populate 'user_uuid' for 'GROUPS_USERS'", PopulateGroupsUsersUserUuid.class) - .add(3637, "Make 'user_uuid' column not nullable for 'GROUPS_USERS'", MakeGroupsUsersUserUuidColumnNotNullable.class) - .add(3638, "Drop index on 'user_id' column of 'GROUPS_USERS' table", DropIndexOnUserIdOfGroupsUsersTable.class) - .add(3639, "Add index on 'user_uuid' column of 'GROUPS_USERS' table", AddIndexOnUserUuidOfGroupsUsersTable.class) - .add(3640, "Drop index on 'user_id', 'group_id' columns of 'GROUPS_USERS' table", DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTable.class) - .add(3641, "Add unique index on 'user_uuid', 'group_id' columns of 'GROUPS_USERS' table", AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTable.class) - .add(3642, "Drop column on 'user_id' column of 'GROUPS_USERS' table", DropUserIdColumnOfGroupsUsersTable.class) - - // Migration of FK in ORGANIZATION_MEMBERS to USERS - .add(3643, "Add 'user_uuid' column on 'ORGANIZATION_MEMBERS' table", AddUserUuidColumnToOrganizationMembers.class) - .add(3644, "Populate 'user_uuid' for 'ORGANIZATION_MEMBERS'", PopulateOrganizationMembersUserUuid.class) - .add(3645, "Make 'user_uuid' not-null for 'ORGANIZATION_MEMBERS'", MakeOrganizationMembersUserUuidColumnNotNullable.class) - .add(3646, "Drop index on 'user_id' column of 'ORGANIZATION_MEMBERS' table", DropIndexOnUserIdOfOrganizationMembersTable.class) - .add(3647, "Add index on 'user_uuid' column of 'ORGANIZATION_MEMBERS' table", AddIndexOnUserUuidOfOrganizationMembersTable.class) - .add(3648, "Drop index on 'user_id', 'group_id' columns of 'ORGANIZATION_MEMBERS' table", DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTable.class) - .add(3649, "Add PK on 'user_uuid', 'organization_uuid' columns of 'ORGANIZATION_MEMBERS' table", AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTable.class) - .add(3650, "Drop column on 'user_id' column of 'ORGANIZATION_MEMBERS' table", DropUserIdColumnOfOrganizationMembersTable.class) - - // Migration of FK in PERM_TEMPLATES_USERS to USERS - .add(3651, "Add 'user_uuid' column on 'PERM_TEMPLATES_USERS' table", AddUserUuidColumnToPermTemplatesUsers.class) - .add(3652, "Populate 'user_uuid' for 'PERM_TEMPLATES_USERS'", PopulatePermTemplatesUsersUserUuid.class) - .add(3653, "Make 'user_uuid' not-null for 'PERM_TEMPLATES_USERS'", MakePermTemplatesUsersUserUuidColumnNotNullable.class) - .add(3654, "Drop column on 'user_id' column of 'PERM_TEMPLATES_USERS' table", DropUserIdColumnOfPermTemplatesUsersTable.class) - - // Migration of FK in PROPERTIES to USERS - .add(3655, "Add 'user_uuid' column on 'PROPERTIES' table", AddUserUuidColumnToPropertiesUsers.class) - .add(3656, "Populate 'user_uuid' for 'PROPERTIES'", PopulatePropertiesUserUuid.class) - .add(3657, "Drop column on 'user_id' column of 'PROPERTIES' table", DropUserIdColumnOfPropertiesTable.class) - - // Migration of FK in QPROFILE_EDIT_USERS to USERS - .add(3658, "Add 'user_uuid' column on 'QPROFILE_EDIT_USERS' table", AddUserUuidColumnToQProfileEditUsers.class) - .add(3659, "Populate 'user_uuid' for 'QPROFILE_EDIT_USERS'", PopulateQProfileEditUsersUserUuid.class) - .add(3660, "Make 'user_uuid' not-null for 'QPROFILE_EDIT_USERS'", MakeQProfileEditUsersUserUuidColumnNotNullable.class) - .add(3661, "Drop unique index on 'user_id','qprofile_uuid' columns of 'QPROFILE_EDIT_USERS' table", DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTable.class) - .add(3662, "Add unique index on 'user_uuid','qprofile_uuid' columns of 'QPROFILE_EDIT_USERS' table", AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTable.class) - .add(3663, "Drop column on 'user_id' column of 'QPROFILE_EDIT_USERS' table", DropUserIdColumnOfQProfileEditUsersTable.class) - - .add(3664, "Add 'user_uuid' column on 'USER_ROLES' table", AddUserUuidColumnToUserRoles.class) - .add(3665, "Populate 'user_uuid' for 'USER_ROLES'", PopulateUserRolesUserUuid.class) - .add(3666, "Drop unique index on 'user_id' column of 'USER_ROLES' table", DropIndexOnUserIdOfUserRolesTable.class) - .add(3667, "Add unique index on 'user_uuid' columns of 'USER_ROLES' table", AddIndexOnUserUuidOfUserRolesTable.class) - .add(3668, "Drop column on 'user_id' column of 'USER_ROLES' table", DropUserIdColumnOfUserRolesTable.class) - - .add(3669, "Drop unique index on 'user_id' column of 'USERS' table", DropUniqueIndexOnUuidColumnOfUsersTable.class) - .add(3670, "Drop PK index on 'id' column of 'USERS' table", DropPrimaryKeyOnIdColumnOfUsersTable.class) - .add(3671, "Add PK index on 'uuid' column of 'USERS' table", AddPrimaryKeyOnUuidColumnOfUsersTable.class) - .add(3672, "Drop 'id' column of 'USERS' table", DropIdColumnOfUsersTable.class) - - // Migration of RULES table - .add(3673, "Add 'uuid' column for 'RULES'", AddUuidAndTemplateUuidColumnsToRules.class) - .add(3674, "Populate 'uuid' column for 'RULES'", PopulateRulesUuid.class) - .add(3675, "Make 'uuid' column not nullable for 'RULES'", MakeRulesUuidColumnNotNullable.class) - .add(3676, "Populate 'templateUuid' column for 'RULES'", PopulateRulesTemplateUuid.class) - .add(3677, "Drop column 'templateId' column for 'RULES'", DropTemplateIdColumnOfRulesTable.class) - // Migration of RULES_METADATA FK to RULES, switch from rule_id to rule_uuid - .add(3678, "Add 'RULE_UUID' column for 'RULES_METADATA' table", AddRuleUuidColumnToRulesMetadataTable.class) - .add(3679, "Populate 'RULE_UUID' column for 'RULES_METADATA' table", PopulateRulesMetadataRuleUuidColumn.class) - .add(3680, "Make 'RULE_UUID' column not nullable for 'RULES_METADATA' table", MakeRulesMetadataRuleUuidColumnNotNullable.class) - .add(3681, "Drop primary key on 'RULE_ID' column of 'RULES_METADATA' table", DropPrimaryKeyOnIdColumnOfRulesMetadataTable.class) - .add(3682, "Add primary key on 'RULE_UUID' column of 'RULES_METADATA' table", AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTable.class) - .add(3683, "Drop column 'RULE_ID' of 'RULES_METADATA' table", DropRuleIdColumnOfRulesMetadataTable.class) - // Migration of RULES_PARAMETERS FK to RULES, switch from rule_id to rule_uuid - .add(3684, "Add 'RULE_UUID' column for 'RULES_PARAMETERS' table", AddRuleUuidColumnToRulesParametersTable.class) - .add(3685, "Populate 'RULE_UUID' column for 'RULES_PARAMETERS' table", PopulateRulesParametersRuleUuidColumn.class) - .add(3686, "Make 'RULE_UUID' column not nullable for 'RULES_PARAMETERS' table", MakeRulesParametersRuleUuidColumnNotNullable.class) - .add(3687, "Drop indexes on 'RULE_ID' of 'RULES_PARAMETERS' table", DropIndexesOnRuleIdColumnOfRulesParametersTable.class) - .add(3688, "Add indexes to 'RULES_PARAMETERS' table", AddIndexesToRulesParametersTable.class) - .add(3689, "Drop column 'RULE_ID' of 'RULES_PARAMETERS' table", DropRuleIdColumnOfRulesParametersTable.class) - // Migration of ACTIVE_RULES FK to RULES, switch from rule_id to rule_uuid - .add(3690, "Add 'RULE_UUID' column for 'ACTIVE_RULES' table", AddRuleUuidColumnToActiveRulesTable.class) - .add(3691, "Populate 'RULE_UUID' column for 'ACTIVE_RULES' table", PopulateActiveRulesRuleUuidColumn.class) - .add(3692, "Make 'RULE_UUID' column not nullable for 'ACTIVE_RULES' table", MakeActiveRulesRuleUuidColumnNotNullable.class) - .add(3693, "Drop indexes on 'RULE_ID' of 'ACTIVE_RULES' table", DropIndexOnRuleIdColumnOfActiveRulesTable.class) - .add(3694, "Add indexes to 'ACTIVE_RULES' table", AddIndexToActiveRulesTable.class) - .add(3695, "Drop column 'RULE_ID' of 'ACTIVE_RULES' table", DropRuleIdColumnOfActiveRulesTable.class) - // Migration of DEPRECATED_RULE_KEYS FK to RULES, switch from rule_id to rule_uuid - .add(3696, "Add 'RULE_UUID' column for 'DEPRECATED_RULE_KEYS' table", AddRuleUuidColumnToDeprecatedRuleKeysTable.class) - .add(3697, "Populate 'RULE_UUID' column for 'DEPRECATED_RULE_KEYS' table", PopulateDeprecatedRuleKeysRuleUuidColumn.class) - .add(3698, "Make 'RULE_UUID' column not nullable for 'DEPRECATED_RULE_KEYS' table", MakeDeprecatedRuleKeysRuleUuidColumnNotNullable.class) - .add(3699, "Drop index on 'RULE_ID' of 'DEPRECATED_RULE_KEYS' table", DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTable.class) - .add(3700, "Add index to 'DEPRECATED_RULE_KEYS' table", AddIndexToDeprecatedRuleKeysTable.class) - .add(3701, "Drop column 'RULE_ID' of 'DEPRECATED_RULE_KEYS' table", DropRuleIdColumnOfDeprecatedRuleKeysTable.class) - // Migration of ISSUE FK to RULES, switch from rule_id to rule_uuid - .add(3702, "Add 'RULE_UUID' column for 'ISSUES' table", AddRuleUuidColumnToIssuesTable.class) - .add(3703, "Populate 'RULE_UUID' column for 'ISSUES' table", PopulateIssuesRuleUuidColumn.class) - .add(3704, "Drop index on 'RULE_ID' of 'ISSUES' table", DropIndexOnRuleIdColumnOfIssuesTable.class) - .add(3705, "Add index to 'ISSUES' table", AddIndexToIssuesTable.class) - .add(3706, "Drop column 'RULE_ID' of 'ISSUES' table", DropRuleIdColumnOfIssuesTable.class) - // continue with RULES table cleanup - .add(3707, "Drop primary key on 'ID' column of 'RULES' table", DropPrimaryKeyOnIdColumnOfRulesTable.class) - .add(3708, "Add primary key on 'UUID' column of 'RULES' table", AddPrimaryKeyOnUuidColumnOfRulesTable.class) - .add(3709, "Drop column 'ID' of 'RULES' table", DropIdColumnOfRulesTable.class) - ; } } diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/DropIdFromComponentsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/DropIdFromComponentsTable.java index e76caf281cb..c38a8c66368 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/DropIdFromComponentsTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/DropIdFromComponentsTable.java @@ -23,7 +23,7 @@ import java.sql.SQLException; import org.sonar.db.Database; import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; public class DropIdFromComponentsTable extends DdlChange { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTable.java deleted file mode 100644 index 002d8acc1de..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.activeruleparameters; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.AddPrimaryKeyBuilder; - -public class AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("active_rule_parameters", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/AddUuidColumnToActiveRuleParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/AddUuidColumnToActiveRuleParametersTable.java deleted file mode 100644 index 1b1a93ce675..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/AddUuidColumnToActiveRuleParametersTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.activeruleparameters; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.AddUuidColumnToTable; - -public class AddUuidColumnToActiveRuleParametersTable extends AddUuidColumnToTable { - private static final String TABLE = "active_rule_parameters"; - - public AddUuidColumnToActiveRuleParametersTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/DropIdColumnOfActiveRuleParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/DropIdColumnOfActiveRuleParametersTable.java deleted file mode 100644 index 24707ab2235..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/DropIdColumnOfActiveRuleParametersTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.activeruleparameters; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropIdColumn; - -public class DropIdColumnOfActiveRuleParametersTable extends DropIdColumn { - private static final String TABLE = "active_rule_parameters"; - - public DropIdColumnOfActiveRuleParametersTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/DropPrimaryKeyOnIdColumnOfActiveRuleParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/DropPrimaryKeyOnIdColumnOfActiveRuleParametersTable.java deleted file mode 100644 index 22060f460f7..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/DropPrimaryKeyOnIdColumnOfActiveRuleParametersTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.activeruleparameters; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; - -public class DropPrimaryKeyOnIdColumnOfActiveRuleParametersTable extends DropPrimaryKeyOnIdColumn { - private static final String TABLE_NAME = "active_rule_parameters"; - - public DropPrimaryKeyOnIdColumnOfActiveRuleParametersTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/MakeActiveRuleParametersUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/MakeActiveRuleParametersUuidColumnNotNullable.java deleted file mode 100644 index adb4e660cf9..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/MakeActiveRuleParametersUuidColumnNotNullable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.activeruleparameters; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.MakeUuidColumnNotNullable; - -public class MakeActiveRuleParametersUuidColumnNotNullable extends MakeUuidColumnNotNullable { - private static final String TABLE = "active_rule_parameters"; - - public MakeActiveRuleParametersUuidColumnNotNullable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/PopulateActiveRuleParametersUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/PopulateActiveRuleParametersUuid.java deleted file mode 100644 index 13bba343aa8..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/PopulateActiveRuleParametersUuid.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.activeruleparameters; - -import java.sql.SQLException; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateActiveRuleParametersUuid extends DataChange { - - private final UuidFactory uuidFactory; - - public PopulateActiveRuleParametersUuid(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select id from active_rule_parameters where uuid is null"); - massUpdate.update("update active_rule_parameters set uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, uuidFactory.create()); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/AddActiveRuleUuidColumnToActiveRuleParameters.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/AddActiveRuleUuidColumnToActiveRuleParameters.java deleted file mode 100644 index 7f9347d11f1..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/AddActiveRuleUuidColumnToActiveRuleParameters.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.activerules; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddActiveRuleUuidColumnToActiveRuleParameters extends DdlChange { - private static final String TABLE = "active_rule_parameters"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("active_rule_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddActiveRuleUuidColumnToActiveRuleParameters(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/AddIndexOnActiveRuleUuidOfActiveRuleParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/AddIndexOnActiveRuleUuidOfActiveRuleParametersTable.java deleted file mode 100644 index e6f532b6a26..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/AddIndexOnActiveRuleUuidOfActiveRuleParametersTable.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.activerules; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddIndexOnActiveRuleUuidOfActiveRuleParametersTable extends DdlChange { - private static final String TABLE_NAME = "active_rule_parameters"; - private static final String INDEX_NAME = "arp_active_rule_uuid"; - - public AddIndexOnActiveRuleUuidOfActiveRuleParametersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (!indexExists()) { - context.execute(new CreateIndexBuilder() - .setUnique(false) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("active_rule_uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build()) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/AddPrimaryKeyOnUuidColumnOfActiveRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/AddPrimaryKeyOnUuidColumnOfActiveRulesTable.java deleted file mode 100644 index 3aaee464c4e..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/AddPrimaryKeyOnUuidColumnOfActiveRulesTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.activerules; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.AddPrimaryKeyBuilder; - -public class AddPrimaryKeyOnUuidColumnOfActiveRulesTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfActiveRulesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("active_rules", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/AddUuidColumnToActiveRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/AddUuidColumnToActiveRulesTable.java deleted file mode 100644 index 721d830a5d4..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/AddUuidColumnToActiveRulesTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.activerules; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.AddUuidColumnToTable; - -public class AddUuidColumnToActiveRulesTable extends AddUuidColumnToTable { - private static final String TABLE = "active_rules"; - - public AddUuidColumnToActiveRulesTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/DropActiveRuleIdColumnOfActiveRuleParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/DropActiveRuleIdColumnOfActiveRuleParametersTable.java deleted file mode 100644 index 72952ee7c17..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/DropActiveRuleIdColumnOfActiveRuleParametersTable.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.activerules; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropActiveRuleIdColumnOfActiveRuleParametersTable extends DdlChange { - public DropActiveRuleIdColumnOfActiveRuleParametersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "active_rule_parameters", "active_rule_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/DropIdColumnOfActiveRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/DropIdColumnOfActiveRulesTable.java deleted file mode 100644 index e89cf91637a..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/DropIdColumnOfActiveRulesTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.activerules; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropIdColumn; - -public class DropIdColumnOfActiveRulesTable extends DropIdColumn { - private static final String TABLE = "active_rules"; - - public DropIdColumnOfActiveRulesTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/DropIndexOnActiveRuleIdOfActiveRuleParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/DropIndexOnActiveRuleIdOfActiveRuleParametersTable.java deleted file mode 100644 index d612ae29da7..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/DropIndexOnActiveRuleIdOfActiveRuleParametersTable.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.activerules; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropIndexOnActiveRuleIdOfActiveRuleParametersTable extends DdlChange { - private static final String TABLE_NAME = "active_rule_parameters"; - private static final String INDEX_NAME = "ix_arp_on_active_rule_id"; - - public DropIndexOnActiveRuleIdOfActiveRuleParametersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (indexExists()) { - context.execute(new DropIndexBuilder(getDialect()) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/DropPrimaryKeyOnIdColumnOfActiveRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/DropPrimaryKeyOnIdColumnOfActiveRulesTable.java deleted file mode 100644 index 3c71ebaf6d0..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/DropPrimaryKeyOnIdColumnOfActiveRulesTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.activerules; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; - -public class DropPrimaryKeyOnIdColumnOfActiveRulesTable extends DropPrimaryKeyOnIdColumn { - private static final String TABLE_NAME = "active_rules"; - - public DropPrimaryKeyOnIdColumnOfActiveRulesTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/MakeActiveRuleParametersActiveRuleUuidNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/MakeActiveRuleParametersActiveRuleUuidNotNullable.java deleted file mode 100644 index 19ddafd1889..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/MakeActiveRuleParametersActiveRuleUuidNotNullable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.activerules; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeActiveRuleParametersActiveRuleUuidNotNullable extends DdlChange { - private static final String TABLE = "active_rule_parameters"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("active_rule_uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public MakeActiveRuleParametersActiveRuleUuidNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/MakeActiveRulesUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/MakeActiveRulesUuidColumnNotNullable.java deleted file mode 100644 index 3138410f04c..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/MakeActiveRulesUuidColumnNotNullable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.activerules; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.MakeUuidColumnNotNullable; - -public class MakeActiveRulesUuidColumnNotNullable extends MakeUuidColumnNotNullable { - private static final String TABLE = "active_rules"; - - public MakeActiveRulesUuidColumnNotNullable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/PopulateActiveRuleParametersActiveRuleUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/PopulateActiveRuleParametersActiveRuleUuid.java deleted file mode 100644 index 5f71e13750a..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/PopulateActiveRuleParametersActiveRuleUuid.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.activerules; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateActiveRuleParametersActiveRuleUuid extends DataChange { - - public PopulateActiveRuleParametersActiveRuleUuid(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select arp.uuid, ar.uuid " + - "from active_rule_parameters arp " + - "join active_rules ar on arp.active_rule_id = ar.id"); - - massUpdate.update("update active_rule_parameters set active_rule_uuid = ? where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(2)); - update.setString(2, row.getString(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/PopulateActiveRulesUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/PopulateActiveRulesUuid.java deleted file mode 100644 index 613060e6456..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/activerules/PopulateActiveRulesUuid.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.activerules; - -import java.sql.SQLException; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateActiveRulesUuid extends DataChange { - - private final UuidFactory uuidFactory; - - public PopulateActiveRulesUuid(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select id from active_rules where uuid is null order by id asc"); - massUpdate.update("update active_rules set uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, uuidFactory.create()); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTable.java deleted file mode 100644 index 6b9616675ac..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.ceactivity; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.AddPrimaryKeyBuilder; - -public class AddPrimaryKeyOnUuidColumnOfCeActivityTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfCeActivityTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("ce_activity", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/ceactivity/DropIdColumnOfCeActivityTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/ceactivity/DropIdColumnOfCeActivityTable.java deleted file mode 100644 index 2b8c1be16a6..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/ceactivity/DropIdColumnOfCeActivityTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.ceactivity; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropIdColumn; - -public class DropIdColumnOfCeActivityTable extends DropIdColumn { - private static final String TABLE = "ce_activity"; - - public DropIdColumnOfCeActivityTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTable.java deleted file mode 100644 index 51471b839ce..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.ceactivity; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; - -public class DropPrimaryKeyOnIdColumnOfCeActivityTable extends DropPrimaryKeyOnIdColumn { - private static final String TABLE_NAME = "ce_activity"; - - public DropPrimaryKeyOnIdColumnOfCeActivityTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/cequeue/AddPrimaryKeyOnUuidColumnOfCeQueueTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/cequeue/AddPrimaryKeyOnUuidColumnOfCeQueueTable.java deleted file mode 100644 index 245c6b90781..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/cequeue/AddPrimaryKeyOnUuidColumnOfCeQueueTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.cequeue; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.AddPrimaryKeyBuilder; - -public class AddPrimaryKeyOnUuidColumnOfCeQueueTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfCeQueueTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("ce_queue", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/cequeue/DropIdColumnOfCeQueueTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/cequeue/DropIdColumnOfCeQueueTable.java deleted file mode 100644 index ef70b7630b5..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/cequeue/DropIdColumnOfCeQueueTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.cequeue; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropIdColumn; - -public class DropIdColumnOfCeQueueTable extends DropIdColumn { - private static final String TABLE = "ce_queue"; - - public DropIdColumnOfCeQueueTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/cequeue/DropPrimaryKeyOnIdColumnOfCeQueueTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/cequeue/DropPrimaryKeyOnIdColumnOfCeQueueTable.java deleted file mode 100644 index 511e6e66f2c..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/cequeue/DropPrimaryKeyOnIdColumnOfCeQueueTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.cequeue; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; - -public class DropPrimaryKeyOnIdColumnOfCeQueueTable extends DropPrimaryKeyOnIdColumn { - private static final String TABLE_NAME = "ce_queue"; - - public DropPrimaryKeyOnIdColumnOfCeQueueTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/cequeue/DropUniqueIndexOnUuidColumnOfCeQueueTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/cequeue/DropUniqueIndexOnUuidColumnOfCeQueueTable.java deleted file mode 100644 index d006e156591..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/cequeue/DropUniqueIndexOnUuidColumnOfCeQueueTable.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.cequeue; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropUniqueIndexOnUuidColumnOfCeQueueTable extends DdlChange { - - public DropUniqueIndexOnUuidColumnOfCeQueueTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropIndexBuilder(getDialect()) - .setTable("ce_queue") - .setName("ce_queue_uuid") - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/common/AddUuidColumnToTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/common/AddUuidColumnToTable.java deleted file mode 100644 index 64f4a6aa3c8..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/common/AddUuidColumnToTable.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.common; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public abstract class AddUuidColumnToTable extends DdlChange { - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - private String tableName; - - public AddUuidColumnToTable(Database db, String tableName) { - super(db); - this.tableName = tableName; - } - - @Override - public void execute(DdlChange.Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), tableName) - .addColumn(uuidColumnDefinition) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/common/DropIdColumn.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/common/DropIdColumn.java deleted file mode 100644 index ffa7e0764a3..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/common/DropIdColumn.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.common; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public abstract class DropIdColumn extends DdlChange { - private Database db; - private String tableName; - - public DropIdColumn(Database db, String tableName) { - super(db); - this.db = db; - this.tableName = tableName; - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(db.getDialect(), tableName, "id").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/common/DropPrimaryKeyOnIdColumn.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/common/DropPrimaryKeyOnIdColumn.java deleted file mode 100644 index 396756e7505..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/common/DropPrimaryKeyOnIdColumn.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.common; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; - -public abstract class DropPrimaryKeyOnIdColumn extends DdlChange { - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator; - private String tableName; - - public DropPrimaryKeyOnIdColumn(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator, String tableName) { - super(db); - this.dropPrimaryKeySqlGenerator = dropPrimaryKeySqlGenerator; - this.tableName = tableName; - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(dropPrimaryKeySqlGenerator.generate(tableName, "id", true)); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/common/MakeUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/common/MakeUuidColumnNotNullable.java deleted file mode 100644 index 810b91ca694..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/common/MakeUuidColumnNotNullable.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.common; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public abstract class MakeUuidColumnNotNullable extends DdlChange { - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - private String tableName; - - public MakeUuidColumnNotNullable(Database db, String tableName) { - super(db); - this.tableName = tableName; - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), tableName) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTable.java deleted file mode 100644 index 1efc12e91ea..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.duplicationsindex; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.AddPrimaryKeyBuilder; - -public class AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("duplications_index", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/AddUuidToDuplicationsIndexTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/AddUuidToDuplicationsIndexTable.java deleted file mode 100644 index 95df1702fdc..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/AddUuidToDuplicationsIndexTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.duplicationsindex; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.AddUuidColumnToTable; - -public class AddUuidToDuplicationsIndexTable extends AddUuidColumnToTable { - private static final String TABLE = "duplications_index"; - - public AddUuidToDuplicationsIndexTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/DropIdColumnOfDuplicationsIndexTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/DropIdColumnOfDuplicationsIndexTable.java deleted file mode 100644 index 5a856e29f9c..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/DropIdColumnOfDuplicationsIndexTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.duplicationsindex; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropIdColumn; - -public class DropIdColumnOfDuplicationsIndexTable extends DropIdColumn { - private static final String TABLE = "duplications_index"; - - public DropIdColumnOfDuplicationsIndexTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/DropPrimaryKeyOnIdColumnOfDuplicationsIndexTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/DropPrimaryKeyOnIdColumnOfDuplicationsIndexTable.java deleted file mode 100644 index f0599323942..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/DropPrimaryKeyOnIdColumnOfDuplicationsIndexTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.duplicationsindex; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; - -public class DropPrimaryKeyOnIdColumnOfDuplicationsIndexTable extends DropPrimaryKeyOnIdColumn { - private static final String TABLE_NAME = "duplications_index"; - - public DropPrimaryKeyOnIdColumnOfDuplicationsIndexTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/MakeDuplicationsIndexUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/MakeDuplicationsIndexUuidColumnNotNullable.java deleted file mode 100644 index 400bdcce229..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/MakeDuplicationsIndexUuidColumnNotNullable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.duplicationsindex; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.MakeUuidColumnNotNullable; - -public class MakeDuplicationsIndexUuidColumnNotNullable extends MakeUuidColumnNotNullable { - private static final String TABLE = "duplications_index"; - - public MakeDuplicationsIndexUuidColumnNotNullable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/PopulateDuplicationsIndexUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/PopulateDuplicationsIndexUuid.java deleted file mode 100644 index 9d6302049af..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/PopulateDuplicationsIndexUuid.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.duplicationsindex; - -import java.sql.SQLException; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateDuplicationsIndexUuid extends DataChange { - - private final UuidFactory uuidFactory; - - public PopulateDuplicationsIndexUuid(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select id from duplications_index where uuid is null order by id asc"); - massUpdate.update("update duplications_index set uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, uuidFactory.create()); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/events/AddPrimaryKeyOnUuidColumnOfEventsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/events/AddPrimaryKeyOnUuidColumnOfEventsTable.java deleted file mode 100644 index cbf84c5f7fa..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/events/AddPrimaryKeyOnUuidColumnOfEventsTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.events; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.AddPrimaryKeyBuilder; - -public class AddPrimaryKeyOnUuidColumnOfEventsTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfEventsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("events", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/events/DropIdColumnOfEventsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/events/DropIdColumnOfEventsTable.java deleted file mode 100644 index 69592a8e4fd..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/events/DropIdColumnOfEventsTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.events; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropIdColumn; - -public class DropIdColumnOfEventsTable extends DropIdColumn { - private static final String TABLE = "events"; - - public DropIdColumnOfEventsTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/events/DropPrimaryKeyOnIdColumnOfEventsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/events/DropPrimaryKeyOnIdColumnOfEventsTable.java deleted file mode 100644 index b49286e5cdf..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/events/DropPrimaryKeyOnIdColumnOfEventsTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.events; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; - -public class DropPrimaryKeyOnIdColumnOfEventsTable extends DropPrimaryKeyOnIdColumn { - private static final String TABLE_NAME = "events"; - - public DropPrimaryKeyOnIdColumnOfEventsTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/filesources/AddPrimaryKeyOnUuidColumnOfFileSourcesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/filesources/AddPrimaryKeyOnUuidColumnOfFileSourcesTable.java deleted file mode 100644 index 7f290eccd1b..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/filesources/AddPrimaryKeyOnUuidColumnOfFileSourcesTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.filesources; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.AddPrimaryKeyBuilder; - -public class AddPrimaryKeyOnUuidColumnOfFileSourcesTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfFileSourcesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("file_sources", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/filesources/AddUuidColumnToFileSourcesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/filesources/AddUuidColumnToFileSourcesTable.java deleted file mode 100644 index 79b6bd695fb..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/filesources/AddUuidColumnToFileSourcesTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.filesources; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.AddUuidColumnToTable; - -public class AddUuidColumnToFileSourcesTable extends AddUuidColumnToTable { - private static final String TABLE = "file_sources"; - - public AddUuidColumnToFileSourcesTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/filesources/DropIdColumnOfFileSourcesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/filesources/DropIdColumnOfFileSourcesTable.java deleted file mode 100644 index 741bf99a0e3..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/filesources/DropIdColumnOfFileSourcesTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.filesources; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropIdColumn; - -public class DropIdColumnOfFileSourcesTable extends DropIdColumn { - private static final String TABLE = "file_sources"; - - public DropIdColumnOfFileSourcesTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/filesources/DropPrimaryKeyOnIdColumnOfFileSourcesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/filesources/DropPrimaryKeyOnIdColumnOfFileSourcesTable.java deleted file mode 100644 index 8b03c71be40..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/filesources/DropPrimaryKeyOnIdColumnOfFileSourcesTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.filesources; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; - -public class DropPrimaryKeyOnIdColumnOfFileSourcesTable extends DropPrimaryKeyOnIdColumn { - private static final String TABLE_NAME = "file_sources"; - - public DropPrimaryKeyOnIdColumnOfFileSourcesTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/filesources/MakeFileSourcesUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/filesources/MakeFileSourcesUuidColumnNotNullable.java deleted file mode 100644 index 265ef338f77..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/filesources/MakeFileSourcesUuidColumnNotNullable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.filesources; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.MakeUuidColumnNotNullable; - -public class MakeFileSourcesUuidColumnNotNullable extends MakeUuidColumnNotNullable { - private static final String TABLE = "file_sources"; - - public MakeFileSourcesUuidColumnNotNullable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/filesources/PopulateFileSourcesUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/filesources/PopulateFileSourcesUuid.java deleted file mode 100644 index b292f040284..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/filesources/PopulateFileSourcesUuid.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.filesources; - -import java.sql.SQLException; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateFileSourcesUuid extends DataChange { - - private final UuidFactory uuidFactory; - - public PopulateFileSourcesUuid(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select id from file_sources where uuid is null order by id asc"); - massUpdate.update("update file_sources set uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, uuidFactory.create()); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/grouproles/AddPrimaryKeyOnUuidColumnOfGroupRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/grouproles/AddPrimaryKeyOnUuidColumnOfGroupRolesTable.java deleted file mode 100644 index ee024e616f4..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/grouproles/AddPrimaryKeyOnUuidColumnOfGroupRolesTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.grouproles; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.AddPrimaryKeyBuilder; - -public class AddPrimaryKeyOnUuidColumnOfGroupRolesTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfGroupRolesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("group_roles", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/grouproles/AddUuidColumnToGroupRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/grouproles/AddUuidColumnToGroupRolesTable.java deleted file mode 100644 index 9f4841e0d00..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/grouproles/AddUuidColumnToGroupRolesTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.grouproles; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.AddUuidColumnToTable; - -public class AddUuidColumnToGroupRolesTable extends AddUuidColumnToTable { - private static final String TABLE = "group_roles"; - - public AddUuidColumnToGroupRolesTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/grouproles/DropIdColumnOfGroupRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/grouproles/DropIdColumnOfGroupRolesTable.java deleted file mode 100644 index 3e15cba01d7..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/grouproles/DropIdColumnOfGroupRolesTable.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.grouproles; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropIdColumnOfGroupRolesTable extends DdlChange { - - private Database db; - - public DropIdColumnOfGroupRolesTable(Database db) { - super(db); - this.db = db; - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(db.getDialect(), "group_roles", "id").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/grouproles/DropPrimaryKeyOnIdColumnOfGroupRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/grouproles/DropPrimaryKeyOnIdColumnOfGroupRolesTable.java deleted file mode 100644 index 9de6c1beae8..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/grouproles/DropPrimaryKeyOnIdColumnOfGroupRolesTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.grouproles; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; - -public class DropPrimaryKeyOnIdColumnOfGroupRolesTable extends DropPrimaryKeyOnIdColumn { - private static final String TABLE_NAME = "group_roles"; - - public DropPrimaryKeyOnIdColumnOfGroupRolesTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/grouproles/MakeGroupRolesUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/grouproles/MakeGroupRolesUuidColumnNotNullable.java deleted file mode 100644 index e5b8ab5ec2d..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/grouproles/MakeGroupRolesUuidColumnNotNullable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.grouproles; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.MakeUuidColumnNotNullable; - -public class MakeGroupRolesUuidColumnNotNullable extends MakeUuidColumnNotNullable { - private static final String TABLE = "group_roles"; - - public MakeGroupRolesUuidColumnNotNullable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/grouproles/PopulateGroupRolesUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/grouproles/PopulateGroupRolesUuid.java deleted file mode 100644 index 7458ffd1e06..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/grouproles/PopulateGroupRolesUuid.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.grouproles; - -import java.sql.SQLException; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateGroupRolesUuid extends DataChange { - - private final UuidFactory uuidFactory; - - public PopulateGroupRolesUuid(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select id from group_roles where uuid is null order by id asc"); - massUpdate.update("update group_roles set uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, uuidFactory.create()); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/AddPrimaryKeyOnUuidColumnOfGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/AddPrimaryKeyOnUuidColumnOfGroupsTable.java deleted file mode 100644 index 0c1d518061d..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/AddPrimaryKeyOnUuidColumnOfGroupsTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.AddPrimaryKeyBuilder; - -public class AddPrimaryKeyOnUuidColumnOfGroupsTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfGroupsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("groups", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/AddUuidColumnToGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/AddUuidColumnToGroupsTable.java deleted file mode 100644 index fb7c38f0ad6..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/AddUuidColumnToGroupsTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.AddUuidColumnToTable; - -public class AddUuidColumnToGroupsTable extends AddUuidColumnToTable { - private static final String TABLE = "groups"; - - public AddUuidColumnToGroupsTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/DropIdColumnOfGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/DropIdColumnOfGroupsTable.java deleted file mode 100644 index b473a7fe200..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/DropIdColumnOfGroupsTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropIdColumn; - -public class DropIdColumnOfGroupsTable extends DropIdColumn { - private static final String TABLE = "groups"; - - public DropIdColumnOfGroupsTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/DropPrimaryKeyOnIdColumnOfGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/DropPrimaryKeyOnIdColumnOfGroupsTable.java deleted file mode 100644 index 3e1386bb56f..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/DropPrimaryKeyOnIdColumnOfGroupsTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; - -public class DropPrimaryKeyOnIdColumnOfGroupsTable extends DropPrimaryKeyOnIdColumn { - private static final String TABLE_NAME = "groups"; - - public DropPrimaryKeyOnIdColumnOfGroupsTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/MakeGroupsUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/MakeGroupsUuidColumnNotNullable.java deleted file mode 100644 index 187d515fa44..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/MakeGroupsUuidColumnNotNullable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.MakeUuidColumnNotNullable; - -public class MakeGroupsUuidColumnNotNullable extends MakeUuidColumnNotNullable { - private static final String TABLE = "groups"; - - public MakeGroupsUuidColumnNotNullable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/PopulateGroupsUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/PopulateGroupsUuid.java deleted file mode 100644 index 54044e6fcc4..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/PopulateGroupsUuid.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups; - -import java.sql.SQLException; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateGroupsUuid extends DataChange { - - private final UuidFactory uuidFactory; - - public PopulateGroupsUuid(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select id from groups where uuid is null order by id asc"); - massUpdate.update("update groups set uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, uuidFactory.create()); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/AddGroupUuidColumnToGroupRoles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/AddGroupUuidColumnToGroupRoles.java deleted file mode 100644 index efcef0cbfb6..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/AddGroupUuidColumnToGroupRoles.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.grouproles; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddGroupUuidColumnToGroupRoles extends DdlChange { - private static final String TABLE = "group_roles"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("group_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddGroupUuidColumnToGroupRoles(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/AddIndexOnGroupUuidOfGroupRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/AddIndexOnGroupUuidOfGroupRolesTable.java deleted file mode 100644 index 639b0616382..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/AddIndexOnGroupUuidOfGroupRolesTable.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.grouproles; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddIndexOnGroupUuidOfGroupRolesTable extends DdlChange { - private static final String TABLE_NAME = "group_roles"; - private static final String INDEX_NAME = "uniq_group_roles"; - - public AddIndexOnGroupUuidOfGroupRolesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (!indexExists()) { - context.execute(new CreateIndexBuilder() - .setUnique(true) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("organization_uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build()) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("group_uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build()) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("component_uuid") - .setIsNullable(true) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build()) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("role") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build()) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/DropGroupIdColumnOfGroupRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/DropGroupIdColumnOfGroupRolesTable.java deleted file mode 100644 index c5877817dd7..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/DropGroupIdColumnOfGroupRolesTable.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.grouproles; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropGroupIdColumnOfGroupRolesTable extends DdlChange { - public DropGroupIdColumnOfGroupRolesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "group_roles", "group_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/DropIndexOnGroupIdOfGroupRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/DropIndexOnGroupIdOfGroupRolesTable.java deleted file mode 100644 index ab3238ee0f2..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/DropIndexOnGroupIdOfGroupRolesTable.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.grouproles; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropIndexOnGroupIdOfGroupRolesTable extends DdlChange { - private static final String TABLE_NAME = "group_roles"; - private static final String INDEX_NAME = "uniq_group_roles"; - - public DropIndexOnGroupIdOfGroupRolesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (indexExists()) { - context.execute(new DropIndexBuilder(getDialect()) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/PopulateGroupRolesGroupUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/PopulateGroupRolesGroupUuid.java deleted file mode 100644 index 99757c5b7e3..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/PopulateGroupRolesGroupUuid.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.grouproles; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateGroupRolesGroupUuid extends DataChange { - - public PopulateGroupRolesGroupUuid(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select gr.uuid, g.uuid " + - "from group_roles gr " + - "join groups g on gr.group_id = g.id"); - - massUpdate.update("update group_roles set group_uuid = ? where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(2)); - update.setString(2, row.getString(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/AddGroupUuidColumnToGroupsUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/AddGroupUuidColumnToGroupsUsers.java deleted file mode 100644 index 7895606e694..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/AddGroupUuidColumnToGroupsUsers.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.groupsusers; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddGroupUuidColumnToGroupsUsers extends DdlChange { - private static final String TABLE = "groups_users"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("group_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddGroupUuidColumnToGroupsUsers(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/AddIndexOnGroupUuidOfGroupsUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/AddIndexOnGroupUuidOfGroupsUsersTable.java deleted file mode 100644 index 67d2474970e..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/AddIndexOnGroupUuidOfGroupsUsersTable.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.groupsusers; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.BigIntegerColumnDef.newBigIntegerColumnDefBuilder; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddIndexOnGroupUuidOfGroupsUsersTable extends DdlChange { - private static final String TABLE_NAME = "groups_users"; - private static final String INDEX_NAME1 = "index_groups_users_group_uuid"; - private static final String INDEX_NAME2 = "groups_users_unique"; - - public AddIndexOnGroupUuidOfGroupsUsersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - VarcharColumnDef groupUuid = newVarcharColumnDefBuilder() - .setColumnName("group_uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - if (!indexExists(INDEX_NAME1)) { - context.execute(new CreateIndexBuilder() - .setUnique(false) - .setTable(TABLE_NAME) - .setName(INDEX_NAME1) - .addColumn(groupUuid) - .build()); - } - if (!indexExists(INDEX_NAME2)) { - context.execute(new CreateIndexBuilder() - .setUnique(true) - .setTable(TABLE_NAME) - .setName(INDEX_NAME2) - .addColumn(groupUuid) - .addColumn(newBigIntegerColumnDefBuilder() - .setColumnName("user_id") - .setIsNullable(true) - .build()) - .build()); - } - } - - private boolean indexExists(String name) throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExists(TABLE_NAME, name, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/DropGroupIdColumnOfGroupsUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/DropGroupIdColumnOfGroupsUsersTable.java deleted file mode 100644 index bbe2c267f3a..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/DropGroupIdColumnOfGroupsUsersTable.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.groupsusers; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropGroupIdColumnOfGroupsUsersTable extends DdlChange { - public DropGroupIdColumnOfGroupsUsersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "groups_users", "group_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/DropIndexOnGroupIdOfGroupsUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/DropIndexOnGroupIdOfGroupsUsersTable.java deleted file mode 100644 index 155265d8825..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/DropIndexOnGroupIdOfGroupsUsersTable.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.groupsusers; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropIndexOnGroupIdOfGroupsUsersTable extends DdlChange { - private static final String TABLE_NAME = "groups_users"; - private static final String INDEX_NAME1 = "index_groups_users_on_group_id"; - private static final String INDEX_NAME2 = "groups_users_unique"; - - public DropIndexOnGroupIdOfGroupsUsersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (indexExists(INDEX_NAME1)) { - context.execute(new DropIndexBuilder(getDialect()) - .setTable(TABLE_NAME) - .setName(INDEX_NAME1) - .build()); - } - if (indexExists(INDEX_NAME2)) { - context.execute(new DropIndexBuilder(getDialect()) - .setTable(TABLE_NAME) - .setName(INDEX_NAME2) - .build()); - } - } - - private boolean indexExists(String name) throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExists(TABLE_NAME, name, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/MakeGroupsUsersGroupUuidNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/MakeGroupsUsersGroupUuidNotNullable.java deleted file mode 100644 index 4a2a4a2afc3..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/MakeGroupsUsersGroupUuidNotNullable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.groupsusers; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeGroupsUsersGroupUuidNotNullable extends DdlChange { - private static final String TABLE = "groups_users"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("group_uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public MakeGroupsUsersGroupUuidNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/PopulateGroupsUsersGroupUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/PopulateGroupsUsersGroupUuid.java deleted file mode 100644 index 616ce20dc1c..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/PopulateGroupsUsersGroupUuid.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.groupsusers; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateGroupsUsersGroupUuid extends DataChange { - - public PopulateGroupsUsersGroupUuid(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select gu.user_id, gu.group_id, g.uuid " + - "from groups_users gu " + - "join groups g on gu.group_id = g.id"); - - massUpdate.update("update groups_users set group_uuid = ? where user_id = ? and group_id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(3)); - update.setLong(2, row.getLong(1)); - update.setLong(3, row.getLong(2)); - - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/organizations/AddDefaultGroupUuidColumnToOrganizations.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/organizations/AddDefaultGroupUuidColumnToOrganizations.java deleted file mode 100644 index 1bbd8598197..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/organizations/AddDefaultGroupUuidColumnToOrganizations.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.organizations; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddDefaultGroupUuidColumnToOrganizations extends DdlChange { - private static final String TABLE = "organizations"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("default_group_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddDefaultGroupUuidColumnToOrganizations(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/organizations/DropDefaultGroupIdColumnOfOrganizationsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/organizations/DropDefaultGroupIdColumnOfOrganizationsTable.java deleted file mode 100644 index 37bab29449d..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/organizations/DropDefaultGroupIdColumnOfOrganizationsTable.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.organizations; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropDefaultGroupIdColumnOfOrganizationsTable extends DdlChange { - public DropDefaultGroupIdColumnOfOrganizationsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "organizations", "default_group_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/organizations/PopulateOrganizationsDefaultGroupUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/organizations/PopulateOrganizationsDefaultGroupUuid.java deleted file mode 100644 index 597b8e04bcd..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/organizations/PopulateOrganizationsDefaultGroupUuid.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.organizations; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateOrganizationsDefaultGroupUuid extends DataChange { - - public PopulateOrganizationsDefaultGroupUuid(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select o.uuid, g.uuid " + - "from organizations o " + - "join groups g on o.default_group_id = g.id"); - - massUpdate.update("update organizations set default_group_uuid = ? where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(2)); - update.setString(2, row.getString(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/permtemplatesgroups/AddGroupUuidColumnToPermTemplatesGroups.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/permtemplatesgroups/AddGroupUuidColumnToPermTemplatesGroups.java deleted file mode 100644 index afccbca8a25..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/permtemplatesgroups/AddGroupUuidColumnToPermTemplatesGroups.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.permtemplatesgroups; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddGroupUuidColumnToPermTemplatesGroups extends DdlChange { - private static final String TABLE = "perm_templates_groups"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("group_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddGroupUuidColumnToPermTemplatesGroups(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/permtemplatesgroups/DropGroupIdColumnOfPermTemplatesGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/permtemplatesgroups/DropGroupIdColumnOfPermTemplatesGroupsTable.java deleted file mode 100644 index 6c208b52663..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/permtemplatesgroups/DropGroupIdColumnOfPermTemplatesGroupsTable.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.permtemplatesgroups; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropGroupIdColumnOfPermTemplatesGroupsTable extends DdlChange { - public DropGroupIdColumnOfPermTemplatesGroupsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "perm_templates_groups", "group_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/permtemplatesgroups/PopulatePermTemplatesGroupsGroupUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/permtemplatesgroups/PopulatePermTemplatesGroupsGroupUuid.java deleted file mode 100644 index 86ded7b3127..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/permtemplatesgroups/PopulatePermTemplatesGroupsGroupUuid.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.permtemplatesgroups; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulatePermTemplatesGroupsGroupUuid extends DataChange { - - public PopulatePermTemplatesGroupsGroupUuid(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select ptg.uuid, g.uuid " + - "from perm_templates_groups ptg " + - "join groups g on ptg.group_id = g.id"); - - massUpdate.update("update perm_templates_groups set group_uuid = ? where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(2)); - update.setString(2, row.getString(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/AddGroupUuidColumnToQProfileEditGroups.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/AddGroupUuidColumnToQProfileEditGroups.java deleted file mode 100644 index 10b33fe77f7..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/AddGroupUuidColumnToQProfileEditGroups.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.qprofileeditgroups; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddGroupUuidColumnToQProfileEditGroups extends DdlChange { - private static final String TABLE = "qprofile_edit_groups"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("group_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddGroupUuidColumnToQProfileEditGroups(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/AddIndexOnGroupUuidOfQProfileEditGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/AddIndexOnGroupUuidOfQProfileEditGroupsTable.java deleted file mode 100644 index b26880a6d9f..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/AddIndexOnGroupUuidOfQProfileEditGroupsTable.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.qprofileeditgroups; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddIndexOnGroupUuidOfQProfileEditGroupsTable extends DdlChange { - private static final String TABLE_NAME = "qprofile_edit_groups"; - private static final String INDEX_NAME = "qprofile_edit_groups_unique"; - - public AddIndexOnGroupUuidOfQProfileEditGroupsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (!indexExists()) { - context.execute(new CreateIndexBuilder() - .setUnique(true) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("group_uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build()) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("qprofile_uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build()) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/DropGroupIdColumnOfQProfileEditGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/DropGroupIdColumnOfQProfileEditGroupsTable.java deleted file mode 100644 index 79af277283c..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/DropGroupIdColumnOfQProfileEditGroupsTable.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.qprofileeditgroups; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropGroupIdColumnOfQProfileEditGroupsTable extends DdlChange { - public DropGroupIdColumnOfQProfileEditGroupsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "qprofile_edit_groups", "group_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/DropIndexOnGroupIdOfQProfileEditGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/DropIndexOnGroupIdOfQProfileEditGroupsTable.java deleted file mode 100644 index 24710c8e1a7..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/DropIndexOnGroupIdOfQProfileEditGroupsTable.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.qprofileeditgroups; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropIndexOnGroupIdOfQProfileEditGroupsTable extends DdlChange { - private static final String TABLE_NAME = "qprofile_edit_groups"; - private static final String INDEX_NAME = "qprofile_edit_groups_unique"; - - public DropIndexOnGroupIdOfQProfileEditGroupsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (indexExists(INDEX_NAME)) { - context.execute(new DropIndexBuilder(getDialect()) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .build()); - } - } - - private boolean indexExists(String name) throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExists(TABLE_NAME, name, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/MakeQProfileEditGroupsGroupUuidNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/MakeQProfileEditGroupsGroupUuidNotNullable.java deleted file mode 100644 index 80f625838f9..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/MakeQProfileEditGroupsGroupUuidNotNullable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.qprofileeditgroups; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeQProfileEditGroupsGroupUuidNotNullable extends DdlChange { - private static final String TABLE = "qprofile_edit_groups"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("group_uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public MakeQProfileEditGroupsGroupUuidNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/PopulateQProfileEditGroupsGroupUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/PopulateQProfileEditGroupsGroupUuid.java deleted file mode 100644 index e513ad84d12..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/PopulateQProfileEditGroupsGroupUuid.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.qprofileeditgroups; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateQProfileEditGroupsGroupUuid extends DataChange { - - public PopulateQProfileEditGroupsGroupUuid(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select qeg.uuid, g.uuid " + - "from qprofile_edit_groups qeg " + - "join groups g on qeg.group_id = g.id"); - - massUpdate.update("update qprofile_edit_groups set group_uuid = ? where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(2)); - update.setString(2, row.getString(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/AddPrimaryKeyOnUuidColumnOfIssueChangesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/AddPrimaryKeyOnUuidColumnOfIssueChangesTable.java deleted file mode 100644 index cfa5c1da127..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/AddPrimaryKeyOnUuidColumnOfIssueChangesTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.issuechanges; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.AddPrimaryKeyBuilder; - -public class AddPrimaryKeyOnUuidColumnOfIssueChangesTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfIssueChangesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("issue_changes", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/AddUuidColumnToIssueChangesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/AddUuidColumnToIssueChangesTable.java deleted file mode 100644 index bb43dd59808..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/AddUuidColumnToIssueChangesTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.issuechanges; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.AddUuidColumnToTable; - -public class AddUuidColumnToIssueChangesTable extends AddUuidColumnToTable { - private static final String TABLE = "issue_changes"; - - public AddUuidColumnToIssueChangesTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/DropIdColumnOfIssueChangesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/DropIdColumnOfIssueChangesTable.java deleted file mode 100644 index c9e3a3f88c9..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/DropIdColumnOfIssueChangesTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.issuechanges; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropIdColumn; - -public class DropIdColumnOfIssueChangesTable extends DropIdColumn { - private static final String TABLE = "issue_changes"; - - public DropIdColumnOfIssueChangesTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/DropPrimaryKeyOnIdColumnOfIssueChangesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/DropPrimaryKeyOnIdColumnOfIssueChangesTable.java deleted file mode 100644 index 7276ab88279..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/DropPrimaryKeyOnIdColumnOfIssueChangesTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.issuechanges; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; - -public class DropPrimaryKeyOnIdColumnOfIssueChangesTable extends DropPrimaryKeyOnIdColumn { - private static final String TABLE_NAME = "issue_changes"; - - public DropPrimaryKeyOnIdColumnOfIssueChangesTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/MakeIssueChangesUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/MakeIssueChangesUuidColumnNotNullable.java deleted file mode 100644 index 7852ecd8940..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/MakeIssueChangesUuidColumnNotNullable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.issuechanges; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.MakeUuidColumnNotNullable; - -public class MakeIssueChangesUuidColumnNotNullable extends MakeUuidColumnNotNullable { - private static final String TABLE = "issue_changes"; - - public MakeIssueChangesUuidColumnNotNullable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/PopulateIssueChangesUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/PopulateIssueChangesUuid.java deleted file mode 100644 index 0c1b1767b00..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/PopulateIssueChangesUuid.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.issuechanges; - -import java.sql.SQLException; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateIssueChangesUuid extends DataChange { - - private final UuidFactory uuidFactory; - - public PopulateIssueChangesUuid(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select id from issue_changes where uuid is null order by id asc"); - massUpdate.update("update issue_changes set uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, uuidFactory.create()); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issues/AddPrimaryKeyOnKeeColumnOfIssuesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issues/AddPrimaryKeyOnKeeColumnOfIssuesTable.java deleted file mode 100644 index 84e03c5c4f8..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issues/AddPrimaryKeyOnKeeColumnOfIssuesTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.issues; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.AddPrimaryKeyBuilder; - -public class AddPrimaryKeyOnKeeColumnOfIssuesTable extends DdlChange { - - public AddPrimaryKeyOnKeeColumnOfIssuesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("issues", "kee").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issues/DropIdColumnOfIssuesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issues/DropIdColumnOfIssuesTable.java deleted file mode 100644 index 28685f5474f..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issues/DropIdColumnOfIssuesTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.issues; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropIdColumn; - -public class DropIdColumnOfIssuesTable extends DropIdColumn { - private static final String TABLE = "issues"; - - public DropIdColumnOfIssuesTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issues/DropPrimaryKeyOnIdColumnOfIssuesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issues/DropPrimaryKeyOnIdColumnOfIssuesTable.java deleted file mode 100644 index a1bf51daa51..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issues/DropPrimaryKeyOnIdColumnOfIssuesTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.issues; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; - -public class DropPrimaryKeyOnIdColumnOfIssuesTable extends DropPrimaryKeyOnIdColumn { - private static final String TABLE_NAME = "issues"; - - public DropPrimaryKeyOnIdColumnOfIssuesTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/AddPrimaryKeyOnUuidColumnOfManualMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/AddPrimaryKeyOnUuidColumnOfManualMeasuresTable.java deleted file mode 100644 index 79de63414f3..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/AddPrimaryKeyOnUuidColumnOfManualMeasuresTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.manualmeasures; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.AddPrimaryKeyBuilder; - -public class AddPrimaryKeyOnUuidColumnOfManualMeasuresTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfManualMeasuresTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("manual_measures", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/AddUuidColumnToManualMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/AddUuidColumnToManualMeasures.java deleted file mode 100644 index 3e7a6110779..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/AddUuidColumnToManualMeasures.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.manualmeasures; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddUuidColumnToManualMeasures extends DdlChange { - private static final String TABLE = "manual_measures"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddUuidColumnToManualMeasures(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/DropIdColumnOfManualMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/DropIdColumnOfManualMeasuresTable.java deleted file mode 100644 index c5af25c9f59..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/DropIdColumnOfManualMeasuresTable.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.manualmeasures; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropIdColumnOfManualMeasuresTable extends DdlChange { - - public DropIdColumnOfManualMeasuresTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "manual_measures", "id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/DropPrimaryKeyOnIdColumnOfManualMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/DropPrimaryKeyOnIdColumnOfManualMeasuresTable.java deleted file mode 100644 index 85f307727db..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/DropPrimaryKeyOnIdColumnOfManualMeasuresTable.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.manualmeasures; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; - -public class DropPrimaryKeyOnIdColumnOfManualMeasuresTable extends DdlChange { - - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator; - - public DropPrimaryKeyOnIdColumnOfManualMeasuresTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db); - this.dropPrimaryKeySqlGenerator = dropPrimaryKeySqlGenerator; - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(dropPrimaryKeySqlGenerator.generate("manual_measures", "id", true)); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/MakeManualMeasuresUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/MakeManualMeasuresUuidColumnNotNullable.java deleted file mode 100644 index 640549b492d..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/MakeManualMeasuresUuidColumnNotNullable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.manualmeasures; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeManualMeasuresUuidColumnNotNullable extends DdlChange { - private static final String TABLE = "manual_measures"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public MakeManualMeasuresUuidColumnNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/PopulateManualMeasureUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/PopulateManualMeasureUuid.java deleted file mode 100644 index d3a567fabee..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/PopulateManualMeasureUuid.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.manualmeasures; - -import java.sql.SQLException; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateManualMeasureUuid extends DataChange { - - private final UuidFactory uuidFactory; - - public PopulateManualMeasureUuid(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select id from manual_measures where uuid is null"); - massUpdate.update("update manual_measures set uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, uuidFactory.create()); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/AddPrimaryKeyOnUuidColumnOfMetricsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/AddPrimaryKeyOnUuidColumnOfMetricsTable.java deleted file mode 100644 index 652dc701a80..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/AddPrimaryKeyOnUuidColumnOfMetricsTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.AddPrimaryKeyBuilder; - -public class AddPrimaryKeyOnUuidColumnOfMetricsTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfMetricsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("metrics", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/AddUuidColumnToMetricsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/AddUuidColumnToMetricsTable.java deleted file mode 100644 index 9e13d3e5bed..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/AddUuidColumnToMetricsTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.AddUuidColumnToTable; - -public class AddUuidColumnToMetricsTable extends AddUuidColumnToTable { - private static final String TABLE = "metrics"; - - public AddUuidColumnToMetricsTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/DropIdColumnOfMetricsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/DropIdColumnOfMetricsTable.java deleted file mode 100644 index 7bce5f8109d..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/DropIdColumnOfMetricsTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropIdColumn; - -public class DropIdColumnOfMetricsTable extends DropIdColumn { - private static final String TABLE = "metrics"; - - public DropIdColumnOfMetricsTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/DropPrimaryKeyOnIdColumnOfMetricsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/DropPrimaryKeyOnIdColumnOfMetricsTable.java deleted file mode 100644 index 9f09c27d7db..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/DropPrimaryKeyOnIdColumnOfMetricsTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; - -public class DropPrimaryKeyOnIdColumnOfMetricsTable extends DropPrimaryKeyOnIdColumn { - private static final String TABLE_NAME = "metrics"; - - public DropPrimaryKeyOnIdColumnOfMetricsTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/MakeMetricsUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/MakeMetricsUuidColumnNotNullable.java deleted file mode 100644 index af417536dc3..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/MakeMetricsUuidColumnNotNullable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.MakeUuidColumnNotNullable; - -public class MakeMetricsUuidColumnNotNullable extends MakeUuidColumnNotNullable { - private static final String TABLE = "metrics"; - - public MakeMetricsUuidColumnNotNullable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/PopulateMetricsUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/PopulateMetricsUuid.java deleted file mode 100644 index 0edcee2caf6..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/PopulateMetricsUuid.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics; - -import java.sql.SQLException; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateMetricsUuid extends DataChange { - - private final UuidFactory uuidFactory; - - public PopulateMetricsUuid(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select id from metrics where uuid is null order by id asc"); - massUpdate.update("update metrics set uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, uuidFactory.create()); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/AddIndexOnMetricUuidOfLiveMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/AddIndexOnMetricUuidOfLiveMeasuresTable.java deleted file mode 100644 index 90f04d52594..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/AddIndexOnMetricUuidOfLiveMeasuresTable.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics.livemeasures; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddIndexOnMetricUuidOfLiveMeasuresTable extends DdlChange { - private static final String TABLE_NAME = "live_measures"; - private static final String INDEX_NAME = "live_measures_component"; - - public AddIndexOnMetricUuidOfLiveMeasuresTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (!indexExists()) { - context.execute(new CreateIndexBuilder() - .setUnique(true) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("component_uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build()) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("metric_uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build()) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/AddMetricUuidColumnToLiveMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/AddMetricUuidColumnToLiveMeasures.java deleted file mode 100644 index b0c3d41ac31..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/AddMetricUuidColumnToLiveMeasures.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics.livemeasures; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddMetricUuidColumnToLiveMeasures extends DdlChange { - private static final String TABLE = "live_measures"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("metric_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddMetricUuidColumnToLiveMeasures(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/DropIndexOnMetricIdOfLiveMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/DropIndexOnMetricIdOfLiveMeasuresTable.java deleted file mode 100644 index 3c1b5aa964d..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/DropIndexOnMetricIdOfLiveMeasuresTable.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics.livemeasures; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropIndexOnMetricIdOfLiveMeasuresTable extends DdlChange { - private static final String TABLE_NAME = "live_measures"; - private static final String INDEX_NAME = "live_measures_component"; - - public DropIndexOnMetricIdOfLiveMeasuresTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (indexExists()) { - context.execute(new DropIndexBuilder(getDialect()) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/DropMetricIdColumnOfLiveMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/DropMetricIdColumnOfLiveMeasuresTable.java deleted file mode 100644 index 619cb040b9d..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/DropMetricIdColumnOfLiveMeasuresTable.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics.livemeasures; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropMetricIdColumnOfLiveMeasuresTable extends DdlChange { - public DropMetricIdColumnOfLiveMeasuresTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "live_measures", "metric_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/MakeLiveMeasuresMetricUuidNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/MakeLiveMeasuresMetricUuidNotNullable.java deleted file mode 100644 index 3d34e113e83..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/MakeLiveMeasuresMetricUuidNotNullable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics.livemeasures; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeLiveMeasuresMetricUuidNotNullable extends DdlChange { - private static final String TABLE = "live_measures"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("metric_uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public MakeLiveMeasuresMetricUuidNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/PopulateLiveMeasuresMetricUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/PopulateLiveMeasuresMetricUuid.java deleted file mode 100644 index c977afa369f..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/PopulateLiveMeasuresMetricUuid.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics.livemeasures; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateLiveMeasuresMetricUuid extends DataChange { - - public PopulateLiveMeasuresMetricUuid(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select lm.uuid, m.uuid " + - "from live_measures lm " + - "join metrics m on lm.metric_id = m.id"); - - massUpdate.update("update live_measures set metric_uuid = ? where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(2)); - update.setString(2, row.getString(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/AddMetricUuidColumnToManualMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/AddMetricUuidColumnToManualMeasures.java deleted file mode 100644 index d4e87a84671..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/AddMetricUuidColumnToManualMeasures.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics.manualmeasures; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddMetricUuidColumnToManualMeasures extends DdlChange { - private static final String TABLE = "manual_measures"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("metric_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddMetricUuidColumnToManualMeasures(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/DropMetricIdColumnOfManualMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/DropMetricIdColumnOfManualMeasuresTable.java deleted file mode 100644 index 1685a2af332..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/DropMetricIdColumnOfManualMeasuresTable.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics.manualmeasures; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropMetricIdColumnOfManualMeasuresTable extends DdlChange { - public DropMetricIdColumnOfManualMeasuresTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "manual_measures", "metric_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/MakeManualMeasuresMetricUuidNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/MakeManualMeasuresMetricUuidNotNullable.java deleted file mode 100644 index 49b011f9f40..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/MakeManualMeasuresMetricUuidNotNullable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics.manualmeasures; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeManualMeasuresMetricUuidNotNullable extends DdlChange { - private static final String TABLE = "manual_measures"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("metric_uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public MakeManualMeasuresMetricUuidNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/PopulateManualMeasuresMetricUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/PopulateManualMeasuresMetricUuid.java deleted file mode 100644 index b3277075f29..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/PopulateManualMeasuresMetricUuid.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics.manualmeasures; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateManualMeasuresMetricUuid extends DataChange { - - public PopulateManualMeasuresMetricUuid(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select mm.uuid, m.uuid " + - "from manual_measures mm " + - "join metrics m on mm.metric_id = m.id"); - - massUpdate.update("update manual_measures set metric_uuid = ? where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(2)); - update.setString(2, row.getString(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/AddIndexOnMetricUuidOfProjectMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/AddIndexOnMetricUuidOfProjectMeasuresTable.java deleted file mode 100644 index 96d783e7aab..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/AddIndexOnMetricUuidOfProjectMeasuresTable.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics.projectmeasures; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddIndexOnMetricUuidOfProjectMeasuresTable extends DdlChange { - private static final String TABLE_NAME = "project_measures"; - private static final String INDEX_NAME = "measures_analysis_metric"; - - public AddIndexOnMetricUuidOfProjectMeasuresTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (!indexExists()) { - context.execute(new CreateIndexBuilder() - .setUnique(false) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("analysis_uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build()) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("metric_uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build()) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/AddMetricUuidColumnToProjectMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/AddMetricUuidColumnToProjectMeasures.java deleted file mode 100644 index 168917b237f..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/AddMetricUuidColumnToProjectMeasures.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics.projectmeasures; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddMetricUuidColumnToProjectMeasures extends DdlChange { - private static final String TABLE = "project_measures"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("metric_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddMetricUuidColumnToProjectMeasures(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/DropIndexOnMetricIdOfProjectMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/DropIndexOnMetricIdOfProjectMeasuresTable.java deleted file mode 100644 index c96583078af..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/DropIndexOnMetricIdOfProjectMeasuresTable.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics.projectmeasures; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropIndexOnMetricIdOfProjectMeasuresTable extends DdlChange { - private static final String TABLE_NAME = "project_measures"; - private static final String INDEX_NAME = "measures_analysis_metric"; - - public DropIndexOnMetricIdOfProjectMeasuresTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (indexExists()) { - context.execute(new DropIndexBuilder(getDialect()) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/DropMetricIdColumnOfProjectMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/DropMetricIdColumnOfProjectMeasuresTable.java deleted file mode 100644 index 2d3787da147..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/DropMetricIdColumnOfProjectMeasuresTable.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics.projectmeasures; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropMetricIdColumnOfProjectMeasuresTable extends DdlChange { - public DropMetricIdColumnOfProjectMeasuresTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "project_measures", "metric_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/MakeProjectMeasuresMetricUuidNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/MakeProjectMeasuresMetricUuidNotNullable.java deleted file mode 100644 index 4f2aeac199f..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/MakeProjectMeasuresMetricUuidNotNullable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics.projectmeasures; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeProjectMeasuresMetricUuidNotNullable extends DdlChange { - private static final String TABLE = "project_measures"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("metric_uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public MakeProjectMeasuresMetricUuidNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/PopulateProjectMeasuresMetricUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/PopulateProjectMeasuresMetricUuid.java deleted file mode 100644 index 389e4a28bd8..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/PopulateProjectMeasuresMetricUuid.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics.projectmeasures; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateProjectMeasuresMetricUuid extends DataChange { - - public PopulateProjectMeasuresMetricUuid(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select pm.uuid, m.uuid " + - "from project_measures pm " + - "join metrics m on pm.metric_id = m.id"); - - massUpdate.update("update project_measures set metric_uuid = ? where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(2)); - update.setString(2, row.getString(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/AddMetricUuidColumnToQualityGateConditions.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/AddMetricUuidColumnToQualityGateConditions.java deleted file mode 100644 index 89c47a84a0a..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/AddMetricUuidColumnToQualityGateConditions.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics.qualitygateconditions; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddMetricUuidColumnToQualityGateConditions extends DdlChange { - private static final String TABLE = "quality_gate_conditions"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("metric_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddMetricUuidColumnToQualityGateConditions(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/DropMetricIdColumnOfQualityGateConditionsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/DropMetricIdColumnOfQualityGateConditionsTable.java deleted file mode 100644 index 2e1613300f8..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/DropMetricIdColumnOfQualityGateConditionsTable.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics.qualitygateconditions; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropMetricIdColumnOfQualityGateConditionsTable extends DdlChange { - public DropMetricIdColumnOfQualityGateConditionsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "quality_gate_conditions", "metric_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/MakeQualityGateConditionsMetricUuidNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/MakeQualityGateConditionsMetricUuidNotNullable.java deleted file mode 100644 index c853fe66c5c..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/MakeQualityGateConditionsMetricUuidNotNullable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics.qualitygateconditions; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeQualityGateConditionsMetricUuidNotNullable extends DdlChange { - private static final String TABLE = "quality_gate_conditions"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("metric_uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public MakeQualityGateConditionsMetricUuidNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/PopulateQualityGateConditionsMetricUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/PopulateQualityGateConditionsMetricUuid.java deleted file mode 100644 index 7cf55ffd7af..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/PopulateQualityGateConditionsMetricUuid.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics.qualitygateconditions; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateQualityGateConditionsMetricUuid extends DataChange { - - public PopulateQualityGateConditionsMetricUuid(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - // delete quality gate conditions without a metric - context.prepareUpsert("delete from quality_gate_conditions where metric_id is null").execute(); - - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select qgc.uuid, m.uuid " + - "from quality_gate_conditions qgc " + - "join metrics m on qgc.metric_id = m.id"); - - massUpdate.update("update quality_gate_conditions set metric_uuid = ? where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(2)); - update.setString(2, row.getString(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/notifications/AddPrimaryKeyOnUuidColumnOfNotificationTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/notifications/AddPrimaryKeyOnUuidColumnOfNotificationTable.java deleted file mode 100644 index 83a9691f1ba..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/notifications/AddPrimaryKeyOnUuidColumnOfNotificationTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.notifications; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.AddPrimaryKeyBuilder; - -public class AddPrimaryKeyOnUuidColumnOfNotificationTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfNotificationTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("notifications", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/notifications/AddUuidAndCreatedAtColumnsToNotification.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/notifications/AddUuidAndCreatedAtColumnsToNotification.java deleted file mode 100644 index 749d54f6e5c..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/notifications/AddUuidAndCreatedAtColumnsToNotification.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.notifications; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.BigIntegerColumnDef; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.BigIntegerColumnDef.newBigIntegerColumnDefBuilder; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddUuidAndCreatedAtColumnsToNotification extends DdlChange { - private static final String TABLE = "notifications"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - private static final BigIntegerColumnDef createdAtColumnDefinition = newBigIntegerColumnDefBuilder() - .setColumnName("created_at") - .setIsNullable(true) - .build(); - - public AddUuidAndCreatedAtColumnsToNotification(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .addColumn(createdAtColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/notifications/DropIdColumnOfNotificationTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/notifications/DropIdColumnOfNotificationTable.java deleted file mode 100644 index f6b5fcc22ec..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/notifications/DropIdColumnOfNotificationTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.notifications; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropIdColumn; - -public class DropIdColumnOfNotificationTable extends DropIdColumn { - private static final String TABLE = "notifications"; - - public DropIdColumnOfNotificationTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/notifications/DropPrimaryKeyOnIdColumnOfNotificationTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/notifications/DropPrimaryKeyOnIdColumnOfNotificationTable.java deleted file mode 100644 index ce99e5f5012..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/notifications/DropPrimaryKeyOnIdColumnOfNotificationTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.notifications; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; - -public class DropPrimaryKeyOnIdColumnOfNotificationTable extends DropPrimaryKeyOnIdColumn { - private static final String TABLE_NAME = "notifications"; - - public DropPrimaryKeyOnIdColumnOfNotificationTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/notifications/MakeNotificationUuidAndCreatedAtColumnsNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/notifications/MakeNotificationUuidAndCreatedAtColumnsNotNullable.java deleted file mode 100644 index c0aa4de2f48..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/notifications/MakeNotificationUuidAndCreatedAtColumnsNotNullable.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.notifications; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.BigIntegerColumnDef; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.BigIntegerColumnDef.newBigIntegerColumnDefBuilder; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeNotificationUuidAndCreatedAtColumnsNotNullable extends DdlChange { - private static final String TABLE = "notifications"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - private static final BigIntegerColumnDef createdAtColumnDefinition = newBigIntegerColumnDefBuilder() - .setColumnName("created_at") - .setIsNullable(false) - .build(); - - - public MakeNotificationUuidAndCreatedAtColumnsNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(uuidColumnDefinition) - .updateColumn(createdAtColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/notifications/PopulateNotificationUuidAndCreatedAt.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/notifications/PopulateNotificationUuidAndCreatedAt.java deleted file mode 100644 index 0c5eeb43b28..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/notifications/PopulateNotificationUuidAndCreatedAt.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.notifications; - -import java.sql.SQLException; -import java.util.concurrent.atomic.AtomicLong; -import org.sonar.api.utils.System2; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateNotificationUuidAndCreatedAt extends DataChange { - - private final UuidFactory uuidFactory; - private final System2 system2; - - public PopulateNotificationUuidAndCreatedAt(Database db, UuidFactory uuidFactory, System2 system2) { - super(db); - this.uuidFactory = uuidFactory; - this.system2 = system2; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select id from notifications where uuid is null order by id asc"); - massUpdate.update("update notifications set uuid = ?, created_at = ? where id = ?"); - - // now - 7 days, to have previous notification in the past - long lastWeek = system2.now() - (1000 * 60 * 60 * 24 * 7); - - AtomicLong cpt = new AtomicLong(0); - massUpdate.execute((row, update) -> { - update.setString(1, uuidFactory.create()); - update.setLong(2, lastWeek + cpt.longValue()); - update.setLong(3, row.getLong(1)); - cpt.addAndGet(1); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/package-info.java deleted file mode 100644 index a671d6ae95d..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.platform.db.migration.version.v83; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTable.java deleted file mode 100644 index 27bbbb1fe21..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permissiontemplates; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.AddPrimaryKeyBuilder; - -public class AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("permission_templates", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/AddUuidColumnToPermissionTemplates.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/AddUuidColumnToPermissionTemplates.java deleted file mode 100644 index 718fb3265ed..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/AddUuidColumnToPermissionTemplates.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permissiontemplates; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.AddUuidColumnToTable; - -public class AddUuidColumnToPermissionTemplates extends AddUuidColumnToTable { - private static final String TABLE_NAME = "permission_templates"; - - public AddUuidColumnToPermissionTemplates(Database db) { - super(db, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/DropIdColumnOfPermissionTemplatesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/DropIdColumnOfPermissionTemplatesTable.java deleted file mode 100644 index 7aefd8a625e..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/DropIdColumnOfPermissionTemplatesTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permissiontemplates; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropIdColumn; - -public class DropIdColumnOfPermissionTemplatesTable extends DropIdColumn { - private static final String TABLE_NAME = "permission_templates"; - - public DropIdColumnOfPermissionTemplatesTable(Database db) { - super(db, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/DropKeeColumnOfPermissionTemplatesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/DropKeeColumnOfPermissionTemplatesTable.java deleted file mode 100644 index ae944fb0fd1..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/DropKeeColumnOfPermissionTemplatesTable.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permissiontemplates; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropKeeColumnOfPermissionTemplatesTable extends DdlChange { - - public DropKeeColumnOfPermissionTemplatesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "permission_templates", "kee").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/DropPrimaryKeyOnIdColumnOfPermissionTemplatesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/DropPrimaryKeyOnIdColumnOfPermissionTemplatesTable.java deleted file mode 100644 index 62be9191725..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/DropPrimaryKeyOnIdColumnOfPermissionTemplatesTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permissiontemplates; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; - -public class DropPrimaryKeyOnIdColumnOfPermissionTemplatesTable extends DropPrimaryKeyOnIdColumn { - private static final String TABLE_NAME = "permission_templates"; - - public DropPrimaryKeyOnIdColumnOfPermissionTemplatesTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/MakePermissionTemplateUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/MakePermissionTemplateUuidColumnNotNullable.java deleted file mode 100644 index 7165abf4026..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/MakePermissionTemplateUuidColumnNotNullable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permissiontemplates; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.MakeUuidColumnNotNullable; - -public class MakePermissionTemplateUuidColumnNotNullable extends MakeUuidColumnNotNullable { - private static final String TABLE_NAME = "permission_templates"; - - public MakePermissionTemplateUuidColumnNotNullable(Database db) { - super(db, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/PopulatePermissionTemplatesUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/PopulatePermissionTemplatesUuid.java deleted file mode 100644 index 03bcd28390f..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/PopulatePermissionTemplatesUuid.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permissiontemplates; - -import java.sql.SQLException; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulatePermissionTemplatesUuid extends DataChange { - - private UuidFactory uuidFactory; - - public PopulatePermissionTemplatesUuid(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select kee from permission_templates where uuid is null"); - massUpdate.update("update permission_templates set uuid = ? where kee = ?"); - - massUpdate.execute((row, update) -> { - String kee = row.getString(1); - String uuid = kee; - - //kee column was declared with 100 char length, so we regenerate if it happened - if (kee.length() > 40) { - uuid = uuidFactory.create(); - } - - update.setString(1, uuid); - update.setString(2, kee); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/AddTemplateUuidColumnToPermTemplatesGroups.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/AddTemplateUuidColumnToPermTemplatesGroups.java deleted file mode 100644 index b494eeb81fa..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/AddTemplateUuidColumnToPermTemplatesGroups.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permissiontemplates.fk.permtemplatesgroups; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddTemplateUuidColumnToPermTemplatesGroups extends DdlChange { - private static final String TABLE = "perm_templates_groups"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("template_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddTemplateUuidColumnToPermTemplatesGroups(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/DropTemplateIdColumnOfPermTemplatesGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/DropTemplateIdColumnOfPermTemplatesGroupsTable.java deleted file mode 100644 index d7ef97571b5..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/DropTemplateIdColumnOfPermTemplatesGroupsTable.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permissiontemplates.fk.permtemplatesgroups; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropTemplateIdColumnOfPermTemplatesGroupsTable extends DdlChange { - - public DropTemplateIdColumnOfPermTemplatesGroupsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "perm_templates_groups", "template_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/MakePermTemplatesGroupsTemplateUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/MakePermTemplatesGroupsTemplateUuidColumnNotNullable.java deleted file mode 100644 index 5bcd439932e..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/MakePermTemplatesGroupsTemplateUuidColumnNotNullable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permissiontemplates.fk.permtemplatesgroups; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakePermTemplatesGroupsTemplateUuidColumnNotNullable extends DdlChange { - private static final String TABLE = "perm_templates_groups"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("template_uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public MakePermTemplatesGroupsTemplateUuidColumnNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/PopulatePermTemplatesGroupsTemplateUuidColumn.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/PopulatePermTemplatesGroupsTemplateUuidColumn.java deleted file mode 100644 index a8f47584604..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/PopulatePermTemplatesGroupsTemplateUuidColumn.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permissiontemplates.fk.permtemplatesgroups; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulatePermTemplatesGroupsTemplateUuidColumn extends DataChange { - - public PopulatePermTemplatesGroupsTemplateUuidColumn(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select ptg.uuid, pt.uuid " + - "from perm_templates_groups ptg " + - "join permission_templates pt on ptg.template_id = pt.id " + - "where ptg.template_uuid is null"); - massUpdate.update("update perm_templates_groups set template_uuid = ? where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(2)); - update.setString(2, row.getString(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/AddTemplateUuidColumnToPermTemplatesUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/AddTemplateUuidColumnToPermTemplatesUsers.java deleted file mode 100644 index 84ca5c77eb8..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/AddTemplateUuidColumnToPermTemplatesUsers.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permissiontemplates.fk.permtemplatesusers; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddTemplateUuidColumnToPermTemplatesUsers extends DdlChange { - private static final String TABLE = "perm_templates_users"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("template_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddTemplateUuidColumnToPermTemplatesUsers(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/DropTemplateIdColumnOfPermTemplatesUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/DropTemplateIdColumnOfPermTemplatesUsersTable.java deleted file mode 100644 index 8b5b9fc7861..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/DropTemplateIdColumnOfPermTemplatesUsersTable.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permissiontemplates.fk.permtemplatesusers; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropTemplateIdColumnOfPermTemplatesUsersTable extends DdlChange { - - public DropTemplateIdColumnOfPermTemplatesUsersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "perm_templates_users", "template_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/MakePermTemplatesUsersTemplateUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/MakePermTemplatesUsersTemplateUuidColumnNotNullable.java deleted file mode 100644 index 7fae47a5237..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/MakePermTemplatesUsersTemplateUuidColumnNotNullable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permissiontemplates.fk.permtemplatesusers; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakePermTemplatesUsersTemplateUuidColumnNotNullable extends DdlChange { - private static final String TABLE = "perm_templates_users"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("template_uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public MakePermTemplatesUsersTemplateUuidColumnNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/PopulatePermTemplatesUsersTemplateUuidColumn.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/PopulatePermTemplatesUsersTemplateUuidColumn.java deleted file mode 100644 index e23e10e2863..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/PopulatePermTemplatesUsersTemplateUuidColumn.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permissiontemplates.fk.permtemplatesusers; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulatePermTemplatesUsersTemplateUuidColumn extends DataChange { - - public PopulatePermTemplatesUsersTemplateUuidColumn(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select ptu.uuid, pt.uuid " + - "from perm_templates_users ptu " + - "join permission_templates pt on ptu.template_id = pt.id " + - "where ptu.template_uuid is null"); - massUpdate.update("update perm_templates_users set template_uuid = ? where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(2)); - update.setString(2, row.getString(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/AddTemplateUuidColumnToPermTplCharacteristics.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/AddTemplateUuidColumnToPermTplCharacteristics.java deleted file mode 100644 index 74ab31e2122..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/AddTemplateUuidColumnToPermTplCharacteristics.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permissiontemplates.fk.permtplcharacteristics; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddTemplateUuidColumnToPermTplCharacteristics extends DdlChange { - private static final String TABLE = "perm_tpl_characteristics"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("template_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddTemplateUuidColumnToPermTplCharacteristics(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTable.java deleted file mode 100644 index 523a4d7886e..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTable.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permissiontemplates.fk.permtplcharacteristics; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTable extends DdlChange { - private static final String TABLE_NAME = "perm_tpl_characteristics"; - private static final String INDEX_NAME = "uniq_perm_tpl_charac"; - - public AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (!indexExists()) { - context.execute(new CreateIndexBuilder() - .setUnique(true) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("template_uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build()) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("permission_key") - .setIsNullable(false) - .setLimit(64) - .build()) - .build()); - } - - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/DropTemplateIdColumnOfPermTplCharacteristicsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/DropTemplateIdColumnOfPermTplCharacteristicsTable.java deleted file mode 100644 index 12a36718869..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/DropTemplateIdColumnOfPermTplCharacteristicsTable.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permissiontemplates.fk.permtplcharacteristics; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropTemplateIdColumnOfPermTplCharacteristicsTable extends DdlChange { - - public DropTemplateIdColumnOfPermTplCharacteristicsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "perm_tpl_characteristics", "template_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTable.java deleted file mode 100644 index 133403afb69..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTable.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permissiontemplates.fk.permtplcharacteristics; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTable extends DdlChange { - private static final String TABLE_NAME = "perm_tpl_characteristics"; - private static final String INDEX_NAME = "uniq_perm_tpl_charac"; - - public DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (indexExists()) { - context.execute(new DropIndexBuilder(getDialect()) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/MakePermTplCharacteristicsTemplateUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/MakePermTplCharacteristicsTemplateUuidColumnNotNullable.java deleted file mode 100644 index 7b3122bdd69..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/MakePermTplCharacteristicsTemplateUuidColumnNotNullable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permissiontemplates.fk.permtplcharacteristics; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakePermTplCharacteristicsTemplateUuidColumnNotNullable extends DdlChange { - private static final String TABLE = "perm_tpl_characteristics"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("template_uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public MakePermTplCharacteristicsTemplateUuidColumnNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/PopulatePermTplCharacteristicsTemplateUuidColumn.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/PopulatePermTplCharacteristicsTemplateUuidColumn.java deleted file mode 100644 index 58e20a239f9..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/PopulatePermTplCharacteristicsTemplateUuidColumn.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permissiontemplates.fk.permtplcharacteristics; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulatePermTplCharacteristicsTemplateUuidColumn extends DataChange { - - public PopulatePermTplCharacteristicsTemplateUuidColumn(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select ptc.uuid, pt.uuid " + - "from perm_tpl_characteristics ptc " + - "join permission_templates pt on ptc.template_id = pt.id " + - "where ptc.template_uuid is null"); - massUpdate.update("update perm_tpl_characteristics set template_uuid = ? where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(2)); - update.setString(2, row.getString(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTable.java deleted file mode 100644 index 17e67b99e83..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permtemplatesgroups; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.AddPrimaryKeyBuilder; - -public class AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("perm_templates_groups", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/AddUuidColumnToPermTemplatesGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/AddUuidColumnToPermTemplatesGroupsTable.java deleted file mode 100644 index 1ec142aa6bf..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/AddUuidColumnToPermTemplatesGroupsTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permtemplatesgroups; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.AddUuidColumnToTable; - -public class AddUuidColumnToPermTemplatesGroupsTable extends AddUuidColumnToTable { - private static final String TABLE = "perm_templates_groups"; - - public AddUuidColumnToPermTemplatesGroupsTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/DropIdColumnOfPermTemplatesGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/DropIdColumnOfPermTemplatesGroupsTable.java deleted file mode 100644 index e3401f9633a..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/DropIdColumnOfPermTemplatesGroupsTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permtemplatesgroups; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropIdColumn; - -public class DropIdColumnOfPermTemplatesGroupsTable extends DropIdColumn { - private static final String TABLE = "perm_templates_groups"; - - public DropIdColumnOfPermTemplatesGroupsTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTable.java deleted file mode 100644 index c84fbd431be..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permtemplatesgroups; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; - -public class DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTable extends DropPrimaryKeyOnIdColumn { - private static final String TABLE_NAME = "perm_templates_groups"; - - public DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/MakePermTemplatesGroupsUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/MakePermTemplatesGroupsUuidColumnNotNullable.java deleted file mode 100644 index 39919e02343..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/MakePermTemplatesGroupsUuidColumnNotNullable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permtemplatesgroups; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.MakeUuidColumnNotNullable; - -public class MakePermTemplatesGroupsUuidColumnNotNullable extends MakeUuidColumnNotNullable { - private static final String TABLE = "perm_templates_groups"; - - public MakePermTemplatesGroupsUuidColumnNotNullable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/PopulatePermTemplatesGroupsUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/PopulatePermTemplatesGroupsUuid.java deleted file mode 100644 index 6b1f0d0c6d4..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/PopulatePermTemplatesGroupsUuid.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permtemplatesgroups; - -import java.sql.SQLException; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulatePermTemplatesGroupsUuid extends DataChange { - - private final UuidFactory uuidFactory; - - public PopulatePermTemplatesGroupsUuid(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select id from perm_templates_groups where uuid is null order by id asc"); - massUpdate.update("update perm_templates_groups set uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, uuidFactory.create()); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTable.java deleted file mode 100644 index 42d6af094a7..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permtemplatesusers; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.AddPrimaryKeyBuilder; - -public class AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("perm_templates_users", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/AddUuidColumnToPermTemplatesUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/AddUuidColumnToPermTemplatesUsersTable.java deleted file mode 100644 index 1fc2d72952a..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/AddUuidColumnToPermTemplatesUsersTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permtemplatesusers; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.AddUuidColumnToTable; - -public class AddUuidColumnToPermTemplatesUsersTable extends AddUuidColumnToTable { - private static final String TABLE = "perm_templates_users"; - - public AddUuidColumnToPermTemplatesUsersTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/DropIdColumnOfPermTemplatesUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/DropIdColumnOfPermTemplatesUsersTable.java deleted file mode 100644 index 978a431df6d..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/DropIdColumnOfPermTemplatesUsersTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permtemplatesusers; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropIdColumn; - -public class DropIdColumnOfPermTemplatesUsersTable extends DropIdColumn { - private static final String TABLE = "perm_templates_users"; - - public DropIdColumnOfPermTemplatesUsersTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTable.java deleted file mode 100644 index 46bf6a4c8c6..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permtemplatesusers; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; - -public class DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTable extends DropPrimaryKeyOnIdColumn { - private static final String TABLE_NAME = "perm_templates_users"; - - public DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/MakePermTemplatesUsersUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/MakePermTemplatesUsersUuidColumnNotNullable.java deleted file mode 100644 index 6c2b9bedca3..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/MakePermTemplatesUsersUuidColumnNotNullable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permtemplatesusers; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.MakeUuidColumnNotNullable; - -public class MakePermTemplatesUsersUuidColumnNotNullable extends MakeUuidColumnNotNullable { - private static final String TABLE = "perm_templates_users"; - - public MakePermTemplatesUsersUuidColumnNotNullable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/PopulatePermTemplatesUsersUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/PopulatePermTemplatesUsersUuid.java deleted file mode 100644 index e15d013b4a4..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/PopulatePermTemplatesUsersUuid.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permtemplatesusers; - -import java.sql.SQLException; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulatePermTemplatesUsersUuid extends DataChange { - - private final UuidFactory uuidFactory; - - public PopulatePermTemplatesUsersUuid(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select id from perm_templates_users where uuid is null order by id asc"); - massUpdate.update("update perm_templates_users set uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, uuidFactory.create()); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTable.java deleted file mode 100644 index db11ad587f5..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permtplcharacteristics; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.AddPrimaryKeyBuilder; - -public class AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("perm_tpl_characteristics", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/AddUuidColumnToPermTplCharacteristicsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/AddUuidColumnToPermTplCharacteristicsTable.java deleted file mode 100644 index 3036ca91ab5..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/AddUuidColumnToPermTplCharacteristicsTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permtplcharacteristics; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.AddUuidColumnToTable; - -public class AddUuidColumnToPermTplCharacteristicsTable extends AddUuidColumnToTable { - private static final String TABLE = "perm_tpl_characteristics"; - - public AddUuidColumnToPermTplCharacteristicsTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/DropIdColumnOfPermTplCharacteristicsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/DropIdColumnOfPermTplCharacteristicsTable.java deleted file mode 100644 index a24f52f355d..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/DropIdColumnOfPermTplCharacteristicsTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permtplcharacteristics; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropIdColumn; - -public class DropIdColumnOfPermTplCharacteristicsTable extends DropIdColumn { - private static final String TABLE = "perm_tpl_characteristics"; - - public DropIdColumnOfPermTplCharacteristicsTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTable.java deleted file mode 100644 index 41a8a5eaf07..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permtplcharacteristics; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; - -public class DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTable extends DropPrimaryKeyOnIdColumn { - private static final String TABLE_NAME = "perm_tpl_characteristics"; - - public DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/MakePermTplCharacteristicsUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/MakePermTplCharacteristicsUuidColumnNotNullable.java deleted file mode 100644 index a1dc21995c2..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/MakePermTplCharacteristicsUuidColumnNotNullable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permtplcharacteristics; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.MakeUuidColumnNotNullable; - -public class MakePermTplCharacteristicsUuidColumnNotNullable extends MakeUuidColumnNotNullable { - private static final String TABLE = "perm_tpl_characteristics"; - - public MakePermTplCharacteristicsUuidColumnNotNullable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/PopulatePermTplCharacteristicsUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/PopulatePermTplCharacteristicsUuid.java deleted file mode 100644 index 446310035de..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/PopulatePermTplCharacteristicsUuid.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permtplcharacteristics; - -import java.sql.SQLException; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulatePermTplCharacteristicsUuid extends DataChange { - - private final UuidFactory uuidFactory; - - public PopulatePermTplCharacteristicsUuid(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select id from perm_tpl_characteristics where uuid is null order by id asc"); - massUpdate.update("update perm_tpl_characteristics set uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, uuidFactory.create()); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/AddPrimaryKeyOnUuidColumnOfProjectMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/AddPrimaryKeyOnUuidColumnOfProjectMeasuresTable.java deleted file mode 100644 index a8438e31687..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/AddPrimaryKeyOnUuidColumnOfProjectMeasuresTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.projectmeasures; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.AddPrimaryKeyBuilder; - -public class AddPrimaryKeyOnUuidColumnOfProjectMeasuresTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfProjectMeasuresTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("project_measures", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/AddUuidColumnToProjectMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/AddUuidColumnToProjectMeasures.java deleted file mode 100644 index aaa004f9eca..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/AddUuidColumnToProjectMeasures.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.projectmeasures; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.AddUuidColumnToTable; - -public class AddUuidColumnToProjectMeasures extends AddUuidColumnToTable { - private static final String TABLE = "project_measures"; - - public AddUuidColumnToProjectMeasures(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/DropIdColumnOfProjectMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/DropIdColumnOfProjectMeasuresTable.java deleted file mode 100644 index 76eeaca7aa9..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/DropIdColumnOfProjectMeasuresTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.projectmeasures; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropIdColumn; - -public class DropIdColumnOfProjectMeasuresTable extends DropIdColumn { - private static final String TABLE = "project_measures"; - - public DropIdColumnOfProjectMeasuresTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/DropPrimaryKeyOnIdColumnOfProjectMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/DropPrimaryKeyOnIdColumnOfProjectMeasuresTable.java deleted file mode 100644 index a5359f27e01..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/DropPrimaryKeyOnIdColumnOfProjectMeasuresTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.projectmeasures; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; - -public class DropPrimaryKeyOnIdColumnOfProjectMeasuresTable extends DropPrimaryKeyOnIdColumn { - private static final String TABLE_NAME = "project_measures"; - - public DropPrimaryKeyOnIdColumnOfProjectMeasuresTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/MakeProjectMeasuresUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/MakeProjectMeasuresUuidColumnNotNullable.java deleted file mode 100644 index 63fe23e3cc1..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/MakeProjectMeasuresUuidColumnNotNullable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.projectmeasures; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.MakeUuidColumnNotNullable; - -public class MakeProjectMeasuresUuidColumnNotNullable extends MakeUuidColumnNotNullable { - private static final String TABLE = "project_measures"; - - public MakeProjectMeasuresUuidColumnNotNullable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/PopulateProjectMeasureUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/PopulateProjectMeasureUuid.java deleted file mode 100644 index 25cdf954177..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/PopulateProjectMeasureUuid.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.projectmeasures; - -import java.sql.SQLException; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateProjectMeasureUuid extends DataChange { - - private final UuidFactory uuidFactory; - - public PopulateProjectMeasureUuid(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select id from project_measures where uuid is null"); - massUpdate.update("update project_measures set uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, uuidFactory.create()); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTable.java deleted file mode 100644 index daa7ec62b11..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.projectqprofiles; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.AddPrimaryKeyBuilder; - -public class AddPrimaryKeyOnUuidColumnOfProjectQProfilesTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfProjectQProfilesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("project_qprofiles", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/AddUuidColumnToProjectQProfilesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/AddUuidColumnToProjectQProfilesTable.java deleted file mode 100644 index b351b586a1b..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/AddUuidColumnToProjectQProfilesTable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.projectqprofiles; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddUuidColumnToProjectQProfilesTable extends DdlChange { - private static final String TABLE = "project_qprofiles"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddUuidColumnToProjectQProfilesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/DropIdColumnOfProjectQProfilesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/DropIdColumnOfProjectQProfilesTable.java deleted file mode 100644 index 4f086167490..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/DropIdColumnOfProjectQProfilesTable.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.projectqprofiles; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropIdColumnOfProjectQProfilesTable extends DdlChange { - - private Database db; - - public DropIdColumnOfProjectQProfilesTable(Database db) { - super(db); - this.db = db; - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(db.getDialect(), "project_qprofiles", "id").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTable.java deleted file mode 100644 index c7955828d99..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTable.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.projectqprofiles; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; - -public class DropPrimaryKeyOnIdColumnOfProjectQProfilesTable extends DdlChange { - - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator; - - public DropPrimaryKeyOnIdColumnOfProjectQProfilesTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db); - this.dropPrimaryKeySqlGenerator = dropPrimaryKeySqlGenerator; - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(dropPrimaryKeySqlGenerator.generate("project_qprofiles", "id", true)); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/MakeProjectQProfilesUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/MakeProjectQProfilesUuidColumnNotNullable.java deleted file mode 100644 index 39cdc82baa1..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/MakeProjectQProfilesUuidColumnNotNullable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.projectqprofiles; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeProjectQProfilesUuidColumnNotNullable extends DdlChange { - private static final String TABLE = "project_qprofiles"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public MakeProjectQProfilesUuidColumnNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/PopulateProjectQProfilesUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/PopulateProjectQProfilesUuid.java deleted file mode 100644 index 863b7c24e49..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/PopulateProjectQProfilesUuid.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.projectqprofiles; - -import java.sql.SQLException; -import java.util.concurrent.atomic.AtomicLong; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateProjectQProfilesUuid extends DataChange { - - private final UuidFactory uuidFactory; - - public PopulateProjectQProfilesUuid(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select id from project_qprofiles where uuid is null"); - massUpdate.update("update project_qprofiles set uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, uuidFactory.create()); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/properties/AddPrimaryKeyOnUuidColumnOfPropertiesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/properties/AddPrimaryKeyOnUuidColumnOfPropertiesTable.java deleted file mode 100644 index 4ef0f7c5aa2..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/properties/AddPrimaryKeyOnUuidColumnOfPropertiesTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.properties; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.AddPrimaryKeyBuilder; - -public class AddPrimaryKeyOnUuidColumnOfPropertiesTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfPropertiesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("properties", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/properties/AddUuidColumnToProperties.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/properties/AddUuidColumnToProperties.java deleted file mode 100644 index 2a71939fcd6..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/properties/AddUuidColumnToProperties.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.properties; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.AddUuidColumnToTable; - -public class AddUuidColumnToProperties extends AddUuidColumnToTable { - private static final String TABLE_NAME = "properties"; - - public AddUuidColumnToProperties(Database db) { - super(db, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/properties/DropIdColumnOfPropertiesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/properties/DropIdColumnOfPropertiesTable.java deleted file mode 100644 index 83901aaaa4c..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/properties/DropIdColumnOfPropertiesTable.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.properties; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropIdColumnOfPropertiesTable extends DdlChange { - - public DropIdColumnOfPropertiesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "properties", "id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/properties/DropPrimaryKeyOnIdColumnOfPropertiesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/properties/DropPrimaryKeyOnIdColumnOfPropertiesTable.java deleted file mode 100644 index bb36cd4d85b..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/properties/DropPrimaryKeyOnIdColumnOfPropertiesTable.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.properties; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; - -public class DropPrimaryKeyOnIdColumnOfPropertiesTable extends DropPrimaryKeyOnIdColumn { - - private static final String TABLE_NAME = "properties"; - - public DropPrimaryKeyOnIdColumnOfPropertiesTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/properties/MakePropertiesUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/properties/MakePropertiesUuidColumnNotNullable.java deleted file mode 100644 index 802e38103d5..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/properties/MakePropertiesUuidColumnNotNullable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.properties; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.MakeUuidColumnNotNullable; - -public class MakePropertiesUuidColumnNotNullable extends MakeUuidColumnNotNullable { - private static final String TABLE_NAME = "properties"; - - public MakePropertiesUuidColumnNotNullable(Database db) { - super(db, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/properties/PopulatePropertiesUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/properties/PopulatePropertiesUuid.java deleted file mode 100644 index 321fd08dbac..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/properties/PopulatePropertiesUuid.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.properties; - -import java.sql.SQLException; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulatePropertiesUuid extends DataChange { - - private final UuidFactory uuidFactory; - - public PopulatePropertiesUuid(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select id from properties where uuid is null order by id asc"); - massUpdate.update("update properties set uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, uuidFactory.create()); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTable.java deleted file mode 100644 index c69ffbeffd0..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.qualitygateconditions; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.AddPrimaryKeyBuilder; - -public class AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("quality_gate_conditions", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/AddUuidColumnToQualityGateConditionsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/AddUuidColumnToQualityGateConditionsTable.java deleted file mode 100644 index 34c7ed0d4b1..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/AddUuidColumnToQualityGateConditionsTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.qualitygateconditions; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.AddUuidColumnToTable; - -public class AddUuidColumnToQualityGateConditionsTable extends AddUuidColumnToTable { - private static final String TABLE = "quality_gate_conditions"; - - public AddUuidColumnToQualityGateConditionsTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/DropIdColumnOfQualityGateConditionsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/DropIdColumnOfQualityGateConditionsTable.java deleted file mode 100644 index 5ea1809a672..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/DropIdColumnOfQualityGateConditionsTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.qualitygateconditions; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropIdColumn; - -public class DropIdColumnOfQualityGateConditionsTable extends DropIdColumn { - private static final String TABLE = "quality_gate_conditions"; - - public DropIdColumnOfQualityGateConditionsTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/DropPrimaryKeyOnIdColumnOfQualityGateConditionsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/DropPrimaryKeyOnIdColumnOfQualityGateConditionsTable.java deleted file mode 100644 index c1b89875c8a..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/DropPrimaryKeyOnIdColumnOfQualityGateConditionsTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.qualitygateconditions; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; - -public class DropPrimaryKeyOnIdColumnOfQualityGateConditionsTable extends DropPrimaryKeyOnIdColumn { - private static final String TABLE_NAME = "quality_gate_conditions"; - - public DropPrimaryKeyOnIdColumnOfQualityGateConditionsTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/MakeQualityGateConditionsUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/MakeQualityGateConditionsUuidColumnNotNullable.java deleted file mode 100644 index c1835b49bc0..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/MakeQualityGateConditionsUuidColumnNotNullable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.qualitygateconditions; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.MakeUuidColumnNotNullable; - -public class MakeQualityGateConditionsUuidColumnNotNullable extends MakeUuidColumnNotNullable { - private static final String TABLE = "quality_gate_conditions"; - - public MakeQualityGateConditionsUuidColumnNotNullable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/PopulateQualityGateConditionsUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/PopulateQualityGateConditionsUuid.java deleted file mode 100644 index 8a7447de24c..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/PopulateQualityGateConditionsUuid.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.qualitygateconditions; - -import java.sql.SQLException; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateQualityGateConditionsUuid extends DataChange { - - private final UuidFactory uuidFactory; - - public PopulateQualityGateConditionsUuid(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select id from quality_gate_conditions where uuid is null order by id asc"); - massUpdate.update("update quality_gate_conditions set uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, uuidFactory.create()); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/AddPrimaryKeyOnUuidColumnOfQGatesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/AddPrimaryKeyOnUuidColumnOfQGatesTable.java deleted file mode 100644 index 39f3a387b03..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/AddPrimaryKeyOnUuidColumnOfQGatesTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.qualitygates; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.AddPrimaryKeyBuilder; - -public class AddPrimaryKeyOnUuidColumnOfQGatesTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfQGatesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("quality_gates", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/AddQGateUuidColumnForQGateConditions.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/AddQGateUuidColumnForQGateConditions.java deleted file mode 100644 index 25d0e2a4818..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/AddQGateUuidColumnForQGateConditions.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.qualitygates; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.common.AddUuidColumnToTable; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddQGateUuidColumnForQGateConditions extends DdlChange { - private static final String TABLE = "quality_gate_conditions"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("qgate_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddQGateUuidColumnForQGateConditions(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropIdColumnOfQGateTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropIdColumnOfQGateTable.java deleted file mode 100644 index 852d20f9ca8..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropIdColumnOfQGateTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.qualitygates; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropIdColumn; - -public class DropIdColumnOfQGateTable extends DropIdColumn { - private static final String TABLE = "quality_gates"; - - public DropIdColumnOfQGateTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropOrphansQGateConditions.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropOrphansQGateConditions.java deleted file mode 100644 index 829d5da8058..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropOrphansQGateConditions.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.qualitygates; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class DropOrphansQGateConditions extends DataChange { - - public DropOrphansQGateConditions(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select uuid from quality_gate_conditions where qgate_uuid is null"); - massUpdate.update("delete from quality_gate_conditions where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropPrimaryKeyOnIdColumnOfQGatesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropPrimaryKeyOnIdColumnOfQGatesTable.java deleted file mode 100644 index a74f42db3ff..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropPrimaryKeyOnIdColumnOfQGatesTable.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.qualitygates; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; - -public class DropPrimaryKeyOnIdColumnOfQGatesTable extends DropPrimaryKeyOnIdColumn { - - private static final String TABLE_NAME = "quality_gates"; - - public DropPrimaryKeyOnIdColumnOfQGatesTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropQGateIdColumnForQGateConditions.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropQGateIdColumnForQGateConditions.java deleted file mode 100644 index a0a4ee4e81b..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropQGateIdColumnForQGateConditions.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.qualitygates; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropQGateIdColumnForQGateConditions extends DdlChange { - - private Database db; - - public DropQGateIdColumnForQGateConditions(Database db) { - super(db); - this.db = db; - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(db.getDialect(), "quality_gate_conditions", "qgate_id").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropUniqueIndexOnUuidColumnOfQualityGatesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropUniqueIndexOnUuidColumnOfQualityGatesTable.java deleted file mode 100644 index d1064194296..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropUniqueIndexOnUuidColumnOfQualityGatesTable.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.qualitygates; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropUniqueIndexOnUuidColumnOfQualityGatesTable extends DdlChange { - - public DropUniqueIndexOnUuidColumnOfQualityGatesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropIndexBuilder(getDialect()) - .setTable("quality_gates") - .setName("uniq_quality_gates_uuid") - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/MakeQGateUuidColumnNotNullableForQGateConditions.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/MakeQGateUuidColumnNotNullableForQGateConditions.java deleted file mode 100644 index 2405199c9da..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/MakeQGateUuidColumnNotNullableForQGateConditions.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.qualitygates; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeQGateUuidColumnNotNullableForQGateConditions extends DdlChange { - private static final String TABLE = "quality_gate_conditions"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("qgate_uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public MakeQGateUuidColumnNotNullableForQGateConditions(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/PopulateQGateUuidColumnForQGateConditions.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/PopulateQGateUuidColumnForQGateConditions.java deleted file mode 100644 index 878309dc341..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/PopulateQGateUuidColumnForQGateConditions.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.qualitygates; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateQGateUuidColumnForQGateConditions extends DataChange { - - public PopulateQGateUuidColumnForQGateConditions(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select uuid, id from quality_gates order by id asc"); - massUpdate.update("update quality_gate_conditions set qgate_uuid = ? where qgate_id = ? and qgate_uuid is null"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(1)); - update.setLong(2, row.getLong(2)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/AddPrimaryKeyOnUuidColumnOfRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/AddPrimaryKeyOnUuidColumnOfRulesTable.java deleted file mode 100644 index 54636e8f742..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/AddPrimaryKeyOnUuidColumnOfRulesTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.AddPrimaryKeyBuilder; - -public class AddPrimaryKeyOnUuidColumnOfRulesTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfRulesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("rules", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/AddUuidAndTemplateUuidColumnsToRules.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/AddUuidAndTemplateUuidColumnsToRules.java deleted file mode 100644 index ba203f53a7d..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/AddUuidAndTemplateUuidColumnsToRules.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddUuidAndTemplateUuidColumnsToRules extends DdlChange { - private static final String TABLE = "rules"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - private static final VarcharColumnDef templateUuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("template_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddUuidAndTemplateUuidColumnsToRules(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .addColumn(templateUuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/DropIdColumnOfRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/DropIdColumnOfRulesTable.java deleted file mode 100644 index cdde386e05a..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/DropIdColumnOfRulesTable.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropIdColumnOfRulesTable extends DdlChange { - - public DropIdColumnOfRulesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "rules", "id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/DropPrimaryKeyOnIdColumnOfRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/DropPrimaryKeyOnIdColumnOfRulesTable.java deleted file mode 100644 index 20c1b53c9ea..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/DropPrimaryKeyOnIdColumnOfRulesTable.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; - -public class DropPrimaryKeyOnIdColumnOfRulesTable extends DdlChange { - - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator; - - public DropPrimaryKeyOnIdColumnOfRulesTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db); - this.dropPrimaryKeySqlGenerator = dropPrimaryKeySqlGenerator; - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(dropPrimaryKeySqlGenerator.generate("rules", "id", true)); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/DropTemplateIdColumnOfRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/DropTemplateIdColumnOfRulesTable.java deleted file mode 100644 index 027f971fe70..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/DropTemplateIdColumnOfRulesTable.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropTemplateIdColumnOfRulesTable extends DdlChange { - - public DropTemplateIdColumnOfRulesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "rules", "template_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/MakeRulesUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/MakeRulesUuidColumnNotNullable.java deleted file mode 100644 index 86bf5f85471..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/MakeRulesUuidColumnNotNullable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeRulesUuidColumnNotNullable extends DdlChange { - private static final String TABLE = "rules"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public MakeRulesUuidColumnNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/PopulateRulesTemplateUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/PopulateRulesTemplateUuid.java deleted file mode 100644 index 9b235a2c47d..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/PopulateRulesTemplateUuid.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateRulesTemplateUuid extends DataChange { - - public PopulateRulesTemplateUuid(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select( - "select ru.id, rt.uuid from rules ru " + - "left join rules rt on rt.id = ru.template_id " + - "where ru.template_uuid is null and ru.template_id is not null"); - massUpdate.update("update rules set template_uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(2)); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/PopulateRulesUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/PopulateRulesUuid.java deleted file mode 100644 index 1d919988bd8..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/PopulateRulesUuid.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules; - -import java.sql.SQLException; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateRulesUuid extends DataChange { - - private final UuidFactory uuidFactory; - - public PopulateRulesUuid(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select id from rules where uuid is null"); - massUpdate.update("update rules set uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, uuidFactory.create()); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/AddIndexToActiveRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/AddIndexToActiveRulesTable.java deleted file mode 100644 index 0e2c2158d1c..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/AddIndexToActiveRulesTable.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.activerules; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddIndexToActiveRulesTable extends DdlChange { - private static final String TABLE = "active_rules"; - private static final String INDEX_NAME = "uniq_profile_rule_uuids"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("rule_uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - private static final VarcharColumnDef profileUuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("profile_uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddIndexToActiveRulesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (!indexExists()) { - context.execute(new CreateIndexBuilder() - .setTable(TABLE) - .setName(INDEX_NAME) - .addColumn(profileUuidColumnDefinition) - .addColumn(uuidColumnDefinition) - .setUnique(true) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExists(TABLE, INDEX_NAME, connection); - } - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/AddRuleUuidColumnToActiveRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/AddRuleUuidColumnToActiveRulesTable.java deleted file mode 100644 index fee60d1416a..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/AddRuleUuidColumnToActiveRulesTable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.activerules; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddRuleUuidColumnToActiveRulesTable extends DdlChange { - private static final String TABLE = "active_rules"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("rule_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddRuleUuidColumnToActiveRulesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/DropIndexOnRuleIdColumnOfActiveRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/DropIndexOnRuleIdColumnOfActiveRulesTable.java deleted file mode 100644 index c177926955a..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/DropIndexOnRuleIdColumnOfActiveRulesTable.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.activerules; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropIndexOnRuleIdColumnOfActiveRulesTable extends DdlChange { - private static final String TABLE_NAME = "active_rules"; - private static final String INDEX_NAME = "uniq_profile_rule_ids"; - - public DropIndexOnRuleIdColumnOfActiveRulesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropIndexBuilder(getDialect()) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/DropRuleIdColumnOfActiveRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/DropRuleIdColumnOfActiveRulesTable.java deleted file mode 100644 index b2f9995af46..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/DropRuleIdColumnOfActiveRulesTable.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.activerules; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropRuleIdColumnOfActiveRulesTable extends DdlChange { - - public DropRuleIdColumnOfActiveRulesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "active_rules", "rule_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/MakeActiveRulesRuleUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/MakeActiveRulesRuleUuidColumnNotNullable.java deleted file mode 100644 index b4b0ffa2c36..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/MakeActiveRulesRuleUuidColumnNotNullable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.activerules; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeActiveRulesRuleUuidColumnNotNullable extends DdlChange { - private static final String TABLE = "active_rules"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("rule_uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public MakeActiveRulesRuleUuidColumnNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/PopulateActiveRulesRuleUuidColumn.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/PopulateActiveRulesRuleUuidColumn.java deleted file mode 100644 index f6ce521e292..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/PopulateActiveRulesRuleUuidColumn.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.activerules; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateActiveRulesRuleUuidColumn extends DataChange { - - public PopulateActiveRulesRuleUuidColumn(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select ar.rule_id, ru.uuid " + - "from active_rules ar " + - "join rules ru on ar.rule_id = ru.id " + - "where ar.rule_uuid is null"); - massUpdate.update("update active_rules set rule_uuid = ? where rule_id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(2)); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/AddIndexToDeprecatedRuleKeysTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/AddIndexToDeprecatedRuleKeysTable.java deleted file mode 100644 index 129f57b3e7f..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/AddIndexToDeprecatedRuleKeysTable.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.deprecatedrulekeys; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddIndexToDeprecatedRuleKeysTable extends DdlChange { - private static final String TABLE = "deprecated_rule_keys"; - private static final String INDEX_NAME = "rule_uuid_deprecated_rule_keys"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("rule_uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddIndexToDeprecatedRuleKeysTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (!indexExists()) { - context.execute(new CreateIndexBuilder() - .setTable(TABLE) - .setName(INDEX_NAME) - .addColumn(uuidColumnDefinition) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExists(TABLE, INDEX_NAME, connection); - } - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/AddRuleUuidColumnToDeprecatedRuleKeysTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/AddRuleUuidColumnToDeprecatedRuleKeysTable.java deleted file mode 100644 index 7920fe3c0fe..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/AddRuleUuidColumnToDeprecatedRuleKeysTable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.deprecatedrulekeys; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddRuleUuidColumnToDeprecatedRuleKeysTable extends DdlChange { - private static final String TABLE = "deprecated_rule_keys"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("rule_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddRuleUuidColumnToDeprecatedRuleKeysTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTable.java deleted file mode 100644 index 047a4981073..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTable.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.deprecatedrulekeys; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTable extends DdlChange { - - public DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropIndexBuilder(getDialect()) - .setTable("deprecated_rule_keys") - .setName("rule_id_deprecated_rule_keys") - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/DropRuleIdColumnOfDeprecatedRuleKeysTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/DropRuleIdColumnOfDeprecatedRuleKeysTable.java deleted file mode 100644 index 4c671299c08..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/DropRuleIdColumnOfDeprecatedRuleKeysTable.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.deprecatedrulekeys; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropRuleIdColumnOfDeprecatedRuleKeysTable extends DdlChange { - - public DropRuleIdColumnOfDeprecatedRuleKeysTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "deprecated_rule_keys", "rule_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/MakeDeprecatedRuleKeysRuleUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/MakeDeprecatedRuleKeysRuleUuidColumnNotNullable.java deleted file mode 100644 index 8023282925b..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/MakeDeprecatedRuleKeysRuleUuidColumnNotNullable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.deprecatedrulekeys; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeDeprecatedRuleKeysRuleUuidColumnNotNullable extends DdlChange { - private static final String TABLE = "deprecated_rule_keys"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("rule_uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public MakeDeprecatedRuleKeysRuleUuidColumnNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/PopulateDeprecatedRuleKeysRuleUuidColumn.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/PopulateDeprecatedRuleKeysRuleUuidColumn.java deleted file mode 100644 index b58d8988bda..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/PopulateDeprecatedRuleKeysRuleUuidColumn.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.deprecatedrulekeys; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateDeprecatedRuleKeysRuleUuidColumn extends DataChange { - - public PopulateDeprecatedRuleKeysRuleUuidColumn(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select drk.rule_id, ru.uuid " + - "from deprecated_rule_keys drk " + - "join rules ru on drk.rule_id = ru.id " + - "where drk.rule_uuid is null"); - massUpdate.update("update deprecated_rule_keys set rule_uuid = ? where rule_id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(2)); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/issues/AddIndexToIssuesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/issues/AddIndexToIssuesTable.java deleted file mode 100644 index 6e1a5a84447..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/issues/AddIndexToIssuesTable.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.issues; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddIndexToIssuesTable extends DdlChange { - private static final String TABLE = "issues"; - private static final String INDEX_NAME = "issues_rule_uuid"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("rule_uuid") - .setIsNullable(true) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddIndexToIssuesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (!indexExists()) { - context.execute(new CreateIndexBuilder() - .setTable(TABLE) - .setName(INDEX_NAME) - .addColumn(uuidColumnDefinition) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExists(TABLE, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/issues/AddRuleUuidColumnToIssuesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/issues/AddRuleUuidColumnToIssuesTable.java deleted file mode 100644 index 0808b9defc9..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/issues/AddRuleUuidColumnToIssuesTable.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.issues; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddRuleUuidColumnToIssuesTable extends DdlChange { - private static final String TABLE = "issues"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("rule_uuid") - .setIsNullable(true) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddRuleUuidColumnToIssuesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/issues/DropIndexOnRuleIdColumnOfIssuesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/issues/DropIndexOnRuleIdColumnOfIssuesTable.java deleted file mode 100644 index f28152e0807..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/issues/DropIndexOnRuleIdColumnOfIssuesTable.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.issues; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropIndexOnRuleIdColumnOfIssuesTable extends DdlChange { - - public DropIndexOnRuleIdColumnOfIssuesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropIndexBuilder(getDialect()) - .setTable("issues") - .setName("issues_rule_id") - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/issues/DropRuleIdColumnOfIssuesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/issues/DropRuleIdColumnOfIssuesTable.java deleted file mode 100644 index 069d44556af..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/issues/DropRuleIdColumnOfIssuesTable.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.issues; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropRuleIdColumnOfIssuesTable extends DdlChange { - - public DropRuleIdColumnOfIssuesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "issues", "rule_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/issues/PopulateIssuesRuleUuidColumn.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/issues/PopulateIssuesRuleUuidColumn.java deleted file mode 100644 index afa594c2692..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/issues/PopulateIssuesRuleUuidColumn.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.issues; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateIssuesRuleUuidColumn extends DataChange { - - public PopulateIssuesRuleUuidColumn(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select iss.rule_id, ru.uuid " + - "from issues iss " + - "join rules ru on iss.rule_id = ru.id " + - "where iss.rule_uuid is null"); - massUpdate.update("update issues set rule_uuid = ? where rule_id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(2)); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTable.java deleted file mode 100644 index 8eb875ecb8a..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.rulesmetadata; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.AddPrimaryKeyBuilder; - -public class AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTable extends DdlChange { - - public AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("rules_metadata", "rule_uuid", "organization_uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/AddRuleUuidColumnToRulesMetadataTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/AddRuleUuidColumnToRulesMetadataTable.java deleted file mode 100644 index 5cfa390a7ec..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/AddRuleUuidColumnToRulesMetadataTable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.rulesmetadata; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddRuleUuidColumnToRulesMetadataTable extends DdlChange { - private static final String TABLE = "rules_metadata"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("rule_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddRuleUuidColumnToRulesMetadataTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/DropPrimaryKeyOnIdColumnOfRulesMetadataTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/DropPrimaryKeyOnIdColumnOfRulesMetadataTable.java deleted file mode 100644 index ef9a32a26c6..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/DropPrimaryKeyOnIdColumnOfRulesMetadataTable.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.rulesmetadata; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; - -public class DropPrimaryKeyOnIdColumnOfRulesMetadataTable extends DdlChange { - - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator; - - public DropPrimaryKeyOnIdColumnOfRulesMetadataTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db); - this.dropPrimaryKeySqlGenerator = dropPrimaryKeySqlGenerator; - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(dropPrimaryKeySqlGenerator.generate("rules_metadata", "rule_id", false)); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/DropRuleIdColumnOfRulesMetadataTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/DropRuleIdColumnOfRulesMetadataTable.java deleted file mode 100644 index cd1b7d8eb8e..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/DropRuleIdColumnOfRulesMetadataTable.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.rulesmetadata; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropRuleIdColumnOfRulesMetadataTable extends DdlChange { - - public DropRuleIdColumnOfRulesMetadataTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "rules_metadata", "rule_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/MakeRulesMetadataRuleUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/MakeRulesMetadataRuleUuidColumnNotNullable.java deleted file mode 100644 index c71a1b9e32f..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/MakeRulesMetadataRuleUuidColumnNotNullable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.rulesmetadata; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeRulesMetadataRuleUuidColumnNotNullable extends DdlChange { - private static final String TABLE = "rules_metadata"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("rule_uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public MakeRulesMetadataRuleUuidColumnNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/PopulateRulesMetadataRuleUuidColumn.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/PopulateRulesMetadataRuleUuidColumn.java deleted file mode 100644 index 646ae438e41..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/PopulateRulesMetadataRuleUuidColumn.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.rulesmetadata; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateRulesMetadataRuleUuidColumn extends DataChange { - - public PopulateRulesMetadataRuleUuidColumn(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select rm.rule_id, ru.uuid " + - "from rules_metadata rm " + - "join rules ru on rm.rule_id = ru.id " + - "where rm.rule_uuid is null"); - massUpdate.update("update rules_metadata set rule_uuid = ? where rule_id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(2)); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/AddIndexesToRulesParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/AddIndexesToRulesParametersTable.java deleted file mode 100644 index aab7f110df7..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/AddIndexesToRulesParametersTable.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.rulesparameters; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddIndexesToRulesParametersTable extends DdlChange { - private static final String TABLE = "rules_parameters"; - private static final String RULE_UUID_INDEX = "rules_parameters_rule_uuid"; - private static final String RULE_UUID_NAME_UNIQUE_INDEX = "rules_parameters_unique"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("rule_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - private static final VarcharColumnDef nameColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("name") - .setLimit(128) - .setIsNullable(false) - .build(); - - public AddIndexesToRulesParametersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (indexDoesNotExist(RULE_UUID_INDEX)) { - context.execute(new CreateIndexBuilder() - .setTable(TABLE) - .setName(RULE_UUID_INDEX) - .addColumn(uuidColumnDefinition) - .build()); - } - - if (indexDoesNotExist(RULE_UUID_NAME_UNIQUE_INDEX)) { - context.execute(new CreateIndexBuilder() - .setTable(TABLE) - .setName(RULE_UUID_NAME_UNIQUE_INDEX) - .addColumn(uuidColumnDefinition) - .addColumn(nameColumnDefinition) - .setUnique(true) - .build()); - } - } - - private boolean indexDoesNotExist(String index) throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return !DatabaseUtils.indexExists(TABLE, index, connection); - } - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/AddRuleUuidColumnToRulesParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/AddRuleUuidColumnToRulesParametersTable.java deleted file mode 100644 index edb9de28196..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/AddRuleUuidColumnToRulesParametersTable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.rulesparameters; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddRuleUuidColumnToRulesParametersTable extends DdlChange { - private static final String TABLE = "rules_parameters"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("rule_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddRuleUuidColumnToRulesParametersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/DropIndexesOnRuleIdColumnOfRulesParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/DropIndexesOnRuleIdColumnOfRulesParametersTable.java deleted file mode 100644 index b512dfbecba..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/DropIndexesOnRuleIdColumnOfRulesParametersTable.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.rulesparameters; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropIndexesOnRuleIdColumnOfRulesParametersTable extends DdlChange { - - public DropIndexesOnRuleIdColumnOfRulesParametersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropIndexBuilder(getDialect()) - .setTable("rules_parameters") - .setName("rules_parameters_rule_id") - .build()); - context.execute(new DropIndexBuilder(getDialect()) - .setTable("rules_parameters") - .setName("rules_parameters_unique") - .build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/DropRuleIdColumnOfRulesParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/DropRuleIdColumnOfRulesParametersTable.java deleted file mode 100644 index c078f553a83..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/DropRuleIdColumnOfRulesParametersTable.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.rulesparameters; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropRuleIdColumnOfRulesParametersTable extends DdlChange { - - public DropRuleIdColumnOfRulesParametersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "rules_parameters", "rule_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/MakeRulesParametersRuleUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/MakeRulesParametersRuleUuidColumnNotNullable.java deleted file mode 100644 index 103ed3541d1..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/MakeRulesParametersRuleUuidColumnNotNullable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.rulesparameters; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeRulesParametersRuleUuidColumnNotNullable extends DdlChange { - private static final String TABLE = "rules_parameters"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("rule_uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public MakeRulesParametersRuleUuidColumnNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/PopulateRulesParametersRuleUuidColumn.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/PopulateRulesParametersRuleUuidColumn.java deleted file mode 100644 index 89a16ddc5b6..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/PopulateRulesParametersRuleUuidColumn.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.rulesparameters; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateRulesParametersRuleUuidColumn extends DataChange { - - public PopulateRulesParametersRuleUuidColumn(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select rp.rule_id, ru.uuid " + - "from rules_parameters rp " + - "join rules ru on rp.rule_id = ru.id " + - "where rp.rule_uuid is null"); - massUpdate.update("update rules_parameters set rule_uuid = ? where rule_id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(2)); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/AddPrimaryKeyOnUuidColumnOfRulesParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/AddPrimaryKeyOnUuidColumnOfRulesParametersTable.java deleted file mode 100644 index 2b32201ac4d..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/AddPrimaryKeyOnUuidColumnOfRulesParametersTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesparameters; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.AddPrimaryKeyBuilder; - -public class AddPrimaryKeyOnUuidColumnOfRulesParametersTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfRulesParametersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("rules_parameters", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/AddUuidColumnToRulesParameters.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/AddUuidColumnToRulesParameters.java deleted file mode 100644 index 7bc9377cac6..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/AddUuidColumnToRulesParameters.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesparameters; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.AddUuidColumnToTable; - -public class AddUuidColumnToRulesParameters extends AddUuidColumnToTable { - private static final String TABLE_NAME = "rules_parameters"; - - public AddUuidColumnToRulesParameters(Database db) { - super(db, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/DropIdColumnOfRulesParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/DropIdColumnOfRulesParametersTable.java deleted file mode 100644 index 3a169211fad..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/DropIdColumnOfRulesParametersTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesparameters; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropIdColumn; - -public class DropIdColumnOfRulesParametersTable extends DropIdColumn { - private static final String TABLE_NAME = "rules_parameters"; - - public DropIdColumnOfRulesParametersTable(Database db) { - super(db, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/DropPrimaryKeyOnIdColumnOfRulesParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/DropPrimaryKeyOnIdColumnOfRulesParametersTable.java deleted file mode 100644 index fde1307624a..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/DropPrimaryKeyOnIdColumnOfRulesParametersTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesparameters; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; - -public class DropPrimaryKeyOnIdColumnOfRulesParametersTable extends DropPrimaryKeyOnIdColumn { - private static final String TABLE_NAME = "rules_parameters"; - - public DropPrimaryKeyOnIdColumnOfRulesParametersTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/MakeRulesParametersUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/MakeRulesParametersUuidColumnNotNullable.java deleted file mode 100644 index 86b023e8446..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/MakeRulesParametersUuidColumnNotNullable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesparameters; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.MakeUuidColumnNotNullable; - -public class MakeRulesParametersUuidColumnNotNullable extends MakeUuidColumnNotNullable { - private static final String TABLE_NAME = "rules_parameters"; - - public MakeRulesParametersUuidColumnNotNullable(Database db) { - super(db, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/PopulateRulesParametersUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/PopulateRulesParametersUuid.java deleted file mode 100644 index c86a5d0cbce..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/PopulateRulesParametersUuid.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesparameters; - -import java.sql.SQLException; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateRulesParametersUuid extends DataChange { - - private final UuidFactory uuidFactory; - - public PopulateRulesParametersUuid(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select id from rules_parameters where uuid is null"); - massUpdate.update("update rules_parameters set uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, uuidFactory.create()); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/AddRulesParameterUuidColumnToActiveRuleParameters.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/AddRulesParameterUuidColumnToActiveRuleParameters.java deleted file mode 100644 index a38d87cf8e8..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/AddRulesParameterUuidColumnToActiveRuleParameters.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesparameters.fk; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddRulesParameterUuidColumnToActiveRuleParameters extends DdlChange { - private static final String TABLE = "active_rule_parameters"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("rules_parameter_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddRulesParameterUuidColumnToActiveRuleParameters(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/DropRulesParameterIdColumnOfActiveRuleParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/DropRulesParameterIdColumnOfActiveRuleParametersTable.java deleted file mode 100644 index aaad275ba86..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/DropRulesParameterIdColumnOfActiveRuleParametersTable.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesparameters.fk; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropRulesParameterIdColumnOfActiveRuleParametersTable extends DdlChange { - - public DropRulesParameterIdColumnOfActiveRuleParametersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "active_rule_parameters", "rules_parameter_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/MakeActiveRuleParametersRulesParameterUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/MakeActiveRuleParametersRulesParameterUuidColumnNotNullable.java deleted file mode 100644 index bd236b9ed8d..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/MakeActiveRuleParametersRulesParameterUuidColumnNotNullable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesparameters.fk; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeActiveRuleParametersRulesParameterUuidColumnNotNullable extends DdlChange { - private static final String TABLE = "active_rule_parameters"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("rules_parameter_uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public MakeActiveRuleParametersRulesParameterUuidColumnNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/PopulateActiveRuleParametersRulesParameterUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/PopulateActiveRuleParametersRulesParameterUuid.java deleted file mode 100644 index 62ae81a95cd..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/PopulateActiveRuleParametersRulesParameterUuid.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesparameters.fk; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateActiveRuleParametersRulesParameterUuid extends DataChange { - - public PopulateActiveRuleParametersRulesParameterUuid(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select arp.uuid, rp.uuid " + - "from active_rule_parameters arp " + - "join rules_parameters rp on arp.rules_parameter_id = rp.id " + - "where arp.rules_parameter_uuid is null"); - massUpdate.update("update active_rule_parameters set rules_parameter_uuid = ? where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(2)); - update.setString(2, row.getString(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/AddPrimaryKeyOnUuidColumnOfRulesProfilesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/AddPrimaryKeyOnUuidColumnOfRulesProfilesTable.java deleted file mode 100644 index ac78aa9d950..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/AddPrimaryKeyOnUuidColumnOfRulesProfilesTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesprofiles; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.AddPrimaryKeyBuilder; - -public class AddPrimaryKeyOnUuidColumnOfRulesProfilesTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfRulesProfilesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("rules_profiles", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/AddUuidColumnToRulesProfilesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/AddUuidColumnToRulesProfilesTable.java deleted file mode 100644 index 4a4ae6c1714..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/AddUuidColumnToRulesProfilesTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesprofiles; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.AddUuidColumnToTable; - -public class AddUuidColumnToRulesProfilesTable extends AddUuidColumnToTable { - private static final String TABLE = "rules_profiles"; - - public AddUuidColumnToRulesProfilesTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropIdColumnOfRulesProfilesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropIdColumnOfRulesProfilesTable.java deleted file mode 100644 index 68c19acb3e1..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropIdColumnOfRulesProfilesTable.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesprofiles; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropIdColumn; - -public class DropIdColumnOfRulesProfilesTable extends DropIdColumn { - - private static final String TABLE_NAME = "rules_profiles"; - - public DropIdColumnOfRulesProfilesTable(Database db) { - super(db, TABLE_NAME); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropKeeColumnOfRulesProfilesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropKeeColumnOfRulesProfilesTable.java deleted file mode 100644 index f630221d84d..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropKeeColumnOfRulesProfilesTable.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesprofiles; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropKeeColumnOfRulesProfilesTable extends DdlChange { - - private Database db; - - public DropKeeColumnOfRulesProfilesTable(Database db) { - super(db); - this.db = db; - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(db.getDialect(), "rules_profiles", "kee").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropPrimaryKeyOnIdColumnOfRulesProfilesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropPrimaryKeyOnIdColumnOfRulesProfilesTable.java deleted file mode 100644 index 2faecfe8873..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropPrimaryKeyOnIdColumnOfRulesProfilesTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesprofiles; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; - -public class DropPrimaryKeyOnIdColumnOfRulesProfilesTable extends DropPrimaryKeyOnIdColumn { - private static final String TABLE_NAME = "rules_profiles"; - - public DropPrimaryKeyOnIdColumnOfRulesProfilesTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropUniqueIndexOnKeeColumnOfRulesProfilesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropUniqueIndexOnKeeColumnOfRulesProfilesTable.java deleted file mode 100644 index 560e6c01db1..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropUniqueIndexOnKeeColumnOfRulesProfilesTable.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesprofiles; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropUniqueIndexOnKeeColumnOfRulesProfilesTable extends DdlChange { - private static final String TABLE_NAME = "rules_profiles"; - private static final String INDEX_NAME = "uniq_qprof_key"; - - public DropUniqueIndexOnKeeColumnOfRulesProfilesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (indexExists()) { - context.execute(new DropIndexBuilder(getDialect()) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/MakeRulesProfilesUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/MakeRulesProfilesUuidColumnNotNullable.java deleted file mode 100644 index 6d13a0803e9..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/MakeRulesProfilesUuidColumnNotNullable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesprofiles; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.MakeUuidColumnNotNullable; - -public class MakeRulesProfilesUuidColumnNotNullable extends MakeUuidColumnNotNullable { - private static final String TABLE_NAME = "rules_profiles"; - - public MakeRulesProfilesUuidColumnNotNullable(Database db) { - super(db, TABLE_NAME); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/PopulateRulesProfilesUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/PopulateRulesProfilesUuid.java deleted file mode 100644 index 51975861f05..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/PopulateRulesProfilesUuid.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesprofiles; - -import java.sql.SQLException; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateRulesProfilesUuid extends DataChange { - - private final UuidFactory uuidFactory; - - public PopulateRulesProfilesUuid(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select id from rules_profiles where uuid is null"); - massUpdate.update("update rules_profiles set uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, uuidFactory.create()); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/AddProfileUuidColumnToActiveRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/AddProfileUuidColumnToActiveRulesTable.java deleted file mode 100644 index ec3847e8621..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/AddProfileUuidColumnToActiveRulesTable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesprofiles.fk.activerules; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddProfileUuidColumnToActiveRulesTable extends DdlChange { - private static final String TABLE = "active_rules"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("profile_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddProfileUuidColumnToActiveRulesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), TABLE) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/AddUniqueIndexOnProfileUuidColumnOfActiveRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/AddUniqueIndexOnProfileUuidColumnOfActiveRulesTable.java deleted file mode 100644 index baf6dfe2f41..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/AddUniqueIndexOnProfileUuidColumnOfActiveRulesTable.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesprofiles.fk.activerules; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.def.IntegerColumnDef; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddUniqueIndexOnProfileUuidColumnOfActiveRulesTable extends DdlChange { - private static final String TABLE_NAME = "active_rules"; - private static final String INDEX_NAME = "uniq_profile_rule_ids"; - - public AddUniqueIndexOnProfileUuidColumnOfActiveRulesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (!indexExists()) { - context.execute(new CreateIndexBuilder() - .setUnique(true) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("profile_uuid") - .setIsNullable(false) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build()) - .addColumn(IntegerColumnDef.newIntegerColumnDefBuilder() - .setColumnName("rule_id") - .setIsNullable(false) - .build()) - .build()); - } - - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/DropProfileIdColumnOfActiveRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/DropProfileIdColumnOfActiveRulesTable.java deleted file mode 100644 index c541b62c6f9..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/DropProfileIdColumnOfActiveRulesTable.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesprofiles.fk.activerules; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropProfileIdColumnOfActiveRulesTable extends DdlChange { - - private Database db; - - public DropProfileIdColumnOfActiveRulesTable(Database db) { - super(db); - this.db = db; - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(db.getDialect(), "active_rules", "profile_id").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/DropUniqueIndexOnProfileIdColumnOfActiveRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/DropUniqueIndexOnProfileIdColumnOfActiveRulesTable.java deleted file mode 100644 index 7e0c9d6a2cd..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/DropUniqueIndexOnProfileIdColumnOfActiveRulesTable.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesprofiles.fk.activerules; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropUniqueIndexOnProfileIdColumnOfActiveRulesTable extends DdlChange { - private static final String TABLE_NAME = "active_rules"; - private static final String INDEX_NAME = "uniq_profile_rule_ids"; - - public DropUniqueIndexOnProfileIdColumnOfActiveRulesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (indexExists()) { - context.execute(new DropIndexBuilder(getDialect()) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/MakeActiveRulesProfileUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/MakeActiveRulesProfileUuidColumnNotNullable.java deleted file mode 100644 index 4e65662aed8..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/MakeActiveRulesProfileUuidColumnNotNullable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesprofiles.fk.activerules; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeActiveRulesProfileUuidColumnNotNullable extends DdlChange { - private static final String TABLE = "active_rules"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("profile_uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public MakeActiveRulesProfileUuidColumnNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/PopulateActiveRulesProfileUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/PopulateActiveRulesProfileUuid.java deleted file mode 100644 index 2dc9aa6644d..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/PopulateActiveRulesProfileUuid.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesprofiles.fk.activerules; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateActiveRulesProfileUuid extends DataChange { - - public PopulateActiveRulesProfileUuid(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select ar.uuid, rp.uuid " + - "from active_rules ar " + - "join rules_profiles rp on ar.profile_id = rp.id " + - "where ar.profile_uuid is null"); - massUpdate.update("update active_rules set profile_uuid = ? where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(2)); - update.setString(2, row.getString(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/orgqprofiles/PopulateOrgQProfilesRulesProfileUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/orgqprofiles/PopulateOrgQProfilesRulesProfileUuid.java deleted file mode 100644 index 7786b6e30e5..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/orgqprofiles/PopulateOrgQProfilesRulesProfileUuid.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesprofiles.fk.orgqprofiles; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateOrgQProfilesRulesProfileUuid extends DataChange { - - public PopulateOrgQProfilesRulesProfileUuid(Database db) { - super(db); - } - - @Override - protected void execute(DataChange.Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select oqp.uuid, rp.uuid " + - "from org_qprofiles oqp " + - "join rules_profiles rp on oqp.rules_profile_uuid = rp.kee"); - massUpdate.update("update org_qprofiles set rules_profile_uuid = ? where uuid = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(2)); - update.setString(2, row.getString(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/qprofilechanges/PopulateQProfileChangesRulesProfileUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/qprofilechanges/PopulateQProfileChangesRulesProfileUuid.java deleted file mode 100644 index 0d7cb591b64..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/qprofilechanges/PopulateQProfileChangesRulesProfileUuid.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesprofiles.fk.qprofilechanges; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateQProfileChangesRulesProfileUuid extends DataChange { - - public PopulateQProfileChangesRulesProfileUuid(Database db) { - super(db); - } - - @Override - protected void execute(DataChange.Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select qpc.kee, rp.uuid " + - "from qprofile_changes qpc " + - "join rules_profiles rp on qpc.rules_profile_uuid = rp.kee"); - massUpdate.update("update qprofile_changes set rules_profile_uuid = ? where kee = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, row.getString(2)); - update.setString(2, row.getString(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/snapshots/issues/AddPrimaryKeyOnUuidColumnOfSnapshotsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/snapshots/issues/AddPrimaryKeyOnUuidColumnOfSnapshotsTable.java deleted file mode 100644 index 75add5962c6..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/snapshots/issues/AddPrimaryKeyOnUuidColumnOfSnapshotsTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.snapshots.issues; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.AddPrimaryKeyBuilder; - -public class AddPrimaryKeyOnUuidColumnOfSnapshotsTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfSnapshotsTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("snapshots", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/snapshots/issues/DropIdColumnOfSnapshotsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/snapshots/issues/DropIdColumnOfSnapshotsTable.java deleted file mode 100644 index 31b1d2fae84..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/snapshots/issues/DropIdColumnOfSnapshotsTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.snapshots.issues; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropIdColumn; - -public class DropIdColumnOfSnapshotsTable extends DropIdColumn { - private static final String TABLE = "snapshots"; - - public DropIdColumnOfSnapshotsTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/snapshots/issues/DropPrimaryKeyOnIdColumnOfSnapshotsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/snapshots/issues/DropPrimaryKeyOnIdColumnOfSnapshotsTable.java deleted file mode 100644 index 9f8aa733ed6..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/snapshots/issues/DropPrimaryKeyOnIdColumnOfSnapshotsTable.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.snapshots.issues; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; - -public class DropPrimaryKeyOnIdColumnOfSnapshotsTable extends DdlChange { - - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator; - - public DropPrimaryKeyOnIdColumnOfSnapshotsTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db); - this.dropPrimaryKeySqlGenerator = dropPrimaryKeySqlGenerator; - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(dropPrimaryKeySqlGenerator.generate("snapshots", "id", true)); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/userroles/AddPrimaryKeyOnUuidColumnOfUserRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/userroles/AddPrimaryKeyOnUuidColumnOfUserRolesTable.java deleted file mode 100644 index f42f96f810b..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/userroles/AddPrimaryKeyOnUuidColumnOfUserRolesTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.userroles; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.AddPrimaryKeyBuilder; - -public class AddPrimaryKeyOnUuidColumnOfUserRolesTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfUserRolesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("user_roles", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/userroles/AddUuidColumnToUserRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/userroles/AddUuidColumnToUserRolesTable.java deleted file mode 100644 index fa22bcbf3f2..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/userroles/AddUuidColumnToUserRolesTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.userroles; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.AddUuidColumnToTable; - -public class AddUuidColumnToUserRolesTable extends AddUuidColumnToTable { - private static final String TABLE = "user_roles"; - - public AddUuidColumnToUserRolesTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/userroles/DropIdColumnOfUserRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/userroles/DropIdColumnOfUserRolesTable.java deleted file mode 100644 index 57122a8f033..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/userroles/DropIdColumnOfUserRolesTable.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.userroles; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropIdColumn; - -public class DropIdColumnOfUserRolesTable extends DropIdColumn { - public DropIdColumnOfUserRolesTable(Database db) { - super(db, "user_roles"); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/userroles/DropPrimaryKeyOnIdColumnOfUserRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/userroles/DropPrimaryKeyOnIdColumnOfUserRolesTable.java deleted file mode 100644 index 0e2b63bcbf1..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/userroles/DropPrimaryKeyOnIdColumnOfUserRolesTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.userroles; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; - -public class DropPrimaryKeyOnIdColumnOfUserRolesTable extends DropPrimaryKeyOnIdColumn { - private static final String TABLE_NAME = "user_roles"; - - public DropPrimaryKeyOnIdColumnOfUserRolesTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/userroles/MakeUserRolesUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/userroles/MakeUserRolesUuidColumnNotNullable.java deleted file mode 100644 index 8ef686cade5..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/userroles/MakeUserRolesUuidColumnNotNullable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.userroles; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.MakeUuidColumnNotNullable; - -public class MakeUserRolesUuidColumnNotNullable extends MakeUuidColumnNotNullable { - private static final String TABLE = "user_roles"; - - public MakeUserRolesUuidColumnNotNullable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/userroles/PopulateUserRolesUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/userroles/PopulateUserRolesUuid.java deleted file mode 100644 index 99d48f71741..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/userroles/PopulateUserRolesUuid.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.userroles; - -import java.sql.SQLException; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateUserRolesUuid extends DataChange { - - private final UuidFactory uuidFactory; - - public PopulateUserRolesUuid(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select id from user_roles where uuid is null order by id asc"); - massUpdate.update("update user_roles set uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, uuidFactory.create()); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/AddPrimaryKeyOnUuidColumnOfUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/AddPrimaryKeyOnUuidColumnOfUsersTable.java deleted file mode 100644 index 52a53bcf7e6..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/AddPrimaryKeyOnUuidColumnOfUsersTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.AddPrimaryKeyBuilder; - -public class AddPrimaryKeyOnUuidColumnOfUsersTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfUsersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("users", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/DropIdColumnOfUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/DropIdColumnOfUsersTable.java deleted file mode 100644 index 15abb3768a1..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/DropIdColumnOfUsersTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropIdColumn; - -public class DropIdColumnOfUsersTable extends DropIdColumn { - - private static final String TABLE_NAME = "users"; - - public DropIdColumnOfUsersTable(Database db) { - super(db, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/DropPrimaryKeyOnIdColumnOfUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/DropPrimaryKeyOnIdColumnOfUsersTable.java deleted file mode 100644 index c52e3f71d1e..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/DropPrimaryKeyOnIdColumnOfUsersTable.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; - -public class DropPrimaryKeyOnIdColumnOfUsersTable extends DropPrimaryKeyOnIdColumn { - - private static final String TABLE_NAME = "users"; - - public DropPrimaryKeyOnIdColumnOfUsersTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/DropUniqueIndexOnUuidColumnOfUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/DropUniqueIndexOnUuidColumnOfUsersTable.java deleted file mode 100644 index fe5d60048d4..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/DropUniqueIndexOnUuidColumnOfUsersTable.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropUniqueIndexOnUuidColumnOfUsersTable extends DdlChange { - - private static final String TABLE_NAME = "users"; - private static final String INDEX_NAME = "users_uuid"; - - public DropUniqueIndexOnUuidColumnOfUsersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (indexExists()) { - context.execute(new DropIndexBuilder(getDialect()) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/AddIndexOnUserUuidOfGroupsUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/AddIndexOnUserUuidOfGroupsUsersTable.java deleted file mode 100644 index 5c93f9c27ee..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/AddIndexOnUserUuidOfGroupsUsersTable.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.groupsusers; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddIndexOnUserUuidOfGroupsUsersTable extends DdlChange { - private static final String TABLE_NAME = "groups_users"; - private static final String INDEX_NAME = "index_groups_users_user_uuid"; - - public AddIndexOnUserUuidOfGroupsUsersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (!indexExists()) { - context.execute(new CreateIndexBuilder() - .setUnique(false) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("user_uuid") - .setLimit(UUID_SIZE) - .build()) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTable.java deleted file mode 100644 index 27159208e35..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTable.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.groupsusers; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.IntegerColumnDef.newIntegerColumnDefBuilder; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTable extends DdlChange { - private static final String TABLE_NAME = "groups_users"; - private static final String INDEX_NAME = "groups_users_unique"; - - public AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (!indexExists()) { - context.execute(new CreateIndexBuilder() - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .setUnique(true) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("user_uuid") - .setLimit(UUID_SIZE) - .build()) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("group_uuid") - .setLimit(UUID_SIZE) - .build()) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/AddUserUuidColumnToGroupsUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/AddUserUuidColumnToGroupsUsers.java deleted file mode 100644 index 74aba144bf4..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/AddUserUuidColumnToGroupsUsers.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.groupsusers; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.users.fk.util.AddUserUuidColumnToTable; - -public class AddUserUuidColumnToGroupsUsers extends AddUserUuidColumnToTable { - public AddUserUuidColumnToGroupsUsers(Database db) { - super(db, "groups_users"); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/DropIndexOnUserIdOfGroupsUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/DropIndexOnUserIdOfGroupsUsersTable.java deleted file mode 100644 index 9d505e0b381..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/DropIndexOnUserIdOfGroupsUsersTable.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.groupsusers; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropIndexOnUserIdOfGroupsUsersTable extends DdlChange { - private static final String TABLE_NAME = "groups_users"; - private static final String INDEX_NAME = "index_groups_users_on_user_id"; - - public DropIndexOnUserIdOfGroupsUsersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (indexExists()) { - context.execute(new DropIndexBuilder(getDialect()) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTable.java deleted file mode 100644 index 64d3a06049c..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTable.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.groupsusers; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTable extends DdlChange { - private static final String TABLE_NAME = "groups_users"; - private static final String INDEX_NAME = "groups_users_unique"; - - public DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (indexExists()) { - context.execute(new DropIndexBuilder(getDialect()) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/DropUserIdColumnOfGroupsUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/DropUserIdColumnOfGroupsUsersTable.java deleted file mode 100644 index 46ac4ca5533..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/DropUserIdColumnOfGroupsUsersTable.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.groupsusers; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropUserIdColumnOfGroupsUsersTable extends DdlChange { - public DropUserIdColumnOfGroupsUsersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "groups_users", "user_id").build()); - } -} - diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/MakeGroupsUsersUserUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/MakeGroupsUsersUserUuidColumnNotNullable.java deleted file mode 100644 index 3b57a7ddd8b..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/MakeGroupsUsersUserUuidColumnNotNullable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.groupsusers; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeGroupsUsersUserUuidColumnNotNullable extends DdlChange { - private static final String TABLE_NAME = "groups_users"; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("user_uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public MakeGroupsUsersUserUuidColumnNotNullable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE_NAME) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/PopulateGroupsUsersUserUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/PopulateGroupsUsersUserUuid.java deleted file mode 100644 index 8ebc22e2044..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/PopulateGroupsUsersUserUuid.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.groupsusers; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateGroupsUsersUserUuid extends DataChange { - - public PopulateGroupsUsersUserUuid(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select gu.group_uuid, gu.user_id, u.uuid " + - "from groups_users gu " + - "join users u on gu.user_id = u.id where gu.user_uuid is null"); - - massUpdate.update("update groups_users set user_uuid = ? where group_uuid = ? and user_id = ?"); - - massUpdate.execute((row, update) -> { - String groupUuid = row.getString(1); - long userId = row.getLong(2); - String userUuid = row.getString(3); - update.setString(1, userUuid); - update.setString(2, groupUuid); - update.setLong(3, userId); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/AddIndexOnUserUuidOfOrganizationMembersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/AddIndexOnUserUuidOfOrganizationMembersTable.java deleted file mode 100644 index 8a65be70e80..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/AddIndexOnUserUuidOfOrganizationMembersTable.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.organizationmembers; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddIndexOnUserUuidOfOrganizationMembersTable extends DdlChange { - private static final String TABLE_NAME = "organization_members"; - private static final String INDEX_NAME = "org_members_user_uuid"; - - public AddIndexOnUserUuidOfOrganizationMembersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (!indexExists()) { - context.execute(new CreateIndexBuilder() - .setUnique(false) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("user_uuid") - .setLimit(UUID_SIZE) - .build()) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTable.java deleted file mode 100644 index 12a1112d5ce..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.organizationmembers; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.AddPrimaryKeyBuilder; - -public class AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTable extends DdlChange { - - public AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("organization_members", "user_uuid", "organization_uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/AddUserUuidColumnToOrganizationMembers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/AddUserUuidColumnToOrganizationMembers.java deleted file mode 100644 index 626cc0c4869..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/AddUserUuidColumnToOrganizationMembers.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.organizationmembers; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.users.fk.util.AddUserUuidColumnToTable; - -public class AddUserUuidColumnToOrganizationMembers extends AddUserUuidColumnToTable { - public AddUserUuidColumnToOrganizationMembers(Database db) { - super(db, "organization_members"); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/DropIndexOnUserIdOfOrganizationMembersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/DropIndexOnUserIdOfOrganizationMembersTable.java deleted file mode 100644 index e19b5e6d2ce..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/DropIndexOnUserIdOfOrganizationMembersTable.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.organizationmembers; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropIndexOnUserIdOfOrganizationMembersTable extends DdlChange { - private static final String TABLE_NAME = "organization_members"; - private static final String INDEX_NAME = "ix_org_members_on_user_id"; - - public DropIndexOnUserIdOfOrganizationMembersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (indexExists()) { - context.execute(new DropIndexBuilder(getDialect()) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTable.java deleted file mode 100644 index 03e495cbd67..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTable.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.organizationmembers; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; - -public class DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTable extends DdlChange { - private static final String TABLE_NAME = "organization_members"; - - private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator; - - public DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db); - this.dropPrimaryKeySqlGenerator = dropPrimaryKeySqlGenerator; - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(dropPrimaryKeySqlGenerator.generate(TABLE_NAME, "user_id", false)); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/DropUserIdColumnOfOrganizationMembersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/DropUserIdColumnOfOrganizationMembersTable.java deleted file mode 100644 index 36f782fcbdb..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/DropUserIdColumnOfOrganizationMembersTable.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.organizationmembers; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropUserIdColumnOfOrganizationMembersTable extends DdlChange { - public DropUserIdColumnOfOrganizationMembersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "organization_members", "user_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/MakeOrganizationMembersUserUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/MakeOrganizationMembersUserUuidColumnNotNullable.java deleted file mode 100644 index c3b09efc86b..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/MakeOrganizationMembersUserUuidColumnNotNullable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.organizationmembers; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.users.fk.util.MakeUserUuidColumnNotNullable; - -public class MakeOrganizationMembersUserUuidColumnNotNullable extends MakeUserUuidColumnNotNullable { - private static final String TABLE_NAME = "organization_members"; - - public MakeOrganizationMembersUserUuidColumnNotNullable(Database db) { - super(db, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/PopulateOrganizationMembersUserUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/PopulateOrganizationMembersUserUuid.java deleted file mode 100644 index ea8e0c3c83b..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/PopulateOrganizationMembersUserUuid.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.organizationmembers; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateOrganizationMembersUserUuid extends DataChange { - - public PopulateOrganizationMembersUserUuid(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select om.user_id, om.organization_uuid, u.uuid " + - "from organization_members om " + - "join users u on om.user_id = u.id where om.user_uuid is null"); - - massUpdate.update("update organization_members set user_uuid = ? where organization_uuid = ? and user_id = ?"); - - massUpdate.execute((row, update, index) -> { - long userId = row.getLong(1); - String organizationUuid = row.getString(2); - String userUuid = row.getString(3); - - update.setString(1, userUuid); - update.setString(2, organizationUuid); - update.setLong(3, userId); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/AddUserUuidColumnToPermTemplatesUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/AddUserUuidColumnToPermTemplatesUsers.java deleted file mode 100644 index ed4b61944f4..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/AddUserUuidColumnToPermTemplatesUsers.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.permtemplatesusers; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.users.fk.util.AddUserUuidColumnToTable; - -public class AddUserUuidColumnToPermTemplatesUsers extends AddUserUuidColumnToTable { - - public AddUserUuidColumnToPermTemplatesUsers(Database db) { - super(db, "perm_templates_users"); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/DropUserIdColumnOfPermTemplatesUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/DropUserIdColumnOfPermTemplatesUsersTable.java deleted file mode 100644 index 2848283ba03..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/DropUserIdColumnOfPermTemplatesUsersTable.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.permtemplatesusers; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropUserIdColumnOfPermTemplatesUsersTable extends DdlChange { - public DropUserIdColumnOfPermTemplatesUsersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "perm_templates_users", "user_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/MakePermTemplatesUsersUserUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/MakePermTemplatesUsersUserUuidColumnNotNullable.java deleted file mode 100644 index 3f9be4ef04f..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/MakePermTemplatesUsersUserUuidColumnNotNullable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.permtemplatesusers; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.users.fk.util.MakeUserUuidColumnNotNullable; - -public class MakePermTemplatesUsersUserUuidColumnNotNullable extends MakeUserUuidColumnNotNullable { - private static final String TABLE_NAME = "perm_templates_users"; - - public MakePermTemplatesUsersUserUuidColumnNotNullable(Database db) { - super(db, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/PopulatePermTemplatesUsersUserUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/PopulatePermTemplatesUsersUserUuid.java deleted file mode 100644 index f86478283a5..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/PopulatePermTemplatesUsersUserUuid.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.permtemplatesusers; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulatePermTemplatesUsersUserUuid extends DataChange { - - public PopulatePermTemplatesUsersUserUuid(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select ptu.uuid, u.uuid " + - "from perm_templates_users ptu " + - "join users u on ptu.user_id = u.id where ptu.user_uuid is null"); - - massUpdate.update("update perm_templates_users set user_uuid = ? where uuid = ?"); - - massUpdate.execute((row, update, index) -> { - String permTemplatesUuid = row.getString(1); - String userUuid = row.getString(2); - - update.setString(1, userUuid); - update.setString(2, permTemplatesUuid); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/AddUserUuidColumnToPropertiesUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/AddUserUuidColumnToPropertiesUsers.java deleted file mode 100644 index 7aaf723df88..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/AddUserUuidColumnToPropertiesUsers.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.properties; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.users.fk.util.AddUserUuidColumnToTable; - -public class AddUserUuidColumnToPropertiesUsers extends AddUserUuidColumnToTable { - - public AddUserUuidColumnToPropertiesUsers(Database db) { - super(db, "properties"); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/DropUserIdColumnOfPropertiesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/DropUserIdColumnOfPropertiesTable.java deleted file mode 100644 index 89453c14d17..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/DropUserIdColumnOfPropertiesTable.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.properties; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropUserIdColumnOfPropertiesTable extends DdlChange { - public DropUserIdColumnOfPropertiesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "properties", "user_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/PopulatePropertiesUserUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/PopulatePropertiesUserUuid.java deleted file mode 100644 index fb709768fec..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/PopulatePropertiesUserUuid.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.properties; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulatePropertiesUserUuid extends DataChange { - - public PopulatePropertiesUserUuid(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select p.uuid, u.uuid " + - "from properties p " + - "join users u on p.user_id = u.id where p.user_uuid is null"); - - massUpdate.update("update properties set user_uuid = ? where uuid = ?"); - - massUpdate.execute((row, update, index) -> { - String propertiesUuid = row.getString(1); - String userUuid = row.getString(2); - - update.setString(1, userUuid); - update.setString(2, propertiesUuid); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTable.java deleted file mode 100644 index 46bbc23f541..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTable.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.qprofileeditusers; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTable extends DdlChange { - private static final String TABLE_NAME = "qprofile_edit_users"; - private static final String INDEX_NAME = "qprofile_edit_users_unique"; - - public AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (!indexExists()) { - context.execute(new CreateIndexBuilder() - .setUnique(true) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("user_uuid") - .setLimit(UUID_SIZE) - .build()) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("qprofile_uuid") - .setLimit(UUID_SIZE) - .build()) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/AddUserUuidColumnToQProfileEditUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/AddUserUuidColumnToQProfileEditUsers.java deleted file mode 100644 index 3018ecaef87..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/AddUserUuidColumnToQProfileEditUsers.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.qprofileeditusers; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.users.fk.util.AddUserUuidColumnToTable; - -public class AddUserUuidColumnToQProfileEditUsers extends AddUserUuidColumnToTable { - - public AddUserUuidColumnToQProfileEditUsers(Database db) { - super(db, "qprofile_edit_users"); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTable.java deleted file mode 100644 index b3d3e6ce23b..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTable.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.qprofileeditusers; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTable extends DdlChange { - private static final String TABLE_NAME = "qprofile_edit_users"; - private static final String INDEX_NAME = "qprofile_edit_users_unique"; - - public DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (indexExists()) { - context.execute(new DropIndexBuilder(getDialect()) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/DropUserIdColumnOfQProfileEditUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/DropUserIdColumnOfQProfileEditUsersTable.java deleted file mode 100644 index f0638133a90..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/DropUserIdColumnOfQProfileEditUsersTable.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.qprofileeditusers; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropUserIdColumnOfQProfileEditUsersTable extends DdlChange { - public DropUserIdColumnOfQProfileEditUsersTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "qprofile_edit_users", "user_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/MakeQProfileEditUsersUserUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/MakeQProfileEditUsersUserUuidColumnNotNullable.java deleted file mode 100644 index cb7b5144fa7..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/MakeQProfileEditUsersUserUuidColumnNotNullable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.qprofileeditusers; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.users.fk.util.MakeUserUuidColumnNotNullable; - -public class MakeQProfileEditUsersUserUuidColumnNotNullable extends MakeUserUuidColumnNotNullable { - private static final String TABLE_NAME = "qprofile_edit_users"; - - public MakeQProfileEditUsersUserUuidColumnNotNullable(Database db) { - super(db, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/PopulateQProfileEditUsersUserUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/PopulateQProfileEditUsersUserUuid.java deleted file mode 100644 index 0a10dc06008..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/PopulateQProfileEditUsersUserUuid.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.qprofileeditusers; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateQProfileEditUsersUserUuid extends DataChange { - - public PopulateQProfileEditUsersUserUuid(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select qeu.uuid, u.uuid " + - "from qprofile_edit_users qeu " + - "join users u on qeu.user_id = u.id where qeu.user_uuid is null"); - - massUpdate.update("update qprofile_edit_users set user_uuid = ? where uuid = ?"); - - massUpdate.execute((row, update, index) -> { - String permTemplatesUuid = row.getString(1); - String userUuid = row.getString(2); - - update.setString(1, userUuid); - update.setString(2, permTemplatesUuid); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/AddIndexOnUserUuidOfUserRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/AddIndexOnUserUuidOfUserRolesTable.java deleted file mode 100644 index b7e4b270ece..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/AddIndexOnUserUuidOfUserRolesTable.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.userroles; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_SIZE; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddIndexOnUserUuidOfUserRolesTable extends DdlChange { - private static final String TABLE_NAME = "user_roles"; - private static final String INDEX_NAME = "user_roles_user"; - - public AddIndexOnUserUuidOfUserRolesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (!indexExists()) { - context.execute(new CreateIndexBuilder() - .setUnique(false) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .addColumn(newVarcharColumnDefBuilder() - .setColumnName("user_uuid") - .setLimit(UUID_SIZE) - .build()) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/AddUserUuidColumnToUserRoles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/AddUserUuidColumnToUserRoles.java deleted file mode 100644 index 5cf8280949d..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/AddUserUuidColumnToUserRoles.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.userroles; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.users.fk.util.AddUserUuidColumnToTable; - -public class AddUserUuidColumnToUserRoles extends AddUserUuidColumnToTable { - - public AddUserUuidColumnToUserRoles(Database db) { - super(db, "user_roles"); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/DropIndexOnUserIdOfUserRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/DropIndexOnUserIdOfUserRolesTable.java deleted file mode 100644 index a34f0b6a784..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/DropIndexOnUserIdOfUserRolesTable.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.userroles; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropIndexOnUserIdOfUserRolesTable extends DdlChange { - private static final String TABLE_NAME = "user_roles"; - private static final String INDEX_NAME = "user_roles_user"; - - public DropIndexOnUserIdOfUserRolesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - if (indexExists()) { - context.execute(new DropIndexBuilder(getDialect()) - .setTable(TABLE_NAME) - .setName(INDEX_NAME) - .build()); - } - } - - private boolean indexExists() throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); - } - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/DropUserIdColumnOfUserRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/DropUserIdColumnOfUserRolesTable.java deleted file mode 100644 index d1e43526b68..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/DropUserIdColumnOfUserRolesTable.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.userroles; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropUserIdColumnOfUserRolesTable extends DdlChange { - public DropUserIdColumnOfUserRolesTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new DropColumnsBuilder(getDialect(), "user_roles", "user_id").build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/PopulateUserRolesUserUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/PopulateUserRolesUserUuid.java deleted file mode 100644 index b645c44f3d9..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/PopulateUserRolesUserUuid.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.userroles; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateUserRolesUserUuid extends DataChange { - - public PopulateUserRolesUserUuid(Database db) { - super(db); - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select ur.uuid, u.uuid " + - "from user_roles ur " + - "join users u on ur.user_id = u.id where ur.user_uuid is null"); - - massUpdate.update("update user_roles set user_uuid = ? where uuid = ?"); - - massUpdate.execute((row, update, index) -> { - String userRolesUuid = row.getString(1); - String userUuid = row.getString(2); - - update.setString(1, userUuid); - update.setString(2, userRolesUuid); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/util/AddUserUuidColumnToTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/util/AddUserUuidColumnToTable.java deleted file mode 100644 index f58a6254251..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/util/AddUserUuidColumnToTable.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.util; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddUserUuidColumnToTable extends DdlChange { - private final String tableName; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("user_uuid") - .setIsNullable(true) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public AddUserUuidColumnToTable(Database db, String tableName) { - super(db); - this.tableName = tableName; - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddColumnsBuilder(getDialect(), tableName) - .addColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/util/MakeUserUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/util/MakeUserUuidColumnNotNullable.java deleted file mode 100644 index e6b1620a781..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/users/fk/util/MakeUserUuidColumnNotNullable.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.util; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class MakeUserUuidColumnNotNullable extends DdlChange { - private final String tableName; - - private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() - .setColumnName("user_uuid") - .setIsNullable(false) - .setDefaultValue(null) - .setLimit(VarcharColumnDef.UUID_SIZE) - .build(); - - public MakeUserUuidColumnNotNullable(Database db, String tableName) { - super(db); - this.tableName = tableName; - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), tableName) - .updateColumn(uuidColumnDefinition) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/usertokens/AddPrimaryKeyOnUuidColumnOfUserTokensTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/usertokens/AddPrimaryKeyOnUuidColumnOfUserTokensTable.java deleted file mode 100644 index 803987a1483..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/usertokens/AddPrimaryKeyOnUuidColumnOfUserTokensTable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.usertokens; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.AddPrimaryKeyBuilder; - -public class AddPrimaryKeyOnUuidColumnOfUserTokensTable extends DdlChange { - - public AddPrimaryKeyOnUuidColumnOfUserTokensTable(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AddPrimaryKeyBuilder("user_tokens", "uuid").build()); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/usertokens/AddUuidColumnToUserTokens.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/usertokens/AddUuidColumnToUserTokens.java deleted file mode 100644 index 0b3b1b77c7c..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/usertokens/AddUuidColumnToUserTokens.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.usertokens; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.AddUuidColumnToTable; - -public class AddUuidColumnToUserTokens extends AddUuidColumnToTable { - private static final String TABLE = "user_tokens"; - - public AddUuidColumnToUserTokens(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/usertokens/DropIdColumnOfUserTokensTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/usertokens/DropIdColumnOfUserTokensTable.java deleted file mode 100644 index 2dec2e7e421..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/usertokens/DropIdColumnOfUserTokensTable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.usertokens; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropIdColumn; - -public class DropIdColumnOfUserTokensTable extends DropIdColumn { - private static final String TABLE = "user_tokens"; - - public DropIdColumnOfUserTokensTable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/usertokens/DropPrimaryKeyOnIdColumnOfUserTokensTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/usertokens/DropPrimaryKeyOnIdColumnOfUserTokensTable.java deleted file mode 100644 index 183a0c7572c..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/usertokens/DropPrimaryKeyOnIdColumnOfUserTokensTable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.usertokens; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; - -public class DropPrimaryKeyOnIdColumnOfUserTokensTable extends DropPrimaryKeyOnIdColumn { - private static final String TABLE_NAME = "user_tokens"; - - public DropPrimaryKeyOnIdColumnOfUserTokensTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { - super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/usertokens/MakeUserTokensUuidNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/usertokens/MakeUserTokensUuidNotNullable.java deleted file mode 100644 index 4cabddcfa5b..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/usertokens/MakeUserTokensUuidNotNullable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.usertokens; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.version.v83.common.MakeUuidColumnNotNullable; - -public class MakeUserTokensUuidNotNullable extends MakeUuidColumnNotNullable { - private static final String TABLE = "user_tokens"; - - public MakeUserTokensUuidNotNullable(Database db) { - super(db, TABLE); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/usertokens/PopulateUserTokensUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/usertokens/PopulateUserTokensUuid.java deleted file mode 100644 index a6933029229..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/usertokens/PopulateUserTokensUuid.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.usertokens; - -import java.sql.SQLException; -import java.util.concurrent.atomic.AtomicLong; -import org.sonar.api.utils.System2; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; - -public class PopulateUserTokensUuid extends DataChange { - - private final UuidFactory uuidFactory; - - public PopulateUserTokensUuid(Database db, UuidFactory uuidFactory) { - super(db); - this.uuidFactory = uuidFactory; - } - - @Override - protected void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - - massUpdate.select("select id from user_tokens where uuid is null order by id asc"); - massUpdate.update("update user_tokens set uuid = ? where id = ?"); - - massUpdate.execute((row, update) -> { - update.setString(1, uuidFactory.create()); - update.setLong(2, row.getLong(1)); - return true; - }); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/util/AddPrimaryKeyBuilder.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/util/AddPrimaryKeyBuilder.java deleted file mode 100644 index bc2d0ebd0ab..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/util/AddPrimaryKeyBuilder.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.util; - -import com.google.common.collect.Lists; -import java.util.List; - -import static com.google.common.base.Preconditions.checkState; -import static java.lang.String.format; -import static org.sonar.server.platform.db.migration.def.Validations.validateTableName; -import static org.sonar.server.platform.db.migration.sql.CreateTableBuilder.PRIMARY_KEY_PREFIX; - -public class AddPrimaryKeyBuilder { - - private final String tableName; - private final List primaryKey; - - public AddPrimaryKeyBuilder(String tableName, String column, String... moreColumns) { - this.tableName = validateTableName(tableName); - this.primaryKey = Lists.asList(column, moreColumns); - } - - public String build() { - checkState(primaryKey != null, "Primary key is missing"); - return format("ALTER TABLE %s ADD CONSTRAINT %s%s PRIMARY KEY (%s)", tableName, PRIMARY_KEY_PREFIX, tableName, - String.join(",", this.primaryKey)); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/util/DropPrimaryKeySqlGenerator.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/util/DropPrimaryKeySqlGenerator.java deleted file mode 100644 index 1d8771ecd94..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/util/DropPrimaryKeySqlGenerator.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.server.platform.db.migration.version.v83.util; - -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; -import org.sonar.db.Database; -import org.sonar.db.dialect.Dialect; -import org.sonar.db.dialect.H2; -import org.sonar.db.dialect.MsSql; -import org.sonar.db.dialect.Oracle; -import org.sonar.db.dialect.PostgreSql; - -import static java.lang.String.format; -import static java.util.Arrays.asList; -import static java.util.Collections.singletonList; - -public class DropPrimaryKeySqlGenerator { - private static final String GENERIC_DROP_CONSTRAINT_STATEMENT = "ALTER TABLE %s DROP CONSTRAINT %s"; - - private final Database db; - private SqlHelper sqlHelper; - - public DropPrimaryKeySqlGenerator(Database db, SqlHelper sqlHelper) { - this.db = db; - this.sqlHelper = sqlHelper; - } - - public List generate(String tableName, String columnName, boolean isAutoGenerated) throws SQLException { - Dialect dialect = db.getDialect(); - switch (dialect.getId()) { - case PostgreSql.ID: - return generateForPostgresSql(tableName, columnName, sqlHelper.getPostgresSqlConstraint(tableName)); - case MsSql.ID: - return generateForMsSql(tableName, sqlHelper.getMssqlConstraint(tableName)); - case Oracle.ID: - return generateForOracle(tableName, sqlHelper.getOracleConstraint(tableName), isAutoGenerated); - case H2.ID: - return generateForH2(tableName, columnName, sqlHelper.getH2Constraint(tableName)); - default: - throw new IllegalStateException(format("Unsupported database '%s'", dialect.getId())); - } - } - - private List generateForPostgresSql(String tableName, String column, String constraintName) throws SQLException { - List statements = new ArrayList<>(); - statements.add(format("ALTER TABLE %s ALTER COLUMN %s DROP DEFAULT", tableName, column)); - - String sequence = sqlHelper.getPostgresSqlSequence(tableName, column); - if (sequence != null) { - statements.add(format("DROP SEQUENCE %s", sequence)); - } - - statements.add(format(GENERIC_DROP_CONSTRAINT_STATEMENT, tableName, constraintName)); - - return statements; - } - - private static List generateForOracle(String tableName, String constraintName, boolean isAutoGenerated) { - List statements = new ArrayList<>(); - if (isAutoGenerated) { - statements.add(format("DROP TRIGGER %s_IDT", tableName)); - statements.add(format("DROP SEQUENCE %s_SEQ", tableName)); - } - - statements.add(format(GENERIC_DROP_CONSTRAINT_STATEMENT, tableName, constraintName)); - return statements; - } - - private static List generateForMsSql(String tableName, String constraintName) { - return singletonList(format(GENERIC_DROP_CONSTRAINT_STATEMENT, tableName, constraintName)); - } - - private static List generateForH2(String tableName, String column, String constraintName) { - return asList( - format(GENERIC_DROP_CONSTRAINT_STATEMENT, tableName, constraintName), - format("ALTER TABLE %s ALTER COLUMN %s INTEGER NOT NULL", tableName, column)); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/util/SqlHelper.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/util/SqlHelper.java deleted file mode 100644 index 88b75a7f1db..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/util/SqlHelper.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.util; - -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.Locale; -import org.sonar.db.Database; - -import static java.lang.String.format; - -public class SqlHelper { - - private final Database db; - - public SqlHelper(Database db) { - this.db = db; - } - - String getH2Constraint(String tableName) throws SQLException { - try (Connection connection = db.getDataSource().getConnection(); - PreparedStatement pstmt = connection - .prepareStatement(format("SELECT constraint_name " - + "FROM information_schema.constraints " - + "WHERE table_name = '%s' and constraint_type = 'PRIMARY KEY'", tableName.toUpperCase(Locale.ENGLISH))); - ResultSet rs = pstmt.executeQuery()) { - if (rs.next()) { - return rs.getString(1); - } - throw contraintNotFoundException(tableName); - } - } - - String getPostgresSqlConstraint(String tableName) throws SQLException { - try (Connection connection = db.getDataSource().getConnection(); - PreparedStatement pstmt = connection - .prepareStatement(format("SELECT conname " + - "FROM pg_constraint " + - "WHERE conrelid = " + - " (SELECT oid " + - " FROM pg_class " + - " WHERE relname LIKE '%s')", tableName)); - ResultSet rs = pstmt.executeQuery()) { - if (rs.next()) { - return rs.getString(1); - } - throw contraintNotFoundException(tableName); - } - } - - String getPostgresSqlSequence(String tableName, String columnName) throws SQLException { - try (Connection connection = db.getDataSource().getConnection(); - PreparedStatement pstmt = connection - .prepareStatement(format("SELECT pg_get_serial_sequence('%s', '%s')", tableName, columnName)); - ResultSet rs = pstmt.executeQuery()) { - if (rs.next()) { - return rs.getString(1); - } - throw new IllegalStateException(format("Cannot find sequence for table '%s' on column '%s'", tableName, columnName)); - } - } - - String getOracleConstraint(String tableName) throws SQLException { - try (Connection connection = db.getDataSource().getConnection(); - PreparedStatement pstmt = connection - .prepareStatement(format("SELECT constraint_name " + - "FROM user_constraints " + - "WHERE table_name = UPPER('%s') " + - "AND constraint_type='P'", tableName)); - ResultSet rs = pstmt.executeQuery()) { - if (rs.next()) { - return rs.getString(1); - } - throw contraintNotFoundException(tableName); - } - } - - String getMssqlConstraint(String tableName) throws SQLException { - try (Connection connection = db.getDataSource().getConnection(); - PreparedStatement pstmt = connection - .prepareStatement(format("SELECT name " + - "FROM sys.key_constraints " + - "WHERE type = 'PK' " + - "AND OBJECT_NAME(parent_object_id) = '%s'", tableName)); - ResultSet rs = pstmt.executeQuery()) { - if (rs.next()) { - return rs.getString(1); - } - throw contraintNotFoundException(tableName); - } - } - - private static IllegalStateException contraintNotFoundException(String tableName) { - return new IllegalStateException(format("Cannot find constraint for table '%s'", tableName)); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/DbVersion84.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/DbVersion84.java new file mode 100644 index 00000000000..7d13f6a0f3d --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/DbVersion84.java @@ -0,0 +1,781 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84; + +import org.sonar.server.platform.db.migration.step.MigrationStepRegistry; +import org.sonar.server.platform.db.migration.version.DbVersion; +import org.sonar.server.platform.db.migration.version.v84.activeruleparameters.AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTable; +import org.sonar.server.platform.db.migration.version.v84.activeruleparameters.AddUuidColumnToActiveRuleParametersTable; +import org.sonar.server.platform.db.migration.version.v84.activeruleparameters.DropIdColumnOfActiveRuleParametersTable; +import org.sonar.server.platform.db.migration.version.v84.activeruleparameters.DropPrimaryKeyOnIdColumnOfActiveRuleParametersTable; +import org.sonar.server.platform.db.migration.version.v84.activeruleparameters.MakeActiveRuleParametersUuidColumnNotNullable; +import org.sonar.server.platform.db.migration.version.v84.activeruleparameters.PopulateActiveRuleParametersUuid; +import org.sonar.server.platform.db.migration.version.v84.activerules.AddActiveRuleUuidColumnToActiveRuleParameters; +import org.sonar.server.platform.db.migration.version.v84.activerules.AddIndexOnActiveRuleUuidOfActiveRuleParametersTable; +import org.sonar.server.platform.db.migration.version.v84.activerules.AddPrimaryKeyOnUuidColumnOfActiveRulesTable; +import org.sonar.server.platform.db.migration.version.v84.activerules.AddUuidColumnToActiveRulesTable; +import org.sonar.server.platform.db.migration.version.v84.activerules.DropActiveRuleIdColumnOfActiveRuleParametersTable; +import org.sonar.server.platform.db.migration.version.v84.activerules.DropIdColumnOfActiveRulesTable; +import org.sonar.server.platform.db.migration.version.v84.activerules.DropIndexOnActiveRuleIdOfActiveRuleParametersTable; +import org.sonar.server.platform.db.migration.version.v84.activerules.DropPrimaryKeyOnIdColumnOfActiveRulesTable; +import org.sonar.server.platform.db.migration.version.v84.activerules.MakeActiveRuleParametersActiveRuleUuidNotNullable; +import org.sonar.server.platform.db.migration.version.v84.activerules.MakeActiveRulesUuidColumnNotNullable; +import org.sonar.server.platform.db.migration.version.v84.activerules.PopulateActiveRuleParametersActiveRuleUuid; +import org.sonar.server.platform.db.migration.version.v84.activerules.PopulateActiveRulesUuid; +import org.sonar.server.platform.db.migration.version.v84.ceactivity.AddPrimaryKeyOnUuidColumnOfCeActivityTable; +import org.sonar.server.platform.db.migration.version.v84.ceactivity.DropIdColumnOfCeActivityTable; +import org.sonar.server.platform.db.migration.version.v84.ceactivity.DropPrimaryKeyOnIdColumnOfCeActivityTable; +import org.sonar.server.platform.db.migration.version.v84.cequeue.AddPrimaryKeyOnUuidColumnOfCeQueueTable; +import org.sonar.server.platform.db.migration.version.v84.cequeue.DropIdColumnOfCeQueueTable; +import org.sonar.server.platform.db.migration.version.v84.cequeue.DropPrimaryKeyOnIdColumnOfCeQueueTable; +import org.sonar.server.platform.db.migration.version.v84.cequeue.DropUniqueIndexOnUuidColumnOfCeQueueTable; +import org.sonar.server.platform.db.migration.version.v84.duplicationsindex.AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTable; +import org.sonar.server.platform.db.migration.version.v84.duplicationsindex.AddUuidToDuplicationsIndexTable; +import org.sonar.server.platform.db.migration.version.v84.duplicationsindex.DropIdColumnOfDuplicationsIndexTable; +import org.sonar.server.platform.db.migration.version.v84.duplicationsindex.DropPrimaryKeyOnIdColumnOfDuplicationsIndexTable; +import org.sonar.server.platform.db.migration.version.v84.duplicationsindex.MakeDuplicationsIndexUuidColumnNotNullable; +import org.sonar.server.platform.db.migration.version.v84.duplicationsindex.PopulateDuplicationsIndexUuid; +import org.sonar.server.platform.db.migration.version.v84.events.AddPrimaryKeyOnUuidColumnOfEventsTable; +import org.sonar.server.platform.db.migration.version.v84.events.DropIdColumnOfEventsTable; +import org.sonar.server.platform.db.migration.version.v84.events.DropPrimaryKeyOnIdColumnOfEventsTable; +import org.sonar.server.platform.db.migration.version.v84.filesources.AddPrimaryKeyOnUuidColumnOfFileSourcesTable; +import org.sonar.server.platform.db.migration.version.v84.filesources.AddUuidColumnToFileSourcesTable; +import org.sonar.server.platform.db.migration.version.v84.filesources.DropIdColumnOfFileSourcesTable; +import org.sonar.server.platform.db.migration.version.v84.filesources.DropPrimaryKeyOnIdColumnOfFileSourcesTable; +import org.sonar.server.platform.db.migration.version.v84.filesources.MakeFileSourcesUuidColumnNotNullable; +import org.sonar.server.platform.db.migration.version.v84.filesources.PopulateFileSourcesUuid; +import org.sonar.server.platform.db.migration.version.v84.grouproles.AddPrimaryKeyOnUuidColumnOfGroupRolesTable; +import org.sonar.server.platform.db.migration.version.v84.grouproles.AddUuidColumnToGroupRolesTable; +import org.sonar.server.platform.db.migration.version.v84.grouproles.DropIdColumnOfGroupRolesTable; +import org.sonar.server.platform.db.migration.version.v84.grouproles.DropPrimaryKeyOnIdColumnOfGroupRolesTable; +import org.sonar.server.platform.db.migration.version.v84.grouproles.MakeGroupRolesUuidColumnNotNullable; +import org.sonar.server.platform.db.migration.version.v84.grouproles.PopulateGroupRolesUuid; +import org.sonar.server.platform.db.migration.version.v84.groups.AddPrimaryKeyOnUuidColumnOfGroupsTable; +import org.sonar.server.platform.db.migration.version.v84.groups.AddUuidColumnToGroupsTable; +import org.sonar.server.platform.db.migration.version.v84.groups.DropIdColumnOfGroupsTable; +import org.sonar.server.platform.db.migration.version.v84.groups.DropPrimaryKeyOnIdColumnOfGroupsTable; +import org.sonar.server.platform.db.migration.version.v84.groups.MakeGroupsUuidColumnNotNullable; +import org.sonar.server.platform.db.migration.version.v84.groups.PopulateGroupsUuid; +import org.sonar.server.platform.db.migration.version.v84.groups.grouproles.AddGroupUuidColumnToGroupRoles; +import org.sonar.server.platform.db.migration.version.v84.groups.grouproles.AddIndexOnGroupUuidOfGroupRolesTable; +import org.sonar.server.platform.db.migration.version.v84.groups.grouproles.DropGroupIdColumnOfGroupRolesTable; +import org.sonar.server.platform.db.migration.version.v84.groups.grouproles.DropIndexOnGroupIdOfGroupRolesTable; +import org.sonar.server.platform.db.migration.version.v84.groups.grouproles.PopulateGroupRolesGroupUuid; +import org.sonar.server.platform.db.migration.version.v84.groups.groupsusers.AddGroupUuidColumnToGroupsUsers; +import org.sonar.server.platform.db.migration.version.v84.groups.groupsusers.AddIndexOnGroupUuidOfGroupsUsersTable; +import org.sonar.server.platform.db.migration.version.v84.groups.groupsusers.DropGroupIdColumnOfGroupsUsersTable; +import org.sonar.server.platform.db.migration.version.v84.groups.groupsusers.DropIndexOnGroupIdOfGroupsUsersTable; +import org.sonar.server.platform.db.migration.version.v84.groups.groupsusers.MakeGroupsUsersGroupUuidNotNullable; +import org.sonar.server.platform.db.migration.version.v84.groups.groupsusers.PopulateGroupsUsersGroupUuid; +import org.sonar.server.platform.db.migration.version.v84.groups.organizations.AddDefaultGroupUuidColumnToOrganizations; +import org.sonar.server.platform.db.migration.version.v84.groups.organizations.DropDefaultGroupIdColumnOfOrganizationsTable; +import org.sonar.server.platform.db.migration.version.v84.groups.organizations.PopulateOrganizationsDefaultGroupUuid; +import org.sonar.server.platform.db.migration.version.v84.groups.permtemplatesgroups.AddGroupUuidColumnToPermTemplatesGroups; +import org.sonar.server.platform.db.migration.version.v84.groups.permtemplatesgroups.DropGroupIdColumnOfPermTemplatesGroupsTable; +import org.sonar.server.platform.db.migration.version.v84.groups.permtemplatesgroups.PopulatePermTemplatesGroupsGroupUuid; +import org.sonar.server.platform.db.migration.version.v84.groups.qprofileeditgroups.AddGroupUuidColumnToQProfileEditGroups; +import org.sonar.server.platform.db.migration.version.v84.groups.qprofileeditgroups.AddIndexOnGroupUuidOfQProfileEditGroupsTable; +import org.sonar.server.platform.db.migration.version.v84.groups.qprofileeditgroups.DropGroupIdColumnOfQProfileEditGroupsTable; +import org.sonar.server.platform.db.migration.version.v84.groups.qprofileeditgroups.DropIndexOnGroupIdOfQProfileEditGroupsTable; +import org.sonar.server.platform.db.migration.version.v84.groups.qprofileeditgroups.MakeQProfileEditGroupsGroupUuidNotNullable; +import org.sonar.server.platform.db.migration.version.v84.groups.qprofileeditgroups.PopulateQProfileEditGroupsGroupUuid; +import org.sonar.server.platform.db.migration.version.v84.issuechanges.AddPrimaryKeyOnUuidColumnOfIssueChangesTable; +import org.sonar.server.platform.db.migration.version.v84.issuechanges.AddUuidColumnToIssueChangesTable; +import org.sonar.server.platform.db.migration.version.v84.issuechanges.DropIdColumnOfIssueChangesTable; +import org.sonar.server.platform.db.migration.version.v84.issuechanges.DropPrimaryKeyOnIdColumnOfIssueChangesTable; +import org.sonar.server.platform.db.migration.version.v84.issuechanges.MakeIssueChangesUuidColumnNotNullable; +import org.sonar.server.platform.db.migration.version.v84.issuechanges.PopulateIssueChangesUuid; +import org.sonar.server.platform.db.migration.version.v84.issues.AddPrimaryKeyOnKeeColumnOfIssuesTable; +import org.sonar.server.platform.db.migration.version.v84.issues.DropIdColumnOfIssuesTable; +import org.sonar.server.platform.db.migration.version.v84.issues.DropPrimaryKeyOnIdColumnOfIssuesTable; +import org.sonar.server.platform.db.migration.version.v84.manualmeasures.AddPrimaryKeyOnUuidColumnOfManualMeasuresTable; +import org.sonar.server.platform.db.migration.version.v84.manualmeasures.AddUuidColumnToManualMeasures; +import org.sonar.server.platform.db.migration.version.v84.manualmeasures.DropIdColumnOfManualMeasuresTable; +import org.sonar.server.platform.db.migration.version.v84.manualmeasures.DropPrimaryKeyOnIdColumnOfManualMeasuresTable; +import org.sonar.server.platform.db.migration.version.v84.manualmeasures.MakeManualMeasuresUuidColumnNotNullable; +import org.sonar.server.platform.db.migration.version.v84.manualmeasures.PopulateManualMeasureUuid; +import org.sonar.server.platform.db.migration.version.v84.metrics.AddPrimaryKeyOnUuidColumnOfMetricsTable; +import org.sonar.server.platform.db.migration.version.v84.metrics.AddUuidColumnToMetricsTable; +import org.sonar.server.platform.db.migration.version.v84.metrics.DropIdColumnOfMetricsTable; +import org.sonar.server.platform.db.migration.version.v84.metrics.DropPrimaryKeyOnIdColumnOfMetricsTable; +import org.sonar.server.platform.db.migration.version.v84.metrics.MakeMetricsUuidColumnNotNullable; +import org.sonar.server.platform.db.migration.version.v84.metrics.PopulateMetricsUuid; +import org.sonar.server.platform.db.migration.version.v84.metrics.livemeasures.AddIndexOnMetricUuidOfLiveMeasuresTable; +import org.sonar.server.platform.db.migration.version.v84.metrics.livemeasures.AddMetricUuidColumnToLiveMeasures; +import org.sonar.server.platform.db.migration.version.v84.metrics.livemeasures.DropIndexOnMetricIdOfLiveMeasuresTable; +import org.sonar.server.platform.db.migration.version.v84.metrics.livemeasures.DropMetricIdColumnOfLiveMeasuresTable; +import org.sonar.server.platform.db.migration.version.v84.metrics.livemeasures.MakeLiveMeasuresMetricUuidNotNullable; +import org.sonar.server.platform.db.migration.version.v84.metrics.livemeasures.PopulateLiveMeasuresMetricUuid; +import org.sonar.server.platform.db.migration.version.v84.metrics.manualmeasures.AddMetricUuidColumnToManualMeasures; +import org.sonar.server.platform.db.migration.version.v84.metrics.manualmeasures.DropMetricIdColumnOfManualMeasuresTable; +import org.sonar.server.platform.db.migration.version.v84.metrics.manualmeasures.MakeManualMeasuresMetricUuidNotNullable; +import org.sonar.server.platform.db.migration.version.v84.metrics.manualmeasures.PopulateManualMeasuresMetricUuid; +import org.sonar.server.platform.db.migration.version.v84.metrics.projectmeasures.AddIndexOnMetricUuidOfProjectMeasuresTable; +import org.sonar.server.platform.db.migration.version.v84.metrics.projectmeasures.AddMetricUuidColumnToProjectMeasures; +import org.sonar.server.platform.db.migration.version.v84.metrics.projectmeasures.DropIndexOnMetricIdOfProjectMeasuresTable; +import org.sonar.server.platform.db.migration.version.v84.metrics.projectmeasures.DropMetricIdColumnOfProjectMeasuresTable; +import org.sonar.server.platform.db.migration.version.v84.metrics.projectmeasures.MakeProjectMeasuresMetricUuidNotNullable; +import org.sonar.server.platform.db.migration.version.v84.metrics.projectmeasures.PopulateProjectMeasuresMetricUuid; +import org.sonar.server.platform.db.migration.version.v84.metrics.qualitygateconditions.AddMetricUuidColumnToQualityGateConditions; +import org.sonar.server.platform.db.migration.version.v84.metrics.qualitygateconditions.DropMetricIdColumnOfQualityGateConditionsTable; +import org.sonar.server.platform.db.migration.version.v84.metrics.qualitygateconditions.MakeQualityGateConditionsMetricUuidNotNullable; +import org.sonar.server.platform.db.migration.version.v84.metrics.qualitygateconditions.PopulateQualityGateConditionsMetricUuid; +import org.sonar.server.platform.db.migration.version.v84.notifications.AddPrimaryKeyOnUuidColumnOfNotificationTable; +import org.sonar.server.platform.db.migration.version.v84.notifications.AddUuidAndCreatedAtColumnsToNotification; +import org.sonar.server.platform.db.migration.version.v84.notifications.DropIdColumnOfNotificationTable; +import org.sonar.server.platform.db.migration.version.v84.notifications.DropPrimaryKeyOnIdColumnOfNotificationTable; +import org.sonar.server.platform.db.migration.version.v84.notifications.MakeNotificationUuidAndCreatedAtColumnsNotNullable; +import org.sonar.server.platform.db.migration.version.v84.notifications.PopulateNotificationUuidAndCreatedAt; +import org.sonar.server.platform.db.migration.version.v84.permissiontemplates.AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTable; +import org.sonar.server.platform.db.migration.version.v84.permissiontemplates.AddUuidColumnToPermissionTemplates; +import org.sonar.server.platform.db.migration.version.v84.permissiontemplates.DropIdColumnOfPermissionTemplatesTable; +import org.sonar.server.platform.db.migration.version.v84.permissiontemplates.DropKeeColumnOfPermissionTemplatesTable; +import org.sonar.server.platform.db.migration.version.v84.permissiontemplates.DropPrimaryKeyOnIdColumnOfPermissionTemplatesTable; +import org.sonar.server.platform.db.migration.version.v84.permissiontemplates.MakePermissionTemplateUuidColumnNotNullable; +import org.sonar.server.platform.db.migration.version.v84.permissiontemplates.PopulatePermissionTemplatesUuid; +import org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesgroups.AddTemplateUuidColumnToPermTemplatesGroups; +import org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesgroups.DropTemplateIdColumnOfPermTemplatesGroupsTable; +import org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesgroups.MakePermTemplatesGroupsTemplateUuidColumnNotNullable; +import org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesgroups.PopulatePermTemplatesGroupsTemplateUuidColumn; +import org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesusers.AddTemplateUuidColumnToPermTemplatesUsers; +import org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesusers.DropTemplateIdColumnOfPermTemplatesUsersTable; +import org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesusers.MakePermTemplatesUsersTemplateUuidColumnNotNullable; +import org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesusers.PopulatePermTemplatesUsersTemplateUuidColumn; +import org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtplcharacteristics.AddTemplateUuidColumnToPermTplCharacteristics; +import org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtplcharacteristics.AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTable; +import org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtplcharacteristics.DropTemplateIdColumnOfPermTplCharacteristicsTable; +import org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtplcharacteristics.DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTable; +import org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtplcharacteristics.MakePermTplCharacteristicsTemplateUuidColumnNotNullable; +import org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtplcharacteristics.PopulatePermTplCharacteristicsTemplateUuidColumn; +import org.sonar.server.platform.db.migration.version.v84.permtemplatesgroups.AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTable; +import org.sonar.server.platform.db.migration.version.v84.permtemplatesgroups.AddUuidColumnToPermTemplatesGroupsTable; +import org.sonar.server.platform.db.migration.version.v84.permtemplatesgroups.DropIdColumnOfPermTemplatesGroupsTable; +import org.sonar.server.platform.db.migration.version.v84.permtemplatesgroups.DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTable; +import org.sonar.server.platform.db.migration.version.v84.permtemplatesgroups.MakePermTemplatesGroupsUuidColumnNotNullable; +import org.sonar.server.platform.db.migration.version.v84.permtemplatesgroups.PopulatePermTemplatesGroupsUuid; +import org.sonar.server.platform.db.migration.version.v84.permtemplatesusers.AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTable; +import org.sonar.server.platform.db.migration.version.v84.permtemplatesusers.AddUuidColumnToPermTemplatesUsersTable; +import org.sonar.server.platform.db.migration.version.v84.permtemplatesusers.DropIdColumnOfPermTemplatesUsersTable; +import org.sonar.server.platform.db.migration.version.v84.permtemplatesusers.DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTable; +import org.sonar.server.platform.db.migration.version.v84.permtemplatesusers.MakePermTemplatesUsersUuidColumnNotNullable; +import org.sonar.server.platform.db.migration.version.v84.permtemplatesusers.PopulatePermTemplatesUsersUuid; +import org.sonar.server.platform.db.migration.version.v84.permtplcharacteristics.AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTable; +import org.sonar.server.platform.db.migration.version.v84.permtplcharacteristics.AddUuidColumnToPermTplCharacteristicsTable; +import org.sonar.server.platform.db.migration.version.v84.permtplcharacteristics.DropIdColumnOfPermTplCharacteristicsTable; +import org.sonar.server.platform.db.migration.version.v84.permtplcharacteristics.DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTable; +import org.sonar.server.platform.db.migration.version.v84.permtplcharacteristics.MakePermTplCharacteristicsUuidColumnNotNullable; +import org.sonar.server.platform.db.migration.version.v84.permtplcharacteristics.PopulatePermTplCharacteristicsUuid; +import org.sonar.server.platform.db.migration.version.v84.projectmeasures.AddPrimaryKeyOnUuidColumnOfProjectMeasuresTable; +import org.sonar.server.platform.db.migration.version.v84.projectmeasures.AddUuidColumnToProjectMeasures; +import org.sonar.server.platform.db.migration.version.v84.projectmeasures.DropIdColumnOfProjectMeasuresTable; +import org.sonar.server.platform.db.migration.version.v84.projectmeasures.DropPrimaryKeyOnIdColumnOfProjectMeasuresTable; +import org.sonar.server.platform.db.migration.version.v84.projectmeasures.MakeProjectMeasuresUuidColumnNotNullable; +import org.sonar.server.platform.db.migration.version.v84.projectmeasures.PopulateProjectMeasureUuid; +import org.sonar.server.platform.db.migration.version.v84.projectqprofiles.AddPrimaryKeyOnUuidColumnOfProjectQProfilesTable; +import org.sonar.server.platform.db.migration.version.v84.projectqprofiles.AddUuidColumnToProjectQProfilesTable; +import org.sonar.server.platform.db.migration.version.v84.projectqprofiles.DropIdColumnOfProjectQProfilesTable; +import org.sonar.server.platform.db.migration.version.v84.projectqprofiles.DropPrimaryKeyOnIdColumnOfProjectQProfilesTable; +import org.sonar.server.platform.db.migration.version.v84.projectqprofiles.MakeProjectQProfilesUuidColumnNotNullable; +import org.sonar.server.platform.db.migration.version.v84.projectqprofiles.PopulateProjectQProfilesUuid; +import org.sonar.server.platform.db.migration.version.v84.properties.AddPrimaryKeyOnUuidColumnOfPropertiesTable; +import org.sonar.server.platform.db.migration.version.v84.properties.AddUuidColumnToProperties; +import org.sonar.server.platform.db.migration.version.v84.properties.DropIdColumnOfPropertiesTable; +import org.sonar.server.platform.db.migration.version.v84.properties.DropPrimaryKeyOnIdColumnOfPropertiesTable; +import org.sonar.server.platform.db.migration.version.v84.properties.MakePropertiesUuidColumnNotNullable; +import org.sonar.server.platform.db.migration.version.v84.properties.PopulatePropertiesUuid; +import org.sonar.server.platform.db.migration.version.v84.qualitygateconditions.AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTable; +import org.sonar.server.platform.db.migration.version.v84.qualitygateconditions.AddUuidColumnToQualityGateConditionsTable; +import org.sonar.server.platform.db.migration.version.v84.qualitygateconditions.DropIdColumnOfQualityGateConditionsTable; +import org.sonar.server.platform.db.migration.version.v84.qualitygateconditions.DropPrimaryKeyOnIdColumnOfQualityGateConditionsTable; +import org.sonar.server.platform.db.migration.version.v84.qualitygateconditions.MakeQualityGateConditionsUuidColumnNotNullable; +import org.sonar.server.platform.db.migration.version.v84.qualitygateconditions.PopulateQualityGateConditionsUuid; +import org.sonar.server.platform.db.migration.version.v84.qualitygates.AddPrimaryKeyOnUuidColumnOfQGatesTable; +import org.sonar.server.platform.db.migration.version.v84.qualitygates.AddQGateUuidColumnForQGateConditions; +import org.sonar.server.platform.db.migration.version.v84.qualitygates.DropIdColumnOfQGateTable; +import org.sonar.server.platform.db.migration.version.v84.qualitygates.DropOrphansQGateConditions; +import org.sonar.server.platform.db.migration.version.v84.qualitygates.DropPrimaryKeyOnIdColumnOfQGatesTable; +import org.sonar.server.platform.db.migration.version.v84.qualitygates.DropQGateIdColumnForQGateConditions; +import org.sonar.server.platform.db.migration.version.v84.qualitygates.DropUniqueIndexOnUuidColumnOfQualityGatesTable; +import org.sonar.server.platform.db.migration.version.v84.qualitygates.MakeQGateUuidColumnNotNullableForQGateConditions; +import org.sonar.server.platform.db.migration.version.v84.qualitygates.PopulateQGateUuidColumnForQGateConditions; +import org.sonar.server.platform.db.migration.version.v84.rules.AddPrimaryKeyOnUuidColumnOfRulesTable; +import org.sonar.server.platform.db.migration.version.v84.rules.AddUuidAndTemplateUuidColumnsToRules; +import org.sonar.server.platform.db.migration.version.v84.rules.DropIdColumnOfRulesTable; +import org.sonar.server.platform.db.migration.version.v84.rules.DropPrimaryKeyOnIdColumnOfRulesTable; +import org.sonar.server.platform.db.migration.version.v84.rules.DropTemplateIdColumnOfRulesTable; +import org.sonar.server.platform.db.migration.version.v84.rules.MakeRulesUuidColumnNotNullable; +import org.sonar.server.platform.db.migration.version.v84.rules.PopulateRulesTemplateUuid; +import org.sonar.server.platform.db.migration.version.v84.rules.PopulateRulesUuid; +import org.sonar.server.platform.db.migration.version.v84.rules.activerules.AddIndexToActiveRulesTable; +import org.sonar.server.platform.db.migration.version.v84.rules.activerules.AddRuleUuidColumnToActiveRulesTable; +import org.sonar.server.platform.db.migration.version.v84.rules.activerules.DropIndexOnRuleIdColumnOfActiveRulesTable; +import org.sonar.server.platform.db.migration.version.v84.rules.activerules.DropRuleIdColumnOfActiveRulesTable; +import org.sonar.server.platform.db.migration.version.v84.rules.activerules.MakeActiveRulesRuleUuidColumnNotNullable; +import org.sonar.server.platform.db.migration.version.v84.rules.activerules.PopulateActiveRulesRuleUuidColumn; +import org.sonar.server.platform.db.migration.version.v84.rules.deprecatedrulekeys.AddIndexToDeprecatedRuleKeysTable; +import org.sonar.server.platform.db.migration.version.v84.rules.deprecatedrulekeys.AddRuleUuidColumnToDeprecatedRuleKeysTable; +import org.sonar.server.platform.db.migration.version.v84.rules.deprecatedrulekeys.DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTable; +import org.sonar.server.platform.db.migration.version.v84.rules.deprecatedrulekeys.DropRuleIdColumnOfDeprecatedRuleKeysTable; +import org.sonar.server.platform.db.migration.version.v84.rules.deprecatedrulekeys.MakeDeprecatedRuleKeysRuleUuidColumnNotNullable; +import org.sonar.server.platform.db.migration.version.v84.rules.deprecatedrulekeys.PopulateDeprecatedRuleKeysRuleUuidColumn; +import org.sonar.server.platform.db.migration.version.v84.rules.issues.AddIndexToIssuesTable; +import org.sonar.server.platform.db.migration.version.v84.rules.issues.AddRuleUuidColumnToIssuesTable; +import org.sonar.server.platform.db.migration.version.v84.rules.issues.DropIndexOnRuleIdColumnOfIssuesTable; +import org.sonar.server.platform.db.migration.version.v84.rules.issues.DropRuleIdColumnOfIssuesTable; +import org.sonar.server.platform.db.migration.version.v84.rules.issues.PopulateIssuesRuleUuidColumn; +import org.sonar.server.platform.db.migration.version.v84.rules.rulesmetadata.AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTable; +import org.sonar.server.platform.db.migration.version.v84.rules.rulesmetadata.AddRuleUuidColumnToRulesMetadataTable; +import org.sonar.server.platform.db.migration.version.v84.rules.rulesmetadata.DropPrimaryKeyOnIdColumnOfRulesMetadataTable; +import org.sonar.server.platform.db.migration.version.v84.rules.rulesmetadata.DropRuleIdColumnOfRulesMetadataTable; +import org.sonar.server.platform.db.migration.version.v84.rules.rulesmetadata.MakeRulesMetadataRuleUuidColumnNotNullable; +import org.sonar.server.platform.db.migration.version.v84.rules.rulesmetadata.PopulateRulesMetadataRuleUuidColumn; +import org.sonar.server.platform.db.migration.version.v84.rules.rulesparameters.AddIndexesToRulesParametersTable; +import org.sonar.server.platform.db.migration.version.v84.rules.rulesparameters.AddRuleUuidColumnToRulesParametersTable; +import org.sonar.server.platform.db.migration.version.v84.rules.rulesparameters.DropIndexesOnRuleIdColumnOfRulesParametersTable; +import org.sonar.server.platform.db.migration.version.v84.rules.rulesparameters.DropRuleIdColumnOfRulesParametersTable; +import org.sonar.server.platform.db.migration.version.v84.rules.rulesparameters.MakeRulesParametersRuleUuidColumnNotNullable; +import org.sonar.server.platform.db.migration.version.v84.rules.rulesparameters.PopulateRulesParametersRuleUuidColumn; +import org.sonar.server.platform.db.migration.version.v84.rulesparameters.AddPrimaryKeyOnUuidColumnOfRulesParametersTable; +import org.sonar.server.platform.db.migration.version.v84.rulesparameters.AddUuidColumnToRulesParameters; +import org.sonar.server.platform.db.migration.version.v84.rulesparameters.DropIdColumnOfRulesParametersTable; +import org.sonar.server.platform.db.migration.version.v84.rulesparameters.DropPrimaryKeyOnIdColumnOfRulesParametersTable; +import org.sonar.server.platform.db.migration.version.v84.rulesparameters.MakeRulesParametersUuidColumnNotNullable; +import org.sonar.server.platform.db.migration.version.v84.rulesparameters.PopulateRulesParametersUuid; +import org.sonar.server.platform.db.migration.version.v84.rulesparameters.fk.AddRulesParameterUuidColumnToActiveRuleParameters; +import org.sonar.server.platform.db.migration.version.v84.rulesparameters.fk.DropRulesParameterIdColumnOfActiveRuleParametersTable; +import org.sonar.server.platform.db.migration.version.v84.rulesparameters.fk.MakeActiveRuleParametersRulesParameterUuidColumnNotNullable; +import org.sonar.server.platform.db.migration.version.v84.rulesparameters.fk.PopulateActiveRuleParametersRulesParameterUuid; +import org.sonar.server.platform.db.migration.version.v84.rulesprofiles.AddPrimaryKeyOnUuidColumnOfRulesProfilesTable; +import org.sonar.server.platform.db.migration.version.v84.rulesprofiles.AddUuidColumnToRulesProfilesTable; +import org.sonar.server.platform.db.migration.version.v84.rulesprofiles.DropIdColumnOfRulesProfilesTable; +import org.sonar.server.platform.db.migration.version.v84.rulesprofiles.DropKeeColumnOfRulesProfilesTable; +import org.sonar.server.platform.db.migration.version.v84.rulesprofiles.DropPrimaryKeyOnIdColumnOfRulesProfilesTable; +import org.sonar.server.platform.db.migration.version.v84.rulesprofiles.DropUniqueIndexOnKeeColumnOfRulesProfilesTable; +import org.sonar.server.platform.db.migration.version.v84.rulesprofiles.MakeRulesProfilesUuidColumnNotNullable; +import org.sonar.server.platform.db.migration.version.v84.rulesprofiles.PopulateRulesProfilesUuid; +import org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.activerules.AddProfileUuidColumnToActiveRulesTable; +import org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.activerules.AddUniqueIndexOnProfileUuidColumnOfActiveRulesTable; +import org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.activerules.DropProfileIdColumnOfActiveRulesTable; +import org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.activerules.DropUniqueIndexOnProfileIdColumnOfActiveRulesTable; +import org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.activerules.MakeActiveRulesProfileUuidColumnNotNullable; +import org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.activerules.PopulateActiveRulesProfileUuid; +import org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.orgqprofiles.PopulateOrgQProfilesRulesProfileUuid; +import org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.qprofilechanges.PopulateQProfileChangesRulesProfileUuid; +import org.sonar.server.platform.db.migration.version.v84.snapshots.issues.AddPrimaryKeyOnUuidColumnOfSnapshotsTable; +import org.sonar.server.platform.db.migration.version.v84.snapshots.issues.DropIdColumnOfSnapshotsTable; +import org.sonar.server.platform.db.migration.version.v84.snapshots.issues.DropPrimaryKeyOnIdColumnOfSnapshotsTable; +import org.sonar.server.platform.db.migration.version.v84.userroles.AddPrimaryKeyOnUuidColumnOfUserRolesTable; +import org.sonar.server.platform.db.migration.version.v84.userroles.AddUuidColumnToUserRolesTable; +import org.sonar.server.platform.db.migration.version.v84.userroles.DropIdColumnOfUserRolesTable; +import org.sonar.server.platform.db.migration.version.v84.userroles.DropPrimaryKeyOnIdColumnOfUserRolesTable; +import org.sonar.server.platform.db.migration.version.v84.userroles.MakeUserRolesUuidColumnNotNullable; +import org.sonar.server.platform.db.migration.version.v84.userroles.PopulateUserRolesUuid; +import org.sonar.server.platform.db.migration.version.v84.users.AddPrimaryKeyOnUuidColumnOfUsersTable; +import org.sonar.server.platform.db.migration.version.v84.users.DropIdColumnOfUsersTable; +import org.sonar.server.platform.db.migration.version.v84.users.DropPrimaryKeyOnIdColumnOfUsersTable; +import org.sonar.server.platform.db.migration.version.v84.users.DropUniqueIndexOnUuidColumnOfUsersTable; +import org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers.AddIndexOnUserUuidOfGroupsUsersTable; +import org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers.AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTable; +import org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers.AddUserUuidColumnToGroupsUsers; +import org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers.DropIndexOnUserIdOfGroupsUsersTable; +import org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers.DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTable; +import org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers.DropUserIdColumnOfGroupsUsersTable; +import org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers.MakeGroupsUsersUserUuidColumnNotNullable; +import org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers.PopulateGroupsUsersUserUuid; +import org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers.AddIndexOnUserUuidOfOrganizationMembersTable; +import org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers.AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTable; +import org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers.AddUserUuidColumnToOrganizationMembers; +import org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers.DropIndexOnUserIdOfOrganizationMembersTable; +import org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers.DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTable; +import org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers.DropUserIdColumnOfOrganizationMembersTable; +import org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers.MakeOrganizationMembersUserUuidColumnNotNullable; +import org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers.PopulateOrganizationMembersUserUuid; +import org.sonar.server.platform.db.migration.version.v84.users.fk.permtemplatesusers.AddUserUuidColumnToPermTemplatesUsers; +import org.sonar.server.platform.db.migration.version.v84.users.fk.permtemplatesusers.DropUserIdColumnOfPermTemplatesUsersTable; +import org.sonar.server.platform.db.migration.version.v84.users.fk.permtemplatesusers.MakePermTemplatesUsersUserUuidColumnNotNullable; +import org.sonar.server.platform.db.migration.version.v84.users.fk.permtemplatesusers.PopulatePermTemplatesUsersUserUuid; +import org.sonar.server.platform.db.migration.version.v84.users.fk.properties.AddUserUuidColumnToPropertiesUsers; +import org.sonar.server.platform.db.migration.version.v84.users.fk.properties.DropUserIdColumnOfPropertiesTable; +import org.sonar.server.platform.db.migration.version.v84.users.fk.properties.PopulatePropertiesUserUuid; +import org.sonar.server.platform.db.migration.version.v84.users.fk.qprofileeditusers.AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTable; +import org.sonar.server.platform.db.migration.version.v84.users.fk.qprofileeditusers.AddUserUuidColumnToQProfileEditUsers; +import org.sonar.server.platform.db.migration.version.v84.users.fk.qprofileeditusers.DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTable; +import org.sonar.server.platform.db.migration.version.v84.users.fk.qprofileeditusers.DropUserIdColumnOfQProfileEditUsersTable; +import org.sonar.server.platform.db.migration.version.v84.users.fk.qprofileeditusers.MakeQProfileEditUsersUserUuidColumnNotNullable; +import org.sonar.server.platform.db.migration.version.v84.users.fk.qprofileeditusers.PopulateQProfileEditUsersUserUuid; +import org.sonar.server.platform.db.migration.version.v84.users.fk.userroles.AddIndexOnUserUuidOfUserRolesTable; +import org.sonar.server.platform.db.migration.version.v84.users.fk.userroles.AddUserUuidColumnToUserRoles; +import org.sonar.server.platform.db.migration.version.v84.users.fk.userroles.DropIndexOnUserIdOfUserRolesTable; +import org.sonar.server.platform.db.migration.version.v84.users.fk.userroles.DropUserIdColumnOfUserRolesTable; +import org.sonar.server.platform.db.migration.version.v84.users.fk.userroles.PopulateUserRolesUserUuid; +import org.sonar.server.platform.db.migration.version.v84.usertokens.AddPrimaryKeyOnUuidColumnOfUserTokensTable; +import org.sonar.server.platform.db.migration.version.v84.usertokens.AddUuidColumnToUserTokens; +import org.sonar.server.platform.db.migration.version.v84.usertokens.DropIdColumnOfUserTokensTable; +import org.sonar.server.platform.db.migration.version.v84.usertokens.DropPrimaryKeyOnIdColumnOfUserTokensTable; +import org.sonar.server.platform.db.migration.version.v84.usertokens.MakeUserTokensUuidNotNullable; +import org.sonar.server.platform.db.migration.version.v84.usertokens.PopulateUserTokensUuid; + +public class DbVersion84 implements DbVersion { + @Override + public void addSteps(MigrationStepRegistry registry) { + registry + // Migration on EVENTS table + .add(3400, "Drop primary key on 'ID' column of 'EVENTS' table", DropPrimaryKeyOnIdColumnOfEventsTable.class) + .add(3401, "Add primary key on 'UUID' column of 'EVENTS' table", AddPrimaryKeyOnUuidColumnOfEventsTable.class) + .add(3402, "Drop column 'ID' of 'EVENTS' table", DropIdColumnOfEventsTable.class) + + // Migrations of NOTIFICATIONS table + .add(3403, "Add 'uuid' and 'createdAt' columns for notifications", AddUuidAndCreatedAtColumnsToNotification.class) + .add(3404, "Populate 'uuid' and 'createdAt columns for notifications", PopulateNotificationUuidAndCreatedAt.class) + .add(3405, "Make 'uuid' and 'createdAt' column not nullable for notifications", MakeNotificationUuidAndCreatedAtColumnsNotNullable.class) + .add(3406, "Drop primary key on 'ID' column of 'NOTIFICATIONS' table", DropPrimaryKeyOnIdColumnOfNotificationTable.class) + .add(3407, "Add primary key on 'UUID' column of 'NOTIFICATIONS' table", AddPrimaryKeyOnUuidColumnOfNotificationTable.class) + .add(3408, "Drop column 'ID' of 'NOTIFICATIONS' table", DropIdColumnOfNotificationTable.class) + + // Migration on ISSUES table + .add(3409, "Drop primary key on 'ID' column of 'ISSUES' table", DropPrimaryKeyOnIdColumnOfIssuesTable.class) + .add(3410, "Add primary key on 'KEE' column of 'ISSUES' table", AddPrimaryKeyOnKeeColumnOfIssuesTable.class) + .add(3411, "Drop column 'ID' of 'ISSUES' table", DropIdColumnOfIssuesTable.class) + + // Migration on SNAPSHOTS table + .add(3412, "Drop primary key on 'ID' column of 'SNAPSHOTS' table", DropPrimaryKeyOnIdColumnOfSnapshotsTable.class) + .add(3413, "Add primary key on 'UUID' column of 'SNAPSHOTS' table", AddPrimaryKeyOnUuidColumnOfSnapshotsTable.class) + .add(3414, "Drop column 'ID' of 'SNAPSHOTS' table", DropIdColumnOfSnapshotsTable.class) + + // Migration on CE_QUEUE table + .add(3415, "Drop unique index on 'uuid' column of 'CE_QUEUE' table", DropUniqueIndexOnUuidColumnOfCeQueueTable.class) + .add(3416, "Drop primary key on 'ID' column of 'CE_QUEUE' table", DropPrimaryKeyOnIdColumnOfCeQueueTable.class) + .add(3417, "Add primary key on 'UUID' column of 'CE_QUEUE' table", AddPrimaryKeyOnUuidColumnOfCeQueueTable.class) + .add(3418, "Drop column 'ID' of 'CE_QUEUE' table", DropIdColumnOfCeQueueTable.class) + + // Migration on CE_ACTIVITY table + .add(3419, "Drop primary key on 'ID' column of 'CE_ACTIVITY' table", DropPrimaryKeyOnIdColumnOfCeActivityTable.class) + .add(3420, "Add primary key on 'UUID' column of 'CE_ACTIVITY' table", AddPrimaryKeyOnUuidColumnOfCeActivityTable.class) + .add(3421, "Drop column 'ID' of 'CE_ACTIVITY' table", DropIdColumnOfCeActivityTable.class) + + // Migration of DUPLICATIONS_INDEX table + .add(3422, "Add 'uuid' columns for DUPLICATIONS_INDEX", AddUuidToDuplicationsIndexTable.class) + .add(3423, "Populate 'uuid' columns for DUPLICATIONS_INDEX", PopulateDuplicationsIndexUuid.class) + .add(3424, "Make 'uuid' column not nullable for DUPLICATIONS_INDEX", MakeDuplicationsIndexUuidColumnNotNullable.class) + .add(3425, "Drop primary key on 'ID' column of 'DUPLICATIONS_INDEX' table", DropPrimaryKeyOnIdColumnOfDuplicationsIndexTable.class) + .add(3426, "Add primary key on 'UUID' column of 'DUPLICATIONS_INDEX' table", AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTable.class) + .add(3427, "Drop column 'ID' of 'DUPLICATIONS_INDEX' table", DropIdColumnOfDuplicationsIndexTable.class) + + // Migration of ACTIVE_RULE_PARAMS table + .add(3428, "Add 'uuid' column for 'ACTIVE_RULE_PARAMS' table", AddUuidColumnToActiveRuleParametersTable.class) + .add(3429, "Populate 'uuid' column for 'ACTIVE_RULE_PARAMS' table", PopulateActiveRuleParametersUuid.class) + .add(3430, "Make 'uuid' column not nullable for 'ACTIVE_RULE_PARAMS' table", MakeActiveRuleParametersUuidColumnNotNullable.class) + .add(3431, "Drop primary key on 'ID' column of 'ACTIVE_RULE_PARAMS' table", DropPrimaryKeyOnIdColumnOfActiveRuleParametersTable.class) + .add(3432, "Add primary key on 'UUID' column of 'ACTIVE_RULE_PARAMS' table", AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTable.class) + .add(3433, "Drop column 'ID' of 'ACTIVE_RULE_PARAMS' table", DropIdColumnOfActiveRuleParametersTable.class) + + // Migration on PROJECT_MEASURES table + .add(3434, "Add 'uuid' columns for 'PROJECT_MEASURES'", AddUuidColumnToProjectMeasures.class) + .add(3435, "Populate 'uuid' column for 'PROJECT_MEASURES'", PopulateProjectMeasureUuid.class) + .add(3436, "Make 'uuid' column not nullable for 'PROJECT_MEASURES'", MakeProjectMeasuresUuidColumnNotNullable.class) + .add(3437, "Drop primary key on 'ID' column of 'PROJECT_MEASURES' table", DropPrimaryKeyOnIdColumnOfProjectMeasuresTable.class) + .add(3438, "Add primary key on 'UUID' column of 'PROJECT_MEASURES' table", AddPrimaryKeyOnUuidColumnOfProjectMeasuresTable.class) + .add(3439, "Drop column 'ID' of 'PROJECT_MEASURES' table", DropIdColumnOfProjectMeasuresTable.class) + + // Migration of USER_TOKENS table + .add(3440, "Add 'UUID' column on 'USER_TOKENS' table", AddUuidColumnToUserTokens.class) + .add(3441, "Populate 'uuid' for 'USER_TOKENS'", PopulateUserTokensUuid.class) + .add(3442, "Make 'uuid' column not nullable for user_tokens", MakeUserTokensUuidNotNullable.class) + .add(3443, "Drop primary key on 'ID' column of 'USER_TOKENS' table", DropPrimaryKeyOnIdColumnOfUserTokensTable.class) + .add(3444, "Add primary key on 'UUID' column of 'USER_TOKENS' table", AddPrimaryKeyOnUuidColumnOfUserTokensTable.class) + .add(3445, "Drop column 'ID' of 'USER_TOKENS' table", DropIdColumnOfUserTokensTable.class) + + // Migration on PROJECT_QPROFILES table + .add(3446, "Add 'uuid' column for 'PROJECT_QPROFILES'", AddUuidColumnToProjectQProfilesTable.class) + .add(3447, "Populate 'uuid' column for 'PROJECT_QPROFILES'", PopulateProjectQProfilesUuid.class) + .add(3448, "Make 'uuid' column not nullable for 'PROJECT_QPROFILES'", MakeProjectQProfilesUuidColumnNotNullable.class) + .add(3449, "Drop primary key on 'ID' column of 'PROJECT_QPROFILES' table", DropPrimaryKeyOnIdColumnOfProjectQProfilesTable.class) + .add(3450, "Add primary key on 'UUID' column of 'PROJECT_QPROFILES' table", AddPrimaryKeyOnUuidColumnOfProjectQProfilesTable.class) + .add(3451, "Drop column 'ID' of 'PROJECT_QPROFILES' table", DropIdColumnOfProjectQProfilesTable.class) + + // Migration of MANUAL_MEASURES table + .add(3452, "Add 'uuid' column for 'MANUAL_MEASURES'", AddUuidColumnToManualMeasures.class) + .add(3453, "Populate 'uuid' column for 'MANUAL_MEASURES'", PopulateManualMeasureUuid.class) + .add(3454, "Make 'uuid' column not nullable for 'MANUAL_MEASURES'", MakeManualMeasuresUuidColumnNotNullable.class) + .add(3455, "Drop primary key on 'ID' column of 'MANUAL_MEASURES' table", DropPrimaryKeyOnIdColumnOfManualMeasuresTable.class) + .add(3456, "Add primary key on 'UUID' column of 'MANUAL_MEASURES' table", AddPrimaryKeyOnUuidColumnOfManualMeasuresTable.class) + .add(3457, "Drop column 'ID' of 'MANUAL_MEASURES' table", DropIdColumnOfManualMeasuresTable.class) + + // Migration of GROUP_ROLES table + .add(3458, "Add 'UUID' column on 'GROUP_ROLES' table", AddUuidColumnToGroupRolesTable.class) + .add(3459, "Populate 'uuid' for 'GROUP_ROLES'", PopulateGroupRolesUuid.class) + .add(3460, "Make 'uuid' column not nullable for 'GROUP_ROLES'", MakeGroupRolesUuidColumnNotNullable.class) + .add(3461, "Drop primary key on 'ID' column of 'GROUP_ROLES' table", DropPrimaryKeyOnIdColumnOfGroupRolesTable.class) + .add(3462, "Add primary key on 'UUID' column of 'GROUP_ROLES' table", AddPrimaryKeyOnUuidColumnOfGroupRolesTable.class) + .add(3463, "Drop column 'ID' of 'GROUP_ROLES' table", DropIdColumnOfGroupRolesTable.class) + + // Migration of USER_ROLES table + .add(3464, "Add 'UUID' column on 'USER_ROLES' table", AddUuidColumnToUserRolesTable.class) + .add(3465, "Populate 'uuid' for 'USER_ROLES'", PopulateUserRolesUuid.class) + .add(3466, "Make 'uuid' column not nullable for 'USER_ROLES'", MakeUserRolesUuidColumnNotNullable.class) + .add(3467, "Drop primary key on 'ID' column of 'USER_ROLES' table", DropPrimaryKeyOnIdColumnOfUserRolesTable.class) + .add(3468, "Add primary key on 'UUID' column of 'USER_ROLES' table", AddPrimaryKeyOnUuidColumnOfUserRolesTable.class) + .add(3469, "Drop column 'ID' of 'USER_ROLES' table", DropIdColumnOfUserRolesTable.class) + + // Migration of FILE_SOURCES table + .add(3470, "Add 'UUID' column on 'FILE_SOURCES' table", AddUuidColumnToFileSourcesTable.class) + .add(3471, "Populate 'uuid' for 'FILE_SOURCES'", PopulateFileSourcesUuid.class) + .add(3472, "Make 'uuid' column not nullable for 'FILE_SOURCES'", MakeFileSourcesUuidColumnNotNullable.class) + .add(3473, "Drop primary key on 'ID' column of 'FILE_SOURCES' table", DropPrimaryKeyOnIdColumnOfFileSourcesTable.class) + .add(3474, "Add primary key on 'UUID' column of 'FILE_SOURCES' table", AddPrimaryKeyOnUuidColumnOfFileSourcesTable.class) + .add(3475, "Drop column 'ID' of 'FILE_SOURCES' table", DropIdColumnOfFileSourcesTable.class) + + // Migration of ISSUE_CHANGES table + .add(3476, "Add 'UUID' column on 'ISSUE_CHANGES' table", AddUuidColumnToIssueChangesTable.class) + .add(3477, "Populate 'uuid' for 'ISSUE_CHANGES'", PopulateIssueChangesUuid.class) + .add(3478, "Make 'uuid' column not nullable for 'ISSUE_CHANGES'", MakeIssueChangesUuidColumnNotNullable.class) + .add(3479, "Drop primary key on 'ID' column of 'ISSUE_CHANGES' table", DropPrimaryKeyOnIdColumnOfIssueChangesTable.class) + .add(3480, "Add primary key on 'UUID' column of 'ISSUE_CHANGES' table", AddPrimaryKeyOnUuidColumnOfIssueChangesTable.class) + .add(3481, "Drop column 'ID' of 'ISSUE_CHANGES' table", DropIdColumnOfIssueChangesTable.class) + + // Migration of QUALITY_GATE_CONDITIONS table + .add(3482, "Add 'UUID' column on 'QUALITY_GATE_CONDITIONS' table", AddUuidColumnToQualityGateConditionsTable.class) + .add(3483, "Populate 'uuid' for 'QUALITY_GATE_CONDITIONS'", PopulateQualityGateConditionsUuid.class) + .add(3484, "Make 'uuid' column not nullable for 'QUALITY_GATE_CONDITIONS'", MakeQualityGateConditionsUuidColumnNotNullable.class) + .add(3485, "Drop primary key on 'ID' column of 'QUALITY_GATE_CONDITIONS' table", DropPrimaryKeyOnIdColumnOfQualityGateConditionsTable.class) + .add(3486, "Add primary key on 'UUID' column of 'QUALITY_GATE_CONDITIONS' table", AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTable.class) + .add(3487, "Drop column 'ID' of 'QUALITY_GATE_CONDITIONS' table", DropIdColumnOfQualityGateConditionsTable.class) + + // Migration of PERM_TEMPLATES_GROUPS table + .add(3488, "Add 'UUID' column on 'PERM_TEMPLATES_GROUPS' table", AddUuidColumnToPermTemplatesGroupsTable.class) + .add(3489, "Populate 'uuid' for 'PERM_TEMPLATES_GROUPS'", PopulatePermTemplatesGroupsUuid.class) + .add(3490, "Make 'uuid' column not nullable for 'PERM_TEMPLATES_GROUPS'", MakePermTemplatesGroupsUuidColumnNotNullable.class) + .add(3491, "Drop primary key on 'ID' column of 'PERM_TEMPLATES_GROUPS' table", DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTable.class) + .add(3492, "Add primary key on 'UUID' column of 'PERM_TEMPLATES_GROUPS' table", AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTable.class) + .add(3493, "Drop column 'ID' of 'PERM_TEMPLATES_GROUPS' table", DropIdColumnOfPermTemplatesGroupsTable.class) + + // Migration of PERM_TPL_CHARACTERISTICS table + .add(3494, "Add 'UUID' column on 'PERM_TPL_CHARACTERISTICS' table", AddUuidColumnToPermTplCharacteristicsTable.class) + .add(3495, "Populate 'uuid' for 'PERM_TPL_CHARACTERISTICS'", PopulatePermTplCharacteristicsUuid.class) + .add(3496, "Make 'uuid' column not nullable for 'PERM_TPL_CHARACTERISTICS'", MakePermTplCharacteristicsUuidColumnNotNullable.class) + .add(3497, "Drop primary key on 'ID' column of 'PERM_TPL_CHARACTERISTICS' table", DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTable.class) + .add(3498, "Add primary key on 'UUID' column of 'PERM_TPL_CHARACTERISTICS' table", AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTable.class) + .add(3499, "Drop column 'ID' of 'PERM_TPL_CHARACTERISTICS' table", DropIdColumnOfPermTplCharacteristicsTable.class) + + // Migration of PERM_TEMPLATES_USERS table + .add(3500, "Add 'UUID' column on 'PERM_TEMPLATES_USERS' table", AddUuidColumnToPermTemplatesUsersTable.class) + .add(3501, "Populate 'uuid' for 'PERM_TEMPLATES_USERS'", PopulatePermTemplatesUsersUuid.class) + .add(3502, "Make 'uuid' column not nullable for 'PERM_TEMPLATES_USERS'", MakePermTemplatesUsersUuidColumnNotNullable.class) + .add(3503, "Drop primary key on 'ID' column of 'PERM_TEMPLATES_USERS' table", DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTable.class) + .add(3504, "Add primary key on 'UUID' column of 'PERM_TEMPLATES_USERS' table", AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTable.class) + .add(3505, "Drop column 'ID' of 'PERM_TEMPLATES_USERS' table", DropIdColumnOfPermTemplatesUsersTable.class) + + // Migration of ACTIVE_RULES table + .add(3506, "Add 'UUID' column on 'ACTIVE_RULES' table", AddUuidColumnToActiveRulesTable.class) + .add(3507, "Populate 'uuid' for 'ACTIVE_RULES'", PopulateActiveRulesUuid.class) + .add(3508, "Make 'uuid' column not nullable for 'ACTIVE_RULES'", MakeActiveRulesUuidColumnNotNullable.class) + + // Migration of FK in ACTIVE_RULE_PARAMETERS to ACTIVE_RULES + .add(3509, "Add 'active_rule_uuid' column on 'ACTIVE_RULE_PARAMETERS' table", AddActiveRuleUuidColumnToActiveRuleParameters.class) + .add(3510, "Populate 'active_rule_uuid' for 'ACTIVE_RULE_PARAMETERS'", PopulateActiveRuleParametersActiveRuleUuid.class) + .add(3511, "Make 'active_rule_uuid' column not nullable for 'ACTIVE_RULE_PARAMETERS'", MakeActiveRuleParametersActiveRuleUuidNotNullable.class) + .add(3512, "Drop index on 'active_rule_id' column of 'ACTIVE_RULE_PARAMETERS' table", DropIndexOnActiveRuleIdOfActiveRuleParametersTable.class) + .add(3513, "Add index on 'active_rule_uuid' column of 'ACTIVE_RULE_PARAMETERS' table", AddIndexOnActiveRuleUuidOfActiveRuleParametersTable.class) + + // Finish migration of ACTIVE_RULES + .add(3514, "Drop primary key on 'ID' column of 'ACTIVE_RULES' table", DropPrimaryKeyOnIdColumnOfActiveRulesTable.class) + .add(3515, "Add primary key on 'UUID' column of 'ACTIVE_RULES' table", AddPrimaryKeyOnUuidColumnOfActiveRulesTable.class) + .add(3516, "Drop column 'ID' of 'ACTIVE_RULES' table", DropIdColumnOfActiveRulesTable.class) + .add(3517, "Drop column 'active_rule_id' of 'ACTIVE_RULE_PARAMETERS' table", DropActiveRuleIdColumnOfActiveRuleParametersTable.class) + + // Migration on RULES_PARAMETERS table - populate uuid column + .add(3518, "Add 'uuid' column for 'RULES_PARAMETERS'", AddUuidColumnToRulesParameters.class) + .add(3519, "Populate 'uuid' column for 'RULES_PARAMETERS'", PopulateRulesParametersUuid.class) + .add(3520, "Make 'uuid' column not nullable for 'RULES_PARAMETERS'", MakeRulesParametersUuidColumnNotNullable.class) + + // Migration of ACTIVE_RULE_PARAMS FK to RULES_PARAMETERS, switch from ruleParamId to ruleParamUuid + .add(3521, "Add 'rules_parameter_uuid' column for 'ACTIVE_RULE_PARAMS' table", AddRulesParameterUuidColumnToActiveRuleParameters.class) + .add(3522, "Populate 'rules_parameter_uuid' column for 'ACTIVE_RULE_PARAMS' table", PopulateActiveRuleParametersRulesParameterUuid.class) + .add(3523, "Make 'rules_parameter_uuid' column not nullable for 'ACTIVE_RULE_PARAMS' table", MakeActiveRuleParametersRulesParameterUuidColumnNotNullable.class) + .add(3524, "Drop column 'rules_parameter_id' of 'ACTIVE_RULE_PARAMS' table", DropRulesParameterIdColumnOfActiveRuleParametersTable.class) + + // Migration on RULES_PARAMETERS table change PK + .add(3525, "Drop primary key on 'ID' column of 'RULES_PARAMETERS' table", DropPrimaryKeyOnIdColumnOfRulesParametersTable.class) + .add(3526, "Add primary key on 'UUID' column of 'RULES_PARAMETERS' table", AddPrimaryKeyOnUuidColumnOfRulesParametersTable.class) + .add(3527, "Drop column 'ID' of 'RULES_PARAMETERS' table", DropIdColumnOfRulesParametersTable.class) + + // Migration of METRICS table + .add(3528, "Add 'UUID' column on 'METRICS' table", AddUuidColumnToMetricsTable.class) + .add(3529, "Populate 'uuid' for 'METRICS'", PopulateMetricsUuid.class) + .add(3530, "Make 'uuid' column not nullable for 'METRICS'", MakeMetricsUuidColumnNotNullable.class) + + // Migration of FK in PROJECT_MEASURES to METRICS + .add(3531, "Add 'metric_uuid' column on 'PROJECT_MEASURES' table", AddMetricUuidColumnToProjectMeasures.class) + .add(3532, "Populate 'metric_uuid' for 'PROJECT_MEASURES'", PopulateProjectMeasuresMetricUuid.class) + .add(3533, "Make 'metric_uuid' column not nullable for 'PROJECT_MEASURES'", MakeProjectMeasuresMetricUuidNotNullable.class) + .add(3534, "Drop index on 'metric_id' and 'analysis_uuid' columns of 'PROJECT_MEASURES' table", DropIndexOnMetricIdOfProjectMeasuresTable.class) + .add(3535, "Add index on 'metric_uuid' and 'analysis_uuid' columns of 'PROJECT_MEASURES' table", AddIndexOnMetricUuidOfProjectMeasuresTable.class) + + // Migration of FK in QUALITY_GATE_CONDITIONS to METRICS + .add(3536, "Add 'metric_uuid' column on 'QUALITY_GATE_CONDITIONS' table", AddMetricUuidColumnToQualityGateConditions.class) + .add(3537, "Populate 'metric_uuid' for 'QUALITY_GATE_CONDITIONS'", PopulateQualityGateConditionsMetricUuid.class) + .add(3538, "Make 'metric_uuid' column not nullable for 'QUALITY_GATE_CONDITIONS'", MakeQualityGateConditionsMetricUuidNotNullable.class) + + // Migration of FK in LIVE_MEASURES to METRICS + .add(3539, "Add 'metric_uuid' column on 'LIVE_MEASURES' table", AddMetricUuidColumnToLiveMeasures.class) + .add(3540, "Populate 'metric_uuid' for 'LIVE_MEASURES'", PopulateLiveMeasuresMetricUuid.class) + .add(3541, "Make 'metric_uuid' column not nullable for 'LIVE_MEASURES'", MakeLiveMeasuresMetricUuidNotNullable.class) + .add(3542, "Drop index on 'metric_id' column of 'LIVE_MEASURES' table", DropIndexOnMetricIdOfLiveMeasuresTable.class) + .add(3543, "Add index on 'metric_uuid' column of 'LIVE_MEASURES' table", AddIndexOnMetricUuidOfLiveMeasuresTable.class) + + // Migration of FK in MANUAL_MEASURES to METRICS + .add(3544, "Add 'metric_uuid' column on 'MANUAL_MEASURES' table", AddMetricUuidColumnToManualMeasures.class) + .add(3545, "Populate 'metric_uuid' for 'MANUAL_MEASURES'", PopulateManualMeasuresMetricUuid.class) + .add(3546, "Make 'metric_uuid' column not nullable for 'MANUAL_MEASURES'", MakeManualMeasuresMetricUuidNotNullable.class) + + // Finish migration of METRICS + .add(3547, "Drop primary key on 'ID' column of 'METRICS' table", DropPrimaryKeyOnIdColumnOfMetricsTable.class) + .add(3548, "Add primary key on 'UUID' column of 'METRICS' table", AddPrimaryKeyOnUuidColumnOfMetricsTable.class) + .add(3549, "Drop column 'METRIC_ID' of 'PROJECT_MEASURES' table", DropMetricIdColumnOfProjectMeasuresTable.class) + .add(3550, "Drop column 'METRIC_ID' of 'QUALITY_GATE_CONDITIONS' table", DropMetricIdColumnOfQualityGateConditionsTable.class) + .add(3551, "Drop column 'METRIC_ID' of 'LIVE_MEASURES' table", DropMetricIdColumnOfLiveMeasuresTable.class) + .add(3552, "Drop column 'METRIC_ID' of 'MANUAL_MEASURES' table", DropMetricIdColumnOfManualMeasuresTable.class) + .add(3553, "Drop column 'ID' of 'METRICS' table", DropIdColumnOfMetricsTable.class) + + // Migration of PERMISSION_TEMPLATES table + .add(3554, "Add 'UUID' column on 'PERMISSION_TEMPLATES' table", AddUuidColumnToPermissionTemplates.class) + .add(3555, "Populate 'uuid' for 'PERMISSION_TEMPLATES'", PopulatePermissionTemplatesUuid.class) + .add(3556, "Make 'uuid' column not nullable for user_tokens", MakePermissionTemplateUuidColumnNotNullable.class) + + // Migration of PERM_TEMPLATES_GROUPS FK to PERMISSION_TEMPLATES, switch from templateId to templateUuid + .add(3557, "Add 'template_uuid' column for 'PERM_TEMPLATES_GROUPS' table", AddTemplateUuidColumnToPermTemplatesGroups.class) + .add(3558, "Populate 'template_uuid' column for 'PERM_TEMPLATES_GROUPS' table", PopulatePermTemplatesGroupsTemplateUuidColumn.class) + .add(3559, "Make 'template_uuid' column not nullable for 'PERM_TEMPLATES_GROUPS' table", MakePermTemplatesGroupsTemplateUuidColumnNotNullable.class) + .add(3560, "Drop column 'template_id' of 'PERM_TEMPLATES_GROUPS' table", DropTemplateIdColumnOfPermTemplatesGroupsTable.class) + + // Migration of PERM_TEMPLATES_USERS FK to PERMISSION_TEMPLATES, switch from templateId to templateUuid + .add(3561, "Add 'template_uuid' column for 'PERM_TEMPLATES_USERS' table", AddTemplateUuidColumnToPermTemplatesUsers.class) + .add(3562, "Populate 'template_uuid' column for 'PERM_TEMPLATES_USERS' table", PopulatePermTemplatesUsersTemplateUuidColumn.class) + .add(3563, "Make 'template_uuid' column not nullable for 'PERM_TEMPLATES_USERS' table", MakePermTemplatesUsersTemplateUuidColumnNotNullable.class) + .add(3564, "Drop column 'template_id' of 'PERM_TEMPLATES_USERS' table", DropTemplateIdColumnOfPermTemplatesUsersTable.class) + + // Migration of PERM_TPL_CHARACTERISTICS FK to PERMISSION_TEMPLATES, switch from templateId to templateUuid + .add(3565, "Add 'template_uuid' column for 'PERM_TPL_CHARACTERISTICS' table", AddTemplateUuidColumnToPermTplCharacteristics.class) + .add(3566, "Populate 'template_uuid' column for 'PERM_TPL_CHARACTERISTICS' table", PopulatePermTplCharacteristicsTemplateUuidColumn.class) + .add(3567, "Make 'template_uuid' column not nullable for 'PERM_TPL_CHARACTERISTICS' table", MakePermTplCharacteristicsTemplateUuidColumnNotNullable.class) + .add(3568, "Drop unique constraint on 'template_id', 'permission_key' columns 'PERM_TPL_CHARACTERISTICS' table", + DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTable.class) + .add(3569, "Add unique constraint on 'template_uuid', 'permission_key' columns 'PERM_TPL_CHARACTERISTICS' table", + AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTable.class) + + .add(3570, "Drop column 'template_id' of 'PERM_TPL_CHARACTERISTICS' table", DropTemplateIdColumnOfPermTplCharacteristicsTable.class) + + .add(3571, "Drop primary key on 'ID' column of 'PERMISSION_TEMPLATES' table", DropPrimaryKeyOnIdColumnOfPermissionTemplatesTable.class) + .add(3572, "Add primary key on 'UUID' column of 'PERMISSION_TEMPLATES' table", AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTable.class) + + .add(3573, "Drop column 'ID' of 'PERMISSION_TEMPLATES' table", DropIdColumnOfPermissionTemplatesTable.class) + .add(3574, "Drop column 'KEE' of 'PERMISSION_TEMPLATES' table", DropKeeColumnOfPermissionTemplatesTable.class) + + // Migration on RULES_PROFILES table + .add(3575, "Add 'uuid' column for 'RULES_PROFILES'", AddUuidColumnToRulesProfilesTable.class) + .add(3576, "Populate 'uuid' column for 'RULES_PROFILES'", PopulateRulesProfilesUuid.class) + .add(3577, "Make 'uuid' column not nullable for 'RULES_PROFILES'", MakeRulesProfilesUuidColumnNotNullable.class) + + // Migration of ORG_QPROFILES FK to RULES_PROFILES + .add(3578, "Populate 'rules_profile_uuid' column for 'ORG_QPROFILES' table", PopulateOrgQProfilesRulesProfileUuid.class) + + // Migration of QPROFILE_CHANGES FK to RULES_PROFILES + .add(3579, "Populate 'rules_profile_uuid' column for 'QPROFILE_CHANGES' table", PopulateQProfileChangesRulesProfileUuid.class) + + // Migration of ACTIVE_RULES FK to RULES_PROFILES, switch from profile_id to profile_uuid + .add(3580, "Add 'profile_uuid' column for 'ACTIVE_RULES' table", AddProfileUuidColumnToActiveRulesTable.class) + .add(3581, "Populate 'profile_uuid' column for 'ACTIVE_RULES' table", PopulateActiveRulesProfileUuid.class) + .add(3582, "Make 'profile_uuid' column not nullable for 'ACTIVE_RULES' table", MakeActiveRulesProfileUuidColumnNotNullable.class) + + .add(3583, "Drop unique constraint on 'profile_id', 'rule_id' columns 'ACTIVE_RULES' table", DropUniqueIndexOnProfileIdColumnOfActiveRulesTable.class) + .add(3584, "Add unique constraint on 'profile_uuid', 'rule_id' columns 'ACTIVE_RULES' table", AddUniqueIndexOnProfileUuidColumnOfActiveRulesTable.class) + + .add(3585, "Drop column 'profile_id' of 'ACTIVE_RULES' table", DropProfileIdColumnOfActiveRulesTable.class) + + .add(3586, "Drop unique constraint on 'kee' columns 'RULES_PROFILES' table", DropUniqueIndexOnKeeColumnOfRulesProfilesTable.class) + .add(3587, "Drop column 'kee' of 'RULES_PROFILES' table", DropKeeColumnOfRulesProfilesTable.class) + + .add(3588, "Drop primary key on 'ID' column of 'RULES_PROFILES' table", DropPrimaryKeyOnIdColumnOfRulesProfilesTable.class) + .add(3589, "Add primary key on 'UUID' column of 'RULES_PROFILES' table", AddPrimaryKeyOnUuidColumnOfRulesProfilesTable.class) + .add(3590, "Drop column 'ID' of 'RULES_PROFILES' table", DropIdColumnOfRulesProfilesTable.class) + + // Migration of PROPERTIES table + .add(3591, "Add 'uuid' column for 'PROPERTIES'", AddUuidColumnToProperties.class) + .add(3592, "Populate 'uuid' for 'PROPERTIES'", PopulatePropertiesUuid.class) + .add(3593, "Make 'uuid' column not nullable for 'PROPERTIES'", MakePropertiesUuidColumnNotNullable.class) + .add(3594, "Drop primary key on 'ID' column of 'PROPERTIES' table", DropPrimaryKeyOnIdColumnOfPropertiesTable.class) + .add(3595, "Add primary key on 'UUID' column of 'PROPERTIES' table", AddPrimaryKeyOnUuidColumnOfPropertiesTable.class) + .add(3596, "Drop column 'ID' of 'PROPERTIES' table", DropIdColumnOfPropertiesTable.class) + + // Migration of GROUPS table + .add(3597, "Add 'UUID' column on 'GROUPS' table", AddUuidColumnToGroupsTable.class) + .add(3598, "Populate 'uuid' for 'GROUPS'", PopulateGroupsUuid.class) + .add(3599, "Make 'uuid' column not nullable for 'GROUPS'", MakeGroupsUuidColumnNotNullable.class) + + // Migration of FK in GROUP_ROLES to GROUPS + .add(3600, "Add 'group_uuid' column on 'GROUP_ROLES' table", AddGroupUuidColumnToGroupRoles.class) + .add(3601, "Populate 'group_uuid' for 'GROUP_ROLES'", PopulateGroupRolesGroupUuid.class) + .add(3602, "Drop index on 'group_id' column of 'GROUP_ROLES' table", DropIndexOnGroupIdOfGroupRolesTable.class) + .add(3603, "Add index on 'group_uuid' column of 'GROUP_ROLES' table", AddIndexOnGroupUuidOfGroupRolesTable.class) + + // Migration of FK in GROUPS_USERS to GROUPS + .add(3604, "Add 'group_uuid' column on 'GROUPS_USERS' table", AddGroupUuidColumnToGroupsUsers.class) + .add(3605, "Populate 'group_uuid' for 'GROUPS_USERS'", PopulateGroupsUsersGroupUuid.class) + .add(3606, "Make 'group_uuid' column not nullable for 'GROUPS_USERS'", MakeGroupsUsersGroupUuidNotNullable.class) + .add(3607, "Drop index on 'group_id' column of 'GROUPS_USERS' table", DropIndexOnGroupIdOfGroupsUsersTable.class) + .add(3608, "Add index on 'group_uuid' column of 'GROUPS_USERS' table", AddIndexOnGroupUuidOfGroupsUsersTable.class) + + // Migration of FK in ORGANIZATIONS to GROUPS + .add(3609, "Add 'default_group_uuid' column on 'ORGANIZATIONS' table", AddDefaultGroupUuidColumnToOrganizations.class) + .add(3610, "Populate 'default_group_uuid' for 'ORGANIZATIONS'", PopulateOrganizationsDefaultGroupUuid.class) + + // Migration of FK in PERM_TEMPLATES_GROUPS to GROUPS + .add(3611, "Add 'group_uuid' column on 'PERM_TEMPLATES_GROUPS' table", AddGroupUuidColumnToPermTemplatesGroups.class) + .add(3612, "Populate 'group_uuid' for 'PERM_TEMPLATES_GROUPS'", PopulatePermTemplatesGroupsGroupUuid.class) + + // Migration of FK in QPROFILE_EDIT_GROUPS to GROUPS + .add(3613, "Add 'group_uuid' column on 'QPROFILE_EDIT_GROUPS' table", AddGroupUuidColumnToQProfileEditGroups.class) + .add(3614, "Populate 'group_uuid' for 'QPROFILE_EDIT_GROUPS'", PopulateQProfileEditGroupsGroupUuid.class) + .add(3615, "Make 'group_uuid' column not nullable for 'QPROFILE_EDIT_GROUPS'", MakeQProfileEditGroupsGroupUuidNotNullable.class) + .add(3616, "Drop index on 'group_id' column of 'QPROFILE_EDIT_GROUPS' table", DropIndexOnGroupIdOfQProfileEditGroupsTable.class) + .add(3617, "Add index on 'group_uuid' column of 'QPROFILE_EDIT_GROUPS' table", AddIndexOnGroupUuidOfQProfileEditGroupsTable.class) + + // Finish migration of Groups + .add(3618, "Drop primary key on 'ID' column of 'GROUPS' table", DropPrimaryKeyOnIdColumnOfGroupsTable.class) + .add(3619, "Add primary key on 'UUID' column of 'GROUPS' table", AddPrimaryKeyOnUuidColumnOfGroupsTable.class) + + .add(3620, "Drop column 'group_id' of 'GROUP_ROLES' table", DropGroupIdColumnOfGroupRolesTable.class) + .add(3621, "Drop column 'group_id' of 'GROUPS_USERS' table", DropGroupIdColumnOfGroupsUsersTable.class) + .add(3622, "Drop column 'group_id' of 'ORGANIZATIONS' table", DropDefaultGroupIdColumnOfOrganizationsTable.class) + .add(3623, "Drop column 'group_id' of 'PERM_TEMPLATES_GROUPS' table", DropGroupIdColumnOfPermTemplatesGroupsTable.class) + .add(3624, "Drop column 'group_id' of 'QPROFILE_EDIT_GROUPS' table", DropGroupIdColumnOfQProfileEditGroupsTable.class) + .add(3625, "Drop column 'ID' of 'GROUPS' table", DropIdColumnOfGroupsTable.class) + + // Migration of QUALITY_GATES_CONDITIONS FK to QUALITY_GATES, switch from qgate_id to qgate_uuid + .add(3626, "Add 'qgate_uuid' column for quality gates conditions", AddQGateUuidColumnForQGateConditions.class) + .add(3627, "Populate 'qgate_uuid' column for quality gates conditions", PopulateQGateUuidColumnForQGateConditions.class) + .add(3628, "drop orphans quality gates conditions", DropOrphansQGateConditions.class) + .add(3629, "Make 'qgate_uuid' column not nullable for quality gates conditions", MakeQGateUuidColumnNotNullableForQGateConditions.class) + .add(3630, "Drop 'qgate_id' column for quality gates conditions", DropQGateIdColumnForQGateConditions.class) + + // Migrations of QUALITY_GATES table + .add(3631, "Drop primary key on 'ID' column of 'QUALITY_GATES' table", DropPrimaryKeyOnIdColumnOfQGatesTable.class) + .add(3632, "drop unique index on 'UUID' column of 'QUALITY_GATES' table", DropUniqueIndexOnUuidColumnOfQualityGatesTable.class) + .add(3633, "Add primary key on 'UUID' column of 'QUALITY_GATES' table", AddPrimaryKeyOnUuidColumnOfQGatesTable.class) + .add(3634, "Drop column 'ID' of 'QUALITY_GATES' table", DropIdColumnOfQGateTable.class) + + // Migration of FK in GROUPS_USERS to USERS + .add(3635, "Add 'user_uuid' column on 'GROUPS_USERS' table", AddUserUuidColumnToGroupsUsers.class) + .add(3636, "Populate 'user_uuid' for 'GROUPS_USERS'", PopulateGroupsUsersUserUuid.class) + .add(3637, "Make 'user_uuid' column not nullable for 'GROUPS_USERS'", MakeGroupsUsersUserUuidColumnNotNullable.class) + .add(3638, "Drop index on 'user_id' column of 'GROUPS_USERS' table", DropIndexOnUserIdOfGroupsUsersTable.class) + .add(3639, "Add index on 'user_uuid' column of 'GROUPS_USERS' table", AddIndexOnUserUuidOfGroupsUsersTable.class) + .add(3640, "Drop index on 'user_id', 'group_id' columns of 'GROUPS_USERS' table", DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTable.class) + .add(3641, "Add unique index on 'user_uuid', 'group_id' columns of 'GROUPS_USERS' table", AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTable.class) + .add(3642, "Drop column on 'user_id' column of 'GROUPS_USERS' table", DropUserIdColumnOfGroupsUsersTable.class) + + // Migration of FK in ORGANIZATION_MEMBERS to USERS + .add(3643, "Add 'user_uuid' column on 'ORGANIZATION_MEMBERS' table", AddUserUuidColumnToOrganizationMembers.class) + .add(3644, "Populate 'user_uuid' for 'ORGANIZATION_MEMBERS'", PopulateOrganizationMembersUserUuid.class) + .add(3645, "Make 'user_uuid' not-null for 'ORGANIZATION_MEMBERS'", MakeOrganizationMembersUserUuidColumnNotNullable.class) + .add(3646, "Drop index on 'user_id' column of 'ORGANIZATION_MEMBERS' table", DropIndexOnUserIdOfOrganizationMembersTable.class) + .add(3647, "Add index on 'user_uuid' column of 'ORGANIZATION_MEMBERS' table", AddIndexOnUserUuidOfOrganizationMembersTable.class) + .add(3648, "Drop index on 'user_id', 'group_id' columns of 'ORGANIZATION_MEMBERS' table", DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTable.class) + .add(3649, "Add PK on 'user_uuid', 'organization_uuid' columns of 'ORGANIZATION_MEMBERS' table", AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTable.class) + .add(3650, "Drop column on 'user_id' column of 'ORGANIZATION_MEMBERS' table", DropUserIdColumnOfOrganizationMembersTable.class) + + // Migration of FK in PERM_TEMPLATES_USERS to USERS + .add(3651, "Add 'user_uuid' column on 'PERM_TEMPLATES_USERS' table", AddUserUuidColumnToPermTemplatesUsers.class) + .add(3652, "Populate 'user_uuid' for 'PERM_TEMPLATES_USERS'", PopulatePermTemplatesUsersUserUuid.class) + .add(3653, "Make 'user_uuid' not-null for 'PERM_TEMPLATES_USERS'", MakePermTemplatesUsersUserUuidColumnNotNullable.class) + .add(3654, "Drop column on 'user_id' column of 'PERM_TEMPLATES_USERS' table", DropUserIdColumnOfPermTemplatesUsersTable.class) + + // Migration of FK in PROPERTIES to USERS + .add(3655, "Add 'user_uuid' column on 'PROPERTIES' table", AddUserUuidColumnToPropertiesUsers.class) + .add(3656, "Populate 'user_uuid' for 'PROPERTIES'", PopulatePropertiesUserUuid.class) + .add(3657, "Drop column on 'user_id' column of 'PROPERTIES' table", DropUserIdColumnOfPropertiesTable.class) + + // Migration of FK in QPROFILE_EDIT_USERS to USERS + .add(3658, "Add 'user_uuid' column on 'QPROFILE_EDIT_USERS' table", AddUserUuidColumnToQProfileEditUsers.class) + .add(3659, "Populate 'user_uuid' for 'QPROFILE_EDIT_USERS'", PopulateQProfileEditUsersUserUuid.class) + .add(3660, "Make 'user_uuid' not-null for 'QPROFILE_EDIT_USERS'", MakeQProfileEditUsersUserUuidColumnNotNullable.class) + .add(3661, "Drop unique index on 'user_id','qprofile_uuid' columns of 'QPROFILE_EDIT_USERS' table", DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTable.class) + .add(3662, "Add unique index on 'user_uuid','qprofile_uuid' columns of 'QPROFILE_EDIT_USERS' table", AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTable.class) + .add(3663, "Drop column on 'user_id' column of 'QPROFILE_EDIT_USERS' table", DropUserIdColumnOfQProfileEditUsersTable.class) + + .add(3664, "Add 'user_uuid' column on 'USER_ROLES' table", AddUserUuidColumnToUserRoles.class) + .add(3665, "Populate 'user_uuid' for 'USER_ROLES'", PopulateUserRolesUserUuid.class) + .add(3666, "Drop unique index on 'user_id' column of 'USER_ROLES' table", DropIndexOnUserIdOfUserRolesTable.class) + .add(3667, "Add unique index on 'user_uuid' columns of 'USER_ROLES' table", AddIndexOnUserUuidOfUserRolesTable.class) + .add(3668, "Drop column on 'user_id' column of 'USER_ROLES' table", DropUserIdColumnOfUserRolesTable.class) + + .add(3669, "Drop unique index on 'user_id' column of 'USERS' table", DropUniqueIndexOnUuidColumnOfUsersTable.class) + .add(3670, "Drop PK index on 'id' column of 'USERS' table", DropPrimaryKeyOnIdColumnOfUsersTable.class) + .add(3671, "Add PK index on 'uuid' column of 'USERS' table", AddPrimaryKeyOnUuidColumnOfUsersTable.class) + .add(3672, "Drop 'id' column of 'USERS' table", DropIdColumnOfUsersTable.class) + + // Migration of RULES table + .add(3673, "Add 'uuid' column for 'RULES'", AddUuidAndTemplateUuidColumnsToRules.class) + .add(3674, "Populate 'uuid' column for 'RULES'", PopulateRulesUuid.class) + .add(3675, "Make 'uuid' column not nullable for 'RULES'", MakeRulesUuidColumnNotNullable.class) + .add(3676, "Populate 'templateUuid' column for 'RULES'", PopulateRulesTemplateUuid.class) + .add(3677, "Drop column 'templateId' column for 'RULES'", DropTemplateIdColumnOfRulesTable.class) + // Migration of RULES_METADATA FK to RULES, switch from rule_id to rule_uuid + .add(3678, "Add 'RULE_UUID' column for 'RULES_METADATA' table", AddRuleUuidColumnToRulesMetadataTable.class) + .add(3679, "Populate 'RULE_UUID' column for 'RULES_METADATA' table", PopulateRulesMetadataRuleUuidColumn.class) + .add(3680, "Make 'RULE_UUID' column not nullable for 'RULES_METADATA' table", MakeRulesMetadataRuleUuidColumnNotNullable.class) + .add(3681, "Drop primary key on 'RULE_ID' column of 'RULES_METADATA' table", DropPrimaryKeyOnIdColumnOfRulesMetadataTable.class) + .add(3682, "Add primary key on 'RULE_UUID' column of 'RULES_METADATA' table", AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTable.class) + .add(3683, "Drop column 'RULE_ID' of 'RULES_METADATA' table", DropRuleIdColumnOfRulesMetadataTable.class) + // Migration of RULES_PARAMETERS FK to RULES, switch from rule_id to rule_uuid + .add(3684, "Add 'RULE_UUID' column for 'RULES_PARAMETERS' table", AddRuleUuidColumnToRulesParametersTable.class) + .add(3685, "Populate 'RULE_UUID' column for 'RULES_PARAMETERS' table", PopulateRulesParametersRuleUuidColumn.class) + .add(3686, "Make 'RULE_UUID' column not nullable for 'RULES_PARAMETERS' table", MakeRulesParametersRuleUuidColumnNotNullable.class) + .add(3687, "Drop indexes on 'RULE_ID' of 'RULES_PARAMETERS' table", DropIndexesOnRuleIdColumnOfRulesParametersTable.class) + .add(3688, "Add indexes to 'RULES_PARAMETERS' table", AddIndexesToRulesParametersTable.class) + .add(3689, "Drop column 'RULE_ID' of 'RULES_PARAMETERS' table", DropRuleIdColumnOfRulesParametersTable.class) + // Migration of ACTIVE_RULES FK to RULES, switch from rule_id to rule_uuid + .add(3690, "Add 'RULE_UUID' column for 'ACTIVE_RULES' table", AddRuleUuidColumnToActiveRulesTable.class) + .add(3691, "Populate 'RULE_UUID' column for 'ACTIVE_RULES' table", PopulateActiveRulesRuleUuidColumn.class) + .add(3692, "Make 'RULE_UUID' column not nullable for 'ACTIVE_RULES' table", MakeActiveRulesRuleUuidColumnNotNullable.class) + .add(3693, "Drop indexes on 'RULE_ID' of 'ACTIVE_RULES' table", DropIndexOnRuleIdColumnOfActiveRulesTable.class) + .add(3694, "Add indexes to 'ACTIVE_RULES' table", AddIndexToActiveRulesTable.class) + .add(3695, "Drop column 'RULE_ID' of 'ACTIVE_RULES' table", DropRuleIdColumnOfActiveRulesTable.class) + // Migration of DEPRECATED_RULE_KEYS FK to RULES, switch from rule_id to rule_uuid + .add(3696, "Add 'RULE_UUID' column for 'DEPRECATED_RULE_KEYS' table", AddRuleUuidColumnToDeprecatedRuleKeysTable.class) + .add(3697, "Populate 'RULE_UUID' column for 'DEPRECATED_RULE_KEYS' table", PopulateDeprecatedRuleKeysRuleUuidColumn.class) + .add(3698, "Make 'RULE_UUID' column not nullable for 'DEPRECATED_RULE_KEYS' table", MakeDeprecatedRuleKeysRuleUuidColumnNotNullable.class) + .add(3699, "Drop index on 'RULE_ID' of 'DEPRECATED_RULE_KEYS' table", DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTable.class) + .add(3700, "Add index to 'DEPRECATED_RULE_KEYS' table", AddIndexToDeprecatedRuleKeysTable.class) + .add(3701, "Drop column 'RULE_ID' of 'DEPRECATED_RULE_KEYS' table", DropRuleIdColumnOfDeprecatedRuleKeysTable.class) + // Migration of ISSUE FK to RULES, switch from rule_id to rule_uuid + .add(3702, "Add 'RULE_UUID' column for 'ISSUES' table", AddRuleUuidColumnToIssuesTable.class) + .add(3703, "Populate 'RULE_UUID' column for 'ISSUES' table", PopulateIssuesRuleUuidColumn.class) + .add(3704, "Drop index on 'RULE_ID' of 'ISSUES' table", DropIndexOnRuleIdColumnOfIssuesTable.class) + .add(3705, "Add index to 'ISSUES' table", AddIndexToIssuesTable.class) + .add(3706, "Drop column 'RULE_ID' of 'ISSUES' table", DropRuleIdColumnOfIssuesTable.class) + // continue with RULES table cleanup + .add(3707, "Drop primary key on 'ID' column of 'RULES' table", DropPrimaryKeyOnIdColumnOfRulesTable.class) + .add(3708, "Add primary key on 'UUID' column of 'RULES' table", AddPrimaryKeyOnUuidColumnOfRulesTable.class) + .add(3709, "Drop column 'ID' of 'RULES' table", DropIdColumnOfRulesTable.class) + + ; + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTable.java new file mode 100644 index 00000000000..eecba7ac96c --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTable.java @@ -0,0 +1,38 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.activeruleparameters; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; + +public class AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTable extends DdlChange { + + public AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddPrimaryKeyBuilder("active_rule_parameters", "uuid").build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddUuidColumnToActiveRuleParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddUuidColumnToActiveRuleParametersTable.java new file mode 100644 index 00000000000..f2a349426ca --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddUuidColumnToActiveRuleParametersTable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.activeruleparameters; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.AddUuidColumnToTable; + +public class AddUuidColumnToActiveRuleParametersTable extends AddUuidColumnToTable { + private static final String TABLE = "active_rule_parameters"; + + public AddUuidColumnToActiveRuleParametersTable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropIdColumnOfActiveRuleParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropIdColumnOfActiveRuleParametersTable.java new file mode 100644 index 00000000000..0d9c8b3e765 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropIdColumnOfActiveRuleParametersTable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.activeruleparameters; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; + +public class DropIdColumnOfActiveRuleParametersTable extends DropIdColumn { + private static final String TABLE = "active_rule_parameters"; + + public DropIdColumnOfActiveRuleParametersTable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropPrimaryKeyOnIdColumnOfActiveRuleParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropPrimaryKeyOnIdColumnOfActiveRuleParametersTable.java new file mode 100644 index 00000000000..8d03f0e69d9 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropPrimaryKeyOnIdColumnOfActiveRuleParametersTable.java @@ -0,0 +1,32 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.activeruleparameters; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; + +public class DropPrimaryKeyOnIdColumnOfActiveRuleParametersTable extends DropPrimaryKeyOnIdColumn { + private static final String TABLE_NAME = "active_rule_parameters"; + + public DropPrimaryKeyOnIdColumnOfActiveRuleParametersTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { + super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/MakeActiveRuleParametersUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/MakeActiveRuleParametersUuidColumnNotNullable.java new file mode 100644 index 00000000000..96806e3bf12 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/MakeActiveRuleParametersUuidColumnNotNullable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.activeruleparameters; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.MakeUuidColumnNotNullable; + +public class MakeActiveRuleParametersUuidColumnNotNullable extends MakeUuidColumnNotNullable { + private static final String TABLE = "active_rule_parameters"; + + public MakeActiveRuleParametersUuidColumnNotNullable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/PopulateActiveRuleParametersUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/PopulateActiveRuleParametersUuid.java new file mode 100644 index 00000000000..4fff992cff8 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/PopulateActiveRuleParametersUuid.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.activeruleparameters; + +import java.sql.SQLException; +import org.sonar.core.util.UuidFactory; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulateActiveRuleParametersUuid extends DataChange { + + private final UuidFactory uuidFactory; + + public PopulateActiveRuleParametersUuid(Database db, UuidFactory uuidFactory) { + super(db); + this.uuidFactory = uuidFactory; + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select id from active_rule_parameters where uuid is null"); + massUpdate.update("update active_rule_parameters set uuid = ? where id = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, uuidFactory.create()); + update.setLong(2, row.getLong(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddActiveRuleUuidColumnToActiveRuleParameters.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddActiveRuleUuidColumnToActiveRuleParameters.java new file mode 100644 index 00000000000..d14460dda72 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddActiveRuleUuidColumnToActiveRuleParameters.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.activerules; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddActiveRuleUuidColumnToActiveRuleParameters extends DdlChange { + private static final String TABLE = "active_rule_parameters"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("active_rule_uuid") + .setIsNullable(true) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public AddActiveRuleUuidColumnToActiveRuleParameters(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddColumnsBuilder(getDialect(), TABLE) + .addColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddIndexOnActiveRuleUuidOfActiveRuleParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddIndexOnActiveRuleUuidOfActiveRuleParametersTable.java new file mode 100644 index 00000000000..26bfea0a4f3 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddIndexOnActiveRuleUuidOfActiveRuleParametersTable.java @@ -0,0 +1,61 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.activerules; + +import java.sql.Connection; +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.DatabaseUtils; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddIndexOnActiveRuleUuidOfActiveRuleParametersTable extends DdlChange { + private static final String TABLE_NAME = "active_rule_parameters"; + private static final String INDEX_NAME = "arp_active_rule_uuid"; + + public AddIndexOnActiveRuleUuidOfActiveRuleParametersTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + if (!indexExists()) { + context.execute(new CreateIndexBuilder() + .setUnique(false) + .setTable(TABLE_NAME) + .setName(INDEX_NAME) + .addColumn(newVarcharColumnDefBuilder() + .setColumnName("active_rule_uuid") + .setIsNullable(false) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build()) + .build()); + } + } + + private boolean indexExists() throws SQLException { + try (Connection connection = getDatabase().getDataSource().getConnection()) { + return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); + } + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddPrimaryKeyOnUuidColumnOfActiveRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddPrimaryKeyOnUuidColumnOfActiveRulesTable.java new file mode 100644 index 00000000000..533804ceca5 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddPrimaryKeyOnUuidColumnOfActiveRulesTable.java @@ -0,0 +1,38 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.activerules; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; + +public class AddPrimaryKeyOnUuidColumnOfActiveRulesTable extends DdlChange { + + public AddPrimaryKeyOnUuidColumnOfActiveRulesTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddPrimaryKeyBuilder("active_rules", "uuid").build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddUuidColumnToActiveRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddUuidColumnToActiveRulesTable.java new file mode 100644 index 00000000000..8299a90d440 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddUuidColumnToActiveRulesTable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.activerules; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.AddUuidColumnToTable; + +public class AddUuidColumnToActiveRulesTable extends AddUuidColumnToTable { + private static final String TABLE = "active_rules"; + + public AddUuidColumnToActiveRulesTable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropActiveRuleIdColumnOfActiveRuleParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropActiveRuleIdColumnOfActiveRuleParametersTable.java new file mode 100644 index 00000000000..c673cbeb306 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropActiveRuleIdColumnOfActiveRuleParametersTable.java @@ -0,0 +1,36 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.activerules; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropActiveRuleIdColumnOfActiveRuleParametersTable extends DdlChange { + public DropActiveRuleIdColumnOfActiveRuleParametersTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropColumnsBuilder(getDialect(), "active_rule_parameters", "active_rule_id").build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropIdColumnOfActiveRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropIdColumnOfActiveRulesTable.java new file mode 100644 index 00000000000..e21de24af9b --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropIdColumnOfActiveRulesTable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.activerules; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; + +public class DropIdColumnOfActiveRulesTable extends DropIdColumn { + private static final String TABLE = "active_rules"; + + public DropIdColumnOfActiveRulesTable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropIndexOnActiveRuleIdOfActiveRuleParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropIndexOnActiveRuleIdOfActiveRuleParametersTable.java new file mode 100644 index 00000000000..b8df35a9fe7 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropIndexOnActiveRuleIdOfActiveRuleParametersTable.java @@ -0,0 +1,52 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.activerules; + +import java.sql.Connection; +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.DatabaseUtils; +import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropIndexOnActiveRuleIdOfActiveRuleParametersTable extends DdlChange { + private static final String TABLE_NAME = "active_rule_parameters"; + private static final String INDEX_NAME = "ix_arp_on_active_rule_id"; + + public DropIndexOnActiveRuleIdOfActiveRuleParametersTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + if (indexExists()) { + context.execute(new DropIndexBuilder(getDialect()) + .setTable(TABLE_NAME) + .setName(INDEX_NAME) + .build()); + } + } + + private boolean indexExists() throws SQLException { + try (Connection connection = getDatabase().getDataSource().getConnection()) { + return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); + } + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropPrimaryKeyOnIdColumnOfActiveRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropPrimaryKeyOnIdColumnOfActiveRulesTable.java new file mode 100644 index 00000000000..325a330cc97 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropPrimaryKeyOnIdColumnOfActiveRulesTable.java @@ -0,0 +1,32 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.activerules; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; + +public class DropPrimaryKeyOnIdColumnOfActiveRulesTable extends DropPrimaryKeyOnIdColumn { + private static final String TABLE_NAME = "active_rules"; + + public DropPrimaryKeyOnIdColumnOfActiveRulesTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { + super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/MakeActiveRuleParametersActiveRuleUuidNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/MakeActiveRuleParametersActiveRuleUuidNotNullable.java new file mode 100644 index 00000000000..62c5bbbabe3 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/MakeActiveRuleParametersActiveRuleUuidNotNullable.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.activerules; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class MakeActiveRuleParametersActiveRuleUuidNotNullable extends DdlChange { + private static final String TABLE = "active_rule_parameters"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("active_rule_uuid") + .setIsNullable(false) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public MakeActiveRuleParametersActiveRuleUuidNotNullable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AlterColumnsBuilder(getDialect(), TABLE) + .updateColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/MakeActiveRulesUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/MakeActiveRulesUuidColumnNotNullable.java new file mode 100644 index 00000000000..b4a0af9dda0 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/MakeActiveRulesUuidColumnNotNullable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.activerules; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.MakeUuidColumnNotNullable; + +public class MakeActiveRulesUuidColumnNotNullable extends MakeUuidColumnNotNullable { + private static final String TABLE = "active_rules"; + + public MakeActiveRulesUuidColumnNotNullable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/PopulateActiveRuleParametersActiveRuleUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/PopulateActiveRuleParametersActiveRuleUuid.java new file mode 100644 index 00000000000..d572f36a31d --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/PopulateActiveRuleParametersActiveRuleUuid.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.activerules; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulateActiveRuleParametersActiveRuleUuid extends DataChange { + + public PopulateActiveRuleParametersActiveRuleUuid(Database db) { + super(db); + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select arp.uuid, ar.uuid " + + "from active_rule_parameters arp " + + "join active_rules ar on arp.active_rule_id = ar.id"); + + massUpdate.update("update active_rule_parameters set active_rule_uuid = ? where uuid = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, row.getString(2)); + update.setString(2, row.getString(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/PopulateActiveRulesUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/PopulateActiveRulesUuid.java new file mode 100644 index 00000000000..053eb4d369f --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/PopulateActiveRulesUuid.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.activerules; + +import java.sql.SQLException; +import org.sonar.core.util.UuidFactory; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulateActiveRulesUuid extends DataChange { + + private final UuidFactory uuidFactory; + + public PopulateActiveRulesUuid(Database db, UuidFactory uuidFactory) { + super(db); + this.uuidFactory = uuidFactory; + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select id from active_rules where uuid is null order by id asc"); + massUpdate.update("update active_rules set uuid = ? where id = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, uuidFactory.create()); + update.setLong(2, row.getLong(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTable.java new file mode 100644 index 00000000000..e76cd130ac8 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTable.java @@ -0,0 +1,38 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.ceactivity; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; + +public class AddPrimaryKeyOnUuidColumnOfCeActivityTable extends DdlChange { + + public AddPrimaryKeyOnUuidColumnOfCeActivityTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddPrimaryKeyBuilder("ce_activity", "uuid").build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropIdColumnOfCeActivityTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropIdColumnOfCeActivityTable.java new file mode 100644 index 00000000000..615000a0d3e --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropIdColumnOfCeActivityTable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.ceactivity; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; + +public class DropIdColumnOfCeActivityTable extends DropIdColumn { + private static final String TABLE = "ce_activity"; + + public DropIdColumnOfCeActivityTable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTable.java new file mode 100644 index 00000000000..6e8050569db --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTable.java @@ -0,0 +1,32 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.ceactivity; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; + +public class DropPrimaryKeyOnIdColumnOfCeActivityTable extends DropPrimaryKeyOnIdColumn { + private static final String TABLE_NAME = "ce_activity"; + + public DropPrimaryKeyOnIdColumnOfCeActivityTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { + super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/cequeue/AddPrimaryKeyOnUuidColumnOfCeQueueTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/cequeue/AddPrimaryKeyOnUuidColumnOfCeQueueTable.java new file mode 100644 index 00000000000..cee57f12796 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/cequeue/AddPrimaryKeyOnUuidColumnOfCeQueueTable.java @@ -0,0 +1,38 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.cequeue; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; + +public class AddPrimaryKeyOnUuidColumnOfCeQueueTable extends DdlChange { + + public AddPrimaryKeyOnUuidColumnOfCeQueueTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddPrimaryKeyBuilder("ce_queue", "uuid").build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropIdColumnOfCeQueueTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropIdColumnOfCeQueueTable.java new file mode 100644 index 00000000000..9433bbe8542 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropIdColumnOfCeQueueTable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.cequeue; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; + +public class DropIdColumnOfCeQueueTable extends DropIdColumn { + private static final String TABLE = "ce_queue"; + + public DropIdColumnOfCeQueueTable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropPrimaryKeyOnIdColumnOfCeQueueTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropPrimaryKeyOnIdColumnOfCeQueueTable.java new file mode 100644 index 00000000000..d893f90acf4 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropPrimaryKeyOnIdColumnOfCeQueueTable.java @@ -0,0 +1,32 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.cequeue; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; + +public class DropPrimaryKeyOnIdColumnOfCeQueueTable extends DropPrimaryKeyOnIdColumn { + private static final String TABLE_NAME = "ce_queue"; + + public DropPrimaryKeyOnIdColumnOfCeQueueTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { + super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropUniqueIndexOnUuidColumnOfCeQueueTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropUniqueIndexOnUuidColumnOfCeQueueTable.java new file mode 100644 index 00000000000..5f898380b2f --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropUniqueIndexOnUuidColumnOfCeQueueTable.java @@ -0,0 +1,41 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.cequeue; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropUniqueIndexOnUuidColumnOfCeQueueTable extends DdlChange { + + public DropUniqueIndexOnUuidColumnOfCeQueueTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropIndexBuilder(getDialect()) + .setTable("ce_queue") + .setName("ce_queue_uuid") + .build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/common/AddUuidColumnToTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/common/AddUuidColumnToTable.java new file mode 100644 index 00000000000..534ce422958 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/common/AddUuidColumnToTable.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.common; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public abstract class AddUuidColumnToTable extends DdlChange { + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("uuid") + .setIsNullable(true) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + private String tableName; + + public AddUuidColumnToTable(Database db, String tableName) { + super(db); + this.tableName = tableName; + } + + @Override + public void execute(DdlChange.Context context) throws SQLException { + context.execute(new AddColumnsBuilder(getDialect(), tableName) + .addColumn(uuidColumnDefinition) + .build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/common/DropIdColumn.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/common/DropIdColumn.java new file mode 100644 index 00000000000..af5360a3964 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/common/DropIdColumn.java @@ -0,0 +1,42 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.common; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public abstract class DropIdColumn extends DdlChange { + private Database db; + private String tableName; + + public DropIdColumn(Database db, String tableName) { + super(db); + this.db = db; + this.tableName = tableName; + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropColumnsBuilder(db.getDialect(), tableName, "id").build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/common/DropPrimaryKeyOnIdColumn.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/common/DropPrimaryKeyOnIdColumn.java new file mode 100644 index 00000000000..d2446360995 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/common/DropPrimaryKeyOnIdColumn.java @@ -0,0 +1,41 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.common; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; + +public abstract class DropPrimaryKeyOnIdColumn extends DdlChange { + private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator; + private String tableName; + + public DropPrimaryKeyOnIdColumn(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator, String tableName) { + super(db); + this.dropPrimaryKeySqlGenerator = dropPrimaryKeySqlGenerator; + this.tableName = tableName; + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(dropPrimaryKeySqlGenerator.generate(tableName, "id", true)); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/common/MakeUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/common/MakeUuidColumnNotNullable.java new file mode 100644 index 00000000000..fd89f1c0ad8 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/common/MakeUuidColumnNotNullable.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.common; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public abstract class MakeUuidColumnNotNullable extends DdlChange { + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("uuid") + .setIsNullable(false) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + private String tableName; + + public MakeUuidColumnNotNullable(Database db, String tableName) { + super(db); + this.tableName = tableName; + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AlterColumnsBuilder(getDialect(), tableName) + .updateColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTable.java new file mode 100644 index 00000000000..8cc709820f9 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTable.java @@ -0,0 +1,38 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.duplicationsindex; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; + +public class AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTable extends DdlChange { + + public AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddPrimaryKeyBuilder("duplications_index", "uuid").build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddUuidToDuplicationsIndexTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddUuidToDuplicationsIndexTable.java new file mode 100644 index 00000000000..cc76f299087 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddUuidToDuplicationsIndexTable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.duplicationsindex; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.AddUuidColumnToTable; + +public class AddUuidToDuplicationsIndexTable extends AddUuidColumnToTable { + private static final String TABLE = "duplications_index"; + + public AddUuidToDuplicationsIndexTable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropIdColumnOfDuplicationsIndexTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropIdColumnOfDuplicationsIndexTable.java new file mode 100644 index 00000000000..3710c3ffdb0 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropIdColumnOfDuplicationsIndexTable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.duplicationsindex; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; + +public class DropIdColumnOfDuplicationsIndexTable extends DropIdColumn { + private static final String TABLE = "duplications_index"; + + public DropIdColumnOfDuplicationsIndexTable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropPrimaryKeyOnIdColumnOfDuplicationsIndexTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropPrimaryKeyOnIdColumnOfDuplicationsIndexTable.java new file mode 100644 index 00000000000..18990608534 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropPrimaryKeyOnIdColumnOfDuplicationsIndexTable.java @@ -0,0 +1,32 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.duplicationsindex; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; + +public class DropPrimaryKeyOnIdColumnOfDuplicationsIndexTable extends DropPrimaryKeyOnIdColumn { + private static final String TABLE_NAME = "duplications_index"; + + public DropPrimaryKeyOnIdColumnOfDuplicationsIndexTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { + super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/MakeDuplicationsIndexUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/MakeDuplicationsIndexUuidColumnNotNullable.java new file mode 100644 index 00000000000..80c6087a40a --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/MakeDuplicationsIndexUuidColumnNotNullable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.duplicationsindex; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.MakeUuidColumnNotNullable; + +public class MakeDuplicationsIndexUuidColumnNotNullable extends MakeUuidColumnNotNullable { + private static final String TABLE = "duplications_index"; + + public MakeDuplicationsIndexUuidColumnNotNullable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/PopulateDuplicationsIndexUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/PopulateDuplicationsIndexUuid.java new file mode 100644 index 00000000000..8542aae54c9 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/PopulateDuplicationsIndexUuid.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.duplicationsindex; + +import java.sql.SQLException; +import org.sonar.core.util.UuidFactory; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulateDuplicationsIndexUuid extends DataChange { + + private final UuidFactory uuidFactory; + + public PopulateDuplicationsIndexUuid(Database db, UuidFactory uuidFactory) { + super(db); + this.uuidFactory = uuidFactory; + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select id from duplications_index where uuid is null order by id asc"); + massUpdate.update("update duplications_index set uuid = ? where id = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, uuidFactory.create()); + update.setLong(2, row.getLong(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/events/AddPrimaryKeyOnUuidColumnOfEventsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/events/AddPrimaryKeyOnUuidColumnOfEventsTable.java new file mode 100644 index 00000000000..be9c8545a3b --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/events/AddPrimaryKeyOnUuidColumnOfEventsTable.java @@ -0,0 +1,38 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.events; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; + +public class AddPrimaryKeyOnUuidColumnOfEventsTable extends DdlChange { + + public AddPrimaryKeyOnUuidColumnOfEventsTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddPrimaryKeyBuilder("events", "uuid").build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/events/DropIdColumnOfEventsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/events/DropIdColumnOfEventsTable.java new file mode 100644 index 00000000000..50b5f4a569f --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/events/DropIdColumnOfEventsTable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.events; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; + +public class DropIdColumnOfEventsTable extends DropIdColumn { + private static final String TABLE = "events"; + + public DropIdColumnOfEventsTable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/events/DropPrimaryKeyOnIdColumnOfEventsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/events/DropPrimaryKeyOnIdColumnOfEventsTable.java new file mode 100644 index 00000000000..f2dc33dd070 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/events/DropPrimaryKeyOnIdColumnOfEventsTable.java @@ -0,0 +1,32 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.events; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; + +public class DropPrimaryKeyOnIdColumnOfEventsTable extends DropPrimaryKeyOnIdColumn { + private static final String TABLE_NAME = "events"; + + public DropPrimaryKeyOnIdColumnOfEventsTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { + super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/AddPrimaryKeyOnUuidColumnOfFileSourcesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/AddPrimaryKeyOnUuidColumnOfFileSourcesTable.java new file mode 100644 index 00000000000..0a0c67869fd --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/AddPrimaryKeyOnUuidColumnOfFileSourcesTable.java @@ -0,0 +1,38 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.filesources; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; + +public class AddPrimaryKeyOnUuidColumnOfFileSourcesTable extends DdlChange { + + public AddPrimaryKeyOnUuidColumnOfFileSourcesTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddPrimaryKeyBuilder("file_sources", "uuid").build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/AddUuidColumnToFileSourcesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/AddUuidColumnToFileSourcesTable.java new file mode 100644 index 00000000000..80cc6327eef --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/AddUuidColumnToFileSourcesTable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.filesources; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.AddUuidColumnToTable; + +public class AddUuidColumnToFileSourcesTable extends AddUuidColumnToTable { + private static final String TABLE = "file_sources"; + + public AddUuidColumnToFileSourcesTable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/DropIdColumnOfFileSourcesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/DropIdColumnOfFileSourcesTable.java new file mode 100644 index 00000000000..4846b7d1404 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/DropIdColumnOfFileSourcesTable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.filesources; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; + +public class DropIdColumnOfFileSourcesTable extends DropIdColumn { + private static final String TABLE = "file_sources"; + + public DropIdColumnOfFileSourcesTable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/DropPrimaryKeyOnIdColumnOfFileSourcesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/DropPrimaryKeyOnIdColumnOfFileSourcesTable.java new file mode 100644 index 00000000000..954e562f1ac --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/DropPrimaryKeyOnIdColumnOfFileSourcesTable.java @@ -0,0 +1,32 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.filesources; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; + +public class DropPrimaryKeyOnIdColumnOfFileSourcesTable extends DropPrimaryKeyOnIdColumn { + private static final String TABLE_NAME = "file_sources"; + + public DropPrimaryKeyOnIdColumnOfFileSourcesTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { + super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/MakeFileSourcesUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/MakeFileSourcesUuidColumnNotNullable.java new file mode 100644 index 00000000000..72d8266208f --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/MakeFileSourcesUuidColumnNotNullable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.filesources; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.MakeUuidColumnNotNullable; + +public class MakeFileSourcesUuidColumnNotNullable extends MakeUuidColumnNotNullable { + private static final String TABLE = "file_sources"; + + public MakeFileSourcesUuidColumnNotNullable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/PopulateFileSourcesUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/PopulateFileSourcesUuid.java new file mode 100644 index 00000000000..673ad4b6a23 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/PopulateFileSourcesUuid.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.filesources; + +import java.sql.SQLException; +import org.sonar.core.util.UuidFactory; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulateFileSourcesUuid extends DataChange { + + private final UuidFactory uuidFactory; + + public PopulateFileSourcesUuid(Database db, UuidFactory uuidFactory) { + super(db); + this.uuidFactory = uuidFactory; + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select id from file_sources where uuid is null order by id asc"); + massUpdate.update("update file_sources set uuid = ? where id = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, uuidFactory.create()); + update.setLong(2, row.getLong(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/AddPrimaryKeyOnUuidColumnOfGroupRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/AddPrimaryKeyOnUuidColumnOfGroupRolesTable.java new file mode 100644 index 00000000000..d7d62af77a7 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/AddPrimaryKeyOnUuidColumnOfGroupRolesTable.java @@ -0,0 +1,38 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.grouproles; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; + +public class AddPrimaryKeyOnUuidColumnOfGroupRolesTable extends DdlChange { + + public AddPrimaryKeyOnUuidColumnOfGroupRolesTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddPrimaryKeyBuilder("group_roles", "uuid").build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/AddUuidColumnToGroupRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/AddUuidColumnToGroupRolesTable.java new file mode 100644 index 00000000000..06a56326c62 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/AddUuidColumnToGroupRolesTable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.grouproles; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.AddUuidColumnToTable; + +public class AddUuidColumnToGroupRolesTable extends AddUuidColumnToTable { + private static final String TABLE = "group_roles"; + + public AddUuidColumnToGroupRolesTable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/DropIdColumnOfGroupRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/DropIdColumnOfGroupRolesTable.java new file mode 100644 index 00000000000..e8d9c9d9772 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/DropIdColumnOfGroupRolesTable.java @@ -0,0 +1,41 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.grouproles; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropIdColumnOfGroupRolesTable extends DdlChange { + + private Database db; + + public DropIdColumnOfGroupRolesTable(Database db) { + super(db); + this.db = db; + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropColumnsBuilder(db.getDialect(), "group_roles", "id").build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/DropPrimaryKeyOnIdColumnOfGroupRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/DropPrimaryKeyOnIdColumnOfGroupRolesTable.java new file mode 100644 index 00000000000..af8fa265219 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/DropPrimaryKeyOnIdColumnOfGroupRolesTable.java @@ -0,0 +1,32 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.grouproles; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; + +public class DropPrimaryKeyOnIdColumnOfGroupRolesTable extends DropPrimaryKeyOnIdColumn { + private static final String TABLE_NAME = "group_roles"; + + public DropPrimaryKeyOnIdColumnOfGroupRolesTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { + super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/MakeGroupRolesUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/MakeGroupRolesUuidColumnNotNullable.java new file mode 100644 index 00000000000..b964556eba3 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/MakeGroupRolesUuidColumnNotNullable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.grouproles; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.MakeUuidColumnNotNullable; + +public class MakeGroupRolesUuidColumnNotNullable extends MakeUuidColumnNotNullable { + private static final String TABLE = "group_roles"; + + public MakeGroupRolesUuidColumnNotNullable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/PopulateGroupRolesUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/PopulateGroupRolesUuid.java new file mode 100644 index 00000000000..5f10b60501d --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/PopulateGroupRolesUuid.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.grouproles; + +import java.sql.SQLException; +import org.sonar.core.util.UuidFactory; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulateGroupRolesUuid extends DataChange { + + private final UuidFactory uuidFactory; + + public PopulateGroupRolesUuid(Database db, UuidFactory uuidFactory) { + super(db); + this.uuidFactory = uuidFactory; + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select id from group_roles where uuid is null order by id asc"); + massUpdate.update("update group_roles set uuid = ? where id = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, uuidFactory.create()); + update.setLong(2, row.getLong(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/AddPrimaryKeyOnUuidColumnOfGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/AddPrimaryKeyOnUuidColumnOfGroupsTable.java new file mode 100644 index 00000000000..c3bc655bc81 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/AddPrimaryKeyOnUuidColumnOfGroupsTable.java @@ -0,0 +1,38 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; + +public class AddPrimaryKeyOnUuidColumnOfGroupsTable extends DdlChange { + + public AddPrimaryKeyOnUuidColumnOfGroupsTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddPrimaryKeyBuilder("groups", "uuid").build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/AddUuidColumnToGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/AddUuidColumnToGroupsTable.java new file mode 100644 index 00000000000..dd0840ae235 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/AddUuidColumnToGroupsTable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.AddUuidColumnToTable; + +public class AddUuidColumnToGroupsTable extends AddUuidColumnToTable { + private static final String TABLE = "groups"; + + public AddUuidColumnToGroupsTable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/DropIdColumnOfGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/DropIdColumnOfGroupsTable.java new file mode 100644 index 00000000000..85c20b2c628 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/DropIdColumnOfGroupsTable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; + +public class DropIdColumnOfGroupsTable extends DropIdColumn { + private static final String TABLE = "groups"; + + public DropIdColumnOfGroupsTable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/DropPrimaryKeyOnIdColumnOfGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/DropPrimaryKeyOnIdColumnOfGroupsTable.java new file mode 100644 index 00000000000..6759868372b --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/DropPrimaryKeyOnIdColumnOfGroupsTable.java @@ -0,0 +1,32 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; + +public class DropPrimaryKeyOnIdColumnOfGroupsTable extends DropPrimaryKeyOnIdColumn { + private static final String TABLE_NAME = "groups"; + + public DropPrimaryKeyOnIdColumnOfGroupsTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { + super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/MakeGroupsUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/MakeGroupsUuidColumnNotNullable.java new file mode 100644 index 00000000000..dd443d8f2f6 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/MakeGroupsUuidColumnNotNullable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.MakeUuidColumnNotNullable; + +public class MakeGroupsUuidColumnNotNullable extends MakeUuidColumnNotNullable { + private static final String TABLE = "groups"; + + public MakeGroupsUuidColumnNotNullable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/PopulateGroupsUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/PopulateGroupsUuid.java new file mode 100644 index 00000000000..2614b8fe46f --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/PopulateGroupsUuid.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups; + +import java.sql.SQLException; +import org.sonar.core.util.UuidFactory; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulateGroupsUuid extends DataChange { + + private final UuidFactory uuidFactory; + + public PopulateGroupsUuid(Database db, UuidFactory uuidFactory) { + super(db); + this.uuidFactory = uuidFactory; + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select id from groups where uuid is null order by id asc"); + massUpdate.update("update groups set uuid = ? where id = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, uuidFactory.create()); + update.setLong(2, row.getLong(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/AddGroupUuidColumnToGroupRoles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/AddGroupUuidColumnToGroupRoles.java new file mode 100644 index 00000000000..2e8f291e1da --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/AddGroupUuidColumnToGroupRoles.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.grouproles; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddGroupUuidColumnToGroupRoles extends DdlChange { + private static final String TABLE = "group_roles"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("group_uuid") + .setIsNullable(true) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public AddGroupUuidColumnToGroupRoles(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddColumnsBuilder(getDialect(), TABLE) + .addColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/AddIndexOnGroupUuidOfGroupRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/AddIndexOnGroupUuidOfGroupRolesTable.java new file mode 100644 index 00000000000..d7d99463837 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/AddIndexOnGroupUuidOfGroupRolesTable.java @@ -0,0 +1,76 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.grouproles; + +import java.sql.Connection; +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.DatabaseUtils; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddIndexOnGroupUuidOfGroupRolesTable extends DdlChange { + private static final String TABLE_NAME = "group_roles"; + private static final String INDEX_NAME = "uniq_group_roles"; + + public AddIndexOnGroupUuidOfGroupRolesTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + if (!indexExists()) { + context.execute(new CreateIndexBuilder() + .setUnique(true) + .setTable(TABLE_NAME) + .setName(INDEX_NAME) + .addColumn(newVarcharColumnDefBuilder() + .setColumnName("organization_uuid") + .setIsNullable(false) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build()) + .addColumn(newVarcharColumnDefBuilder() + .setColumnName("group_uuid") + .setIsNullable(false) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build()) + .addColumn(newVarcharColumnDefBuilder() + .setColumnName("component_uuid") + .setIsNullable(true) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build()) + .addColumn(newVarcharColumnDefBuilder() + .setColumnName("role") + .setIsNullable(false) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build()) + .build()); + } + } + + private boolean indexExists() throws SQLException { + try (Connection connection = getDatabase().getDataSource().getConnection()) { + return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); + } + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/DropGroupIdColumnOfGroupRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/DropGroupIdColumnOfGroupRolesTable.java new file mode 100644 index 00000000000..e011cc890ad --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/DropGroupIdColumnOfGroupRolesTable.java @@ -0,0 +1,36 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.grouproles; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropGroupIdColumnOfGroupRolesTable extends DdlChange { + public DropGroupIdColumnOfGroupRolesTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropColumnsBuilder(getDialect(), "group_roles", "group_id").build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/DropIndexOnGroupIdOfGroupRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/DropIndexOnGroupIdOfGroupRolesTable.java new file mode 100644 index 00000000000..93f6dbe7216 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/DropIndexOnGroupIdOfGroupRolesTable.java @@ -0,0 +1,52 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.grouproles; + +import java.sql.Connection; +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.DatabaseUtils; +import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropIndexOnGroupIdOfGroupRolesTable extends DdlChange { + private static final String TABLE_NAME = "group_roles"; + private static final String INDEX_NAME = "uniq_group_roles"; + + public DropIndexOnGroupIdOfGroupRolesTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + if (indexExists()) { + context.execute(new DropIndexBuilder(getDialect()) + .setTable(TABLE_NAME) + .setName(INDEX_NAME) + .build()); + } + } + + private boolean indexExists() throws SQLException { + try (Connection connection = getDatabase().getDataSource().getConnection()) { + return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); + } + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/PopulateGroupRolesGroupUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/PopulateGroupRolesGroupUuid.java new file mode 100644 index 00000000000..fc9c4a02d95 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/PopulateGroupRolesGroupUuid.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.grouproles; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulateGroupRolesGroupUuid extends DataChange { + + public PopulateGroupRolesGroupUuid(Database db) { + super(db); + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select gr.uuid, g.uuid " + + "from group_roles gr " + + "join groups g on gr.group_id = g.id"); + + massUpdate.update("update group_roles set group_uuid = ? where uuid = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, row.getString(2)); + update.setString(2, row.getString(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/AddGroupUuidColumnToGroupsUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/AddGroupUuidColumnToGroupsUsers.java new file mode 100644 index 00000000000..bba28add577 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/AddGroupUuidColumnToGroupsUsers.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.groupsusers; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddGroupUuidColumnToGroupsUsers extends DdlChange { + private static final String TABLE = "groups_users"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("group_uuid") + .setIsNullable(true) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public AddGroupUuidColumnToGroupsUsers(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddColumnsBuilder(getDialect(), TABLE) + .addColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/AddIndexOnGroupUuidOfGroupsUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/AddIndexOnGroupUuidOfGroupsUsersTable.java new file mode 100644 index 00000000000..ecb0f5d36bc --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/AddIndexOnGroupUuidOfGroupsUsersTable.java @@ -0,0 +1,76 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.groupsusers; + +import java.sql.Connection; +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.DatabaseUtils; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.BigIntegerColumnDef.newBigIntegerColumnDefBuilder; +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddIndexOnGroupUuidOfGroupsUsersTable extends DdlChange { + private static final String TABLE_NAME = "groups_users"; + private static final String INDEX_NAME1 = "index_groups_users_group_uuid"; + private static final String INDEX_NAME2 = "groups_users_unique"; + + public AddIndexOnGroupUuidOfGroupsUsersTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + VarcharColumnDef groupUuid = newVarcharColumnDefBuilder() + .setColumnName("group_uuid") + .setIsNullable(false) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + if (!indexExists(INDEX_NAME1)) { + context.execute(new CreateIndexBuilder() + .setUnique(false) + .setTable(TABLE_NAME) + .setName(INDEX_NAME1) + .addColumn(groupUuid) + .build()); + } + if (!indexExists(INDEX_NAME2)) { + context.execute(new CreateIndexBuilder() + .setUnique(true) + .setTable(TABLE_NAME) + .setName(INDEX_NAME2) + .addColumn(groupUuid) + .addColumn(newBigIntegerColumnDefBuilder() + .setColumnName("user_id") + .setIsNullable(true) + .build()) + .build()); + } + } + + private boolean indexExists(String name) throws SQLException { + try (Connection connection = getDatabase().getDataSource().getConnection()) { + return DatabaseUtils.indexExists(TABLE_NAME, name, connection); + } + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/DropGroupIdColumnOfGroupsUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/DropGroupIdColumnOfGroupsUsersTable.java new file mode 100644 index 00000000000..dc149e4aef9 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/DropGroupIdColumnOfGroupsUsersTable.java @@ -0,0 +1,36 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.groupsusers; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropGroupIdColumnOfGroupsUsersTable extends DdlChange { + public DropGroupIdColumnOfGroupsUsersTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropColumnsBuilder(getDialect(), "groups_users", "group_id").build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/DropIndexOnGroupIdOfGroupsUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/DropIndexOnGroupIdOfGroupsUsersTable.java new file mode 100644 index 00000000000..3b01f284cd0 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/DropIndexOnGroupIdOfGroupsUsersTable.java @@ -0,0 +1,59 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.groupsusers; + +import java.sql.Connection; +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.DatabaseUtils; +import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropIndexOnGroupIdOfGroupsUsersTable extends DdlChange { + private static final String TABLE_NAME = "groups_users"; + private static final String INDEX_NAME1 = "index_groups_users_on_group_id"; + private static final String INDEX_NAME2 = "groups_users_unique"; + + public DropIndexOnGroupIdOfGroupsUsersTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + if (indexExists(INDEX_NAME1)) { + context.execute(new DropIndexBuilder(getDialect()) + .setTable(TABLE_NAME) + .setName(INDEX_NAME1) + .build()); + } + if (indexExists(INDEX_NAME2)) { + context.execute(new DropIndexBuilder(getDialect()) + .setTable(TABLE_NAME) + .setName(INDEX_NAME2) + .build()); + } + } + + private boolean indexExists(String name) throws SQLException { + try (Connection connection = getDatabase().getDataSource().getConnection()) { + return DatabaseUtils.indexExists(TABLE_NAME, name, connection); + } + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/MakeGroupsUsersGroupUuidNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/MakeGroupsUsersGroupUuidNotNullable.java new file mode 100644 index 00000000000..dde58af6c3b --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/MakeGroupsUsersGroupUuidNotNullable.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.groupsusers; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class MakeGroupsUsersGroupUuidNotNullable extends DdlChange { + private static final String TABLE = "groups_users"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("group_uuid") + .setIsNullable(false) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public MakeGroupsUsersGroupUuidNotNullable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AlterColumnsBuilder(getDialect(), TABLE) + .updateColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/PopulateGroupsUsersGroupUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/PopulateGroupsUsersGroupUuid.java new file mode 100644 index 00000000000..6eb0408bb83 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/PopulateGroupsUsersGroupUuid.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.groupsusers; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulateGroupsUsersGroupUuid extends DataChange { + + public PopulateGroupsUsersGroupUuid(Database db) { + super(db); + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select gu.user_id, gu.group_id, g.uuid " + + "from groups_users gu " + + "join groups g on gu.group_id = g.id"); + + massUpdate.update("update groups_users set group_uuid = ? where user_id = ? and group_id = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, row.getString(3)); + update.setLong(2, row.getLong(1)); + update.setLong(3, row.getLong(2)); + + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/AddDefaultGroupUuidColumnToOrganizations.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/AddDefaultGroupUuidColumnToOrganizations.java new file mode 100644 index 00000000000..55f30b45311 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/AddDefaultGroupUuidColumnToOrganizations.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.organizations; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddDefaultGroupUuidColumnToOrganizations extends DdlChange { + private static final String TABLE = "organizations"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("default_group_uuid") + .setIsNullable(true) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public AddDefaultGroupUuidColumnToOrganizations(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddColumnsBuilder(getDialect(), TABLE) + .addColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/DropDefaultGroupIdColumnOfOrganizationsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/DropDefaultGroupIdColumnOfOrganizationsTable.java new file mode 100644 index 00000000000..926e9c6adb6 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/DropDefaultGroupIdColumnOfOrganizationsTable.java @@ -0,0 +1,36 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.organizations; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropDefaultGroupIdColumnOfOrganizationsTable extends DdlChange { + public DropDefaultGroupIdColumnOfOrganizationsTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropColumnsBuilder(getDialect(), "organizations", "default_group_id").build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/PopulateOrganizationsDefaultGroupUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/PopulateOrganizationsDefaultGroupUuid.java new file mode 100644 index 00000000000..a24bf8f6076 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/PopulateOrganizationsDefaultGroupUuid.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.organizations; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulateOrganizationsDefaultGroupUuid extends DataChange { + + public PopulateOrganizationsDefaultGroupUuid(Database db) { + super(db); + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select o.uuid, g.uuid " + + "from organizations o " + + "join groups g on o.default_group_id = g.id"); + + massUpdate.update("update organizations set default_group_uuid = ? where uuid = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, row.getString(2)); + update.setString(2, row.getString(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/AddGroupUuidColumnToPermTemplatesGroups.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/AddGroupUuidColumnToPermTemplatesGroups.java new file mode 100644 index 00000000000..7ffa977d2eb --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/AddGroupUuidColumnToPermTemplatesGroups.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.permtemplatesgroups; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddGroupUuidColumnToPermTemplatesGroups extends DdlChange { + private static final String TABLE = "perm_templates_groups"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("group_uuid") + .setIsNullable(true) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public AddGroupUuidColumnToPermTemplatesGroups(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddColumnsBuilder(getDialect(), TABLE) + .addColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/DropGroupIdColumnOfPermTemplatesGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/DropGroupIdColumnOfPermTemplatesGroupsTable.java new file mode 100644 index 00000000000..dc6fd4f42b6 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/DropGroupIdColumnOfPermTemplatesGroupsTable.java @@ -0,0 +1,36 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.permtemplatesgroups; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropGroupIdColumnOfPermTemplatesGroupsTable extends DdlChange { + public DropGroupIdColumnOfPermTemplatesGroupsTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropColumnsBuilder(getDialect(), "perm_templates_groups", "group_id").build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/PopulatePermTemplatesGroupsGroupUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/PopulatePermTemplatesGroupsGroupUuid.java new file mode 100644 index 00000000000..93bd72df2dc --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/PopulatePermTemplatesGroupsGroupUuid.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.permtemplatesgroups; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulatePermTemplatesGroupsGroupUuid extends DataChange { + + public PopulatePermTemplatesGroupsGroupUuid(Database db) { + super(db); + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select ptg.uuid, g.uuid " + + "from perm_templates_groups ptg " + + "join groups g on ptg.group_id = g.id"); + + massUpdate.update("update perm_templates_groups set group_uuid = ? where uuid = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, row.getString(2)); + update.setString(2, row.getString(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/AddGroupUuidColumnToQProfileEditGroups.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/AddGroupUuidColumnToQProfileEditGroups.java new file mode 100644 index 00000000000..66b1f07cd5a --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/AddGroupUuidColumnToQProfileEditGroups.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.qprofileeditgroups; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddGroupUuidColumnToQProfileEditGroups extends DdlChange { + private static final String TABLE = "qprofile_edit_groups"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("group_uuid") + .setIsNullable(true) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public AddGroupUuidColumnToQProfileEditGroups(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddColumnsBuilder(getDialect(), TABLE) + .addColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/AddIndexOnGroupUuidOfQProfileEditGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/AddIndexOnGroupUuidOfQProfileEditGroupsTable.java new file mode 100644 index 00000000000..2029b8b2499 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/AddIndexOnGroupUuidOfQProfileEditGroupsTable.java @@ -0,0 +1,66 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.qprofileeditgroups; + +import java.sql.Connection; +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.DatabaseUtils; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddIndexOnGroupUuidOfQProfileEditGroupsTable extends DdlChange { + private static final String TABLE_NAME = "qprofile_edit_groups"; + private static final String INDEX_NAME = "qprofile_edit_groups_unique"; + + public AddIndexOnGroupUuidOfQProfileEditGroupsTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + if (!indexExists()) { + context.execute(new CreateIndexBuilder() + .setUnique(true) + .setTable(TABLE_NAME) + .setName(INDEX_NAME) + .addColumn(newVarcharColumnDefBuilder() + .setColumnName("group_uuid") + .setIsNullable(false) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build()) + .addColumn(newVarcharColumnDefBuilder() + .setColumnName("qprofile_uuid") + .setIsNullable(false) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build()) + .build()); + } + } + + private boolean indexExists() throws SQLException { + try (Connection connection = getDatabase().getDataSource().getConnection()) { + return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); + } + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/DropGroupIdColumnOfQProfileEditGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/DropGroupIdColumnOfQProfileEditGroupsTable.java new file mode 100644 index 00000000000..ca47313dd4f --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/DropGroupIdColumnOfQProfileEditGroupsTable.java @@ -0,0 +1,36 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.qprofileeditgroups; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropGroupIdColumnOfQProfileEditGroupsTable extends DdlChange { + public DropGroupIdColumnOfQProfileEditGroupsTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropColumnsBuilder(getDialect(), "qprofile_edit_groups", "group_id").build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/DropIndexOnGroupIdOfQProfileEditGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/DropIndexOnGroupIdOfQProfileEditGroupsTable.java new file mode 100644 index 00000000000..d64275b6a6a --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/DropIndexOnGroupIdOfQProfileEditGroupsTable.java @@ -0,0 +1,52 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.qprofileeditgroups; + +import java.sql.Connection; +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.DatabaseUtils; +import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropIndexOnGroupIdOfQProfileEditGroupsTable extends DdlChange { + private static final String TABLE_NAME = "qprofile_edit_groups"; + private static final String INDEX_NAME = "qprofile_edit_groups_unique"; + + public DropIndexOnGroupIdOfQProfileEditGroupsTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + if (indexExists(INDEX_NAME)) { + context.execute(new DropIndexBuilder(getDialect()) + .setTable(TABLE_NAME) + .setName(INDEX_NAME) + .build()); + } + } + + private boolean indexExists(String name) throws SQLException { + try (Connection connection = getDatabase().getDataSource().getConnection()) { + return DatabaseUtils.indexExists(TABLE_NAME, name, connection); + } + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/MakeQProfileEditGroupsGroupUuidNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/MakeQProfileEditGroupsGroupUuidNotNullable.java new file mode 100644 index 00000000000..fdeecc65ef6 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/MakeQProfileEditGroupsGroupUuidNotNullable.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.qprofileeditgroups; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class MakeQProfileEditGroupsGroupUuidNotNullable extends DdlChange { + private static final String TABLE = "qprofile_edit_groups"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("group_uuid") + .setIsNullable(false) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public MakeQProfileEditGroupsGroupUuidNotNullable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AlterColumnsBuilder(getDialect(), TABLE) + .updateColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/PopulateQProfileEditGroupsGroupUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/PopulateQProfileEditGroupsGroupUuid.java new file mode 100644 index 00000000000..ff8f58f7a6f --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/PopulateQProfileEditGroupsGroupUuid.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.qprofileeditgroups; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulateQProfileEditGroupsGroupUuid extends DataChange { + + public PopulateQProfileEditGroupsGroupUuid(Database db) { + super(db); + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select qeg.uuid, g.uuid " + + "from qprofile_edit_groups qeg " + + "join groups g on qeg.group_id = g.id"); + + massUpdate.update("update qprofile_edit_groups set group_uuid = ? where uuid = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, row.getString(2)); + update.setString(2, row.getString(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddPrimaryKeyOnUuidColumnOfIssueChangesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddPrimaryKeyOnUuidColumnOfIssueChangesTable.java new file mode 100644 index 00000000000..d8515339139 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddPrimaryKeyOnUuidColumnOfIssueChangesTable.java @@ -0,0 +1,38 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.issuechanges; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; + +public class AddPrimaryKeyOnUuidColumnOfIssueChangesTable extends DdlChange { + + public AddPrimaryKeyOnUuidColumnOfIssueChangesTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddPrimaryKeyBuilder("issue_changes", "uuid").build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddUuidColumnToIssueChangesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddUuidColumnToIssueChangesTable.java new file mode 100644 index 00000000000..5e230a55fac --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddUuidColumnToIssueChangesTable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.issuechanges; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.AddUuidColumnToTable; + +public class AddUuidColumnToIssueChangesTable extends AddUuidColumnToTable { + private static final String TABLE = "issue_changes"; + + public AddUuidColumnToIssueChangesTable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/DropIdColumnOfIssueChangesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/DropIdColumnOfIssueChangesTable.java new file mode 100644 index 00000000000..3855775af41 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/DropIdColumnOfIssueChangesTable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.issuechanges; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; + +public class DropIdColumnOfIssueChangesTable extends DropIdColumn { + private static final String TABLE = "issue_changes"; + + public DropIdColumnOfIssueChangesTable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/DropPrimaryKeyOnIdColumnOfIssueChangesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/DropPrimaryKeyOnIdColumnOfIssueChangesTable.java new file mode 100644 index 00000000000..99e83714900 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/DropPrimaryKeyOnIdColumnOfIssueChangesTable.java @@ -0,0 +1,32 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.issuechanges; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; + +public class DropPrimaryKeyOnIdColumnOfIssueChangesTable extends DropPrimaryKeyOnIdColumn { + private static final String TABLE_NAME = "issue_changes"; + + public DropPrimaryKeyOnIdColumnOfIssueChangesTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { + super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/MakeIssueChangesUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/MakeIssueChangesUuidColumnNotNullable.java new file mode 100644 index 00000000000..348213722c5 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/MakeIssueChangesUuidColumnNotNullable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.issuechanges; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.MakeUuidColumnNotNullable; + +public class MakeIssueChangesUuidColumnNotNullable extends MakeUuidColumnNotNullable { + private static final String TABLE = "issue_changes"; + + public MakeIssueChangesUuidColumnNotNullable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/PopulateIssueChangesUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/PopulateIssueChangesUuid.java new file mode 100644 index 00000000000..b52f665023c --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/PopulateIssueChangesUuid.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.issuechanges; + +import java.sql.SQLException; +import org.sonar.core.util.UuidFactory; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulateIssueChangesUuid extends DataChange { + + private final UuidFactory uuidFactory; + + public PopulateIssueChangesUuid(Database db, UuidFactory uuidFactory) { + super(db); + this.uuidFactory = uuidFactory; + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select id from issue_changes where uuid is null order by id asc"); + massUpdate.update("update issue_changes set uuid = ? where id = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, uuidFactory.create()); + update.setLong(2, row.getLong(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issues/AddPrimaryKeyOnKeeColumnOfIssuesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issues/AddPrimaryKeyOnKeeColumnOfIssuesTable.java new file mode 100644 index 00000000000..71d552a0b21 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issues/AddPrimaryKeyOnKeeColumnOfIssuesTable.java @@ -0,0 +1,38 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.issues; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; + +public class AddPrimaryKeyOnKeeColumnOfIssuesTable extends DdlChange { + + public AddPrimaryKeyOnKeeColumnOfIssuesTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddPrimaryKeyBuilder("issues", "kee").build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issues/DropIdColumnOfIssuesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issues/DropIdColumnOfIssuesTable.java new file mode 100644 index 00000000000..22726ff29f3 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issues/DropIdColumnOfIssuesTable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.issues; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; + +public class DropIdColumnOfIssuesTable extends DropIdColumn { + private static final String TABLE = "issues"; + + public DropIdColumnOfIssuesTable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issues/DropPrimaryKeyOnIdColumnOfIssuesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issues/DropPrimaryKeyOnIdColumnOfIssuesTable.java new file mode 100644 index 00000000000..59427acb800 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issues/DropPrimaryKeyOnIdColumnOfIssuesTable.java @@ -0,0 +1,32 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.issues; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; + +public class DropPrimaryKeyOnIdColumnOfIssuesTable extends DropPrimaryKeyOnIdColumn { + private static final String TABLE_NAME = "issues"; + + public DropPrimaryKeyOnIdColumnOfIssuesTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { + super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddPrimaryKeyOnUuidColumnOfManualMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddPrimaryKeyOnUuidColumnOfManualMeasuresTable.java new file mode 100644 index 00000000000..cbcc2fca86b --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddPrimaryKeyOnUuidColumnOfManualMeasuresTable.java @@ -0,0 +1,38 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.manualmeasures; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; + +public class AddPrimaryKeyOnUuidColumnOfManualMeasuresTable extends DdlChange { + + public AddPrimaryKeyOnUuidColumnOfManualMeasuresTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddPrimaryKeyBuilder("manual_measures", "uuid").build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddUuidColumnToManualMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddUuidColumnToManualMeasures.java new file mode 100644 index 00000000000..d49f87fc6a3 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddUuidColumnToManualMeasures.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.manualmeasures; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddUuidColumnToManualMeasures extends DdlChange { + private static final String TABLE = "manual_measures"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("uuid") + .setIsNullable(true) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public AddUuidColumnToManualMeasures(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddColumnsBuilder(getDialect(), TABLE) + .addColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropIdColumnOfManualMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropIdColumnOfManualMeasuresTable.java new file mode 100644 index 00000000000..443879ab003 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropIdColumnOfManualMeasuresTable.java @@ -0,0 +1,37 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.manualmeasures; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropIdColumnOfManualMeasuresTable extends DdlChange { + + public DropIdColumnOfManualMeasuresTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropColumnsBuilder(getDialect(), "manual_measures", "id").build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropPrimaryKeyOnIdColumnOfManualMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropPrimaryKeyOnIdColumnOfManualMeasuresTable.java new file mode 100644 index 00000000000..72c50f74b68 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropPrimaryKeyOnIdColumnOfManualMeasuresTable.java @@ -0,0 +1,41 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.manualmeasures; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; + +public class DropPrimaryKeyOnIdColumnOfManualMeasuresTable extends DdlChange { + + private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator; + + public DropPrimaryKeyOnIdColumnOfManualMeasuresTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { + super(db); + this.dropPrimaryKeySqlGenerator = dropPrimaryKeySqlGenerator; + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(dropPrimaryKeySqlGenerator.generate("manual_measures", "id", true)); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/MakeManualMeasuresUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/MakeManualMeasuresUuidColumnNotNullable.java new file mode 100644 index 00000000000..7a23f7b356c --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/MakeManualMeasuresUuidColumnNotNullable.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.manualmeasures; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class MakeManualMeasuresUuidColumnNotNullable extends DdlChange { + private static final String TABLE = "manual_measures"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("uuid") + .setIsNullable(false) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public MakeManualMeasuresUuidColumnNotNullable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AlterColumnsBuilder(getDialect(), TABLE) + .updateColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/PopulateManualMeasureUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/PopulateManualMeasureUuid.java new file mode 100644 index 00000000000..5bd05a72913 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/PopulateManualMeasureUuid.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.manualmeasures; + +import java.sql.SQLException; +import org.sonar.core.util.UuidFactory; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulateManualMeasureUuid extends DataChange { + + private final UuidFactory uuidFactory; + + public PopulateManualMeasureUuid(Database db, UuidFactory uuidFactory) { + super(db); + this.uuidFactory = uuidFactory; + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select id from manual_measures where uuid is null"); + massUpdate.update("update manual_measures set uuid = ? where id = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, uuidFactory.create()); + update.setLong(2, row.getLong(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/AddPrimaryKeyOnUuidColumnOfMetricsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/AddPrimaryKeyOnUuidColumnOfMetricsTable.java new file mode 100644 index 00000000000..708d91ad4df --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/AddPrimaryKeyOnUuidColumnOfMetricsTable.java @@ -0,0 +1,38 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; + +public class AddPrimaryKeyOnUuidColumnOfMetricsTable extends DdlChange { + + public AddPrimaryKeyOnUuidColumnOfMetricsTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddPrimaryKeyBuilder("metrics", "uuid").build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/AddUuidColumnToMetricsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/AddUuidColumnToMetricsTable.java new file mode 100644 index 00000000000..e43e2d0b0b0 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/AddUuidColumnToMetricsTable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.AddUuidColumnToTable; + +public class AddUuidColumnToMetricsTable extends AddUuidColumnToTable { + private static final String TABLE = "metrics"; + + public AddUuidColumnToMetricsTable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/DropIdColumnOfMetricsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/DropIdColumnOfMetricsTable.java new file mode 100644 index 00000000000..c425e6e8719 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/DropIdColumnOfMetricsTable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; + +public class DropIdColumnOfMetricsTable extends DropIdColumn { + private static final String TABLE = "metrics"; + + public DropIdColumnOfMetricsTable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/DropPrimaryKeyOnIdColumnOfMetricsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/DropPrimaryKeyOnIdColumnOfMetricsTable.java new file mode 100644 index 00000000000..7b648ae092e --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/DropPrimaryKeyOnIdColumnOfMetricsTable.java @@ -0,0 +1,32 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; + +public class DropPrimaryKeyOnIdColumnOfMetricsTable extends DropPrimaryKeyOnIdColumn { + private static final String TABLE_NAME = "metrics"; + + public DropPrimaryKeyOnIdColumnOfMetricsTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { + super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/MakeMetricsUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/MakeMetricsUuidColumnNotNullable.java new file mode 100644 index 00000000000..a968b4c7db6 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/MakeMetricsUuidColumnNotNullable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.MakeUuidColumnNotNullable; + +public class MakeMetricsUuidColumnNotNullable extends MakeUuidColumnNotNullable { + private static final String TABLE = "metrics"; + + public MakeMetricsUuidColumnNotNullable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/PopulateMetricsUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/PopulateMetricsUuid.java new file mode 100644 index 00000000000..12f1d628cdf --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/PopulateMetricsUuid.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics; + +import java.sql.SQLException; +import org.sonar.core.util.UuidFactory; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulateMetricsUuid extends DataChange { + + private final UuidFactory uuidFactory; + + public PopulateMetricsUuid(Database db, UuidFactory uuidFactory) { + super(db); + this.uuidFactory = uuidFactory; + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select id from metrics where uuid is null order by id asc"); + massUpdate.update("update metrics set uuid = ? where id = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, uuidFactory.create()); + update.setLong(2, row.getLong(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddIndexOnMetricUuidOfLiveMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddIndexOnMetricUuidOfLiveMeasuresTable.java new file mode 100644 index 00000000000..d92a46e3df0 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddIndexOnMetricUuidOfLiveMeasuresTable.java @@ -0,0 +1,66 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics.livemeasures; + +import java.sql.Connection; +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.DatabaseUtils; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddIndexOnMetricUuidOfLiveMeasuresTable extends DdlChange { + private static final String TABLE_NAME = "live_measures"; + private static final String INDEX_NAME = "live_measures_component"; + + public AddIndexOnMetricUuidOfLiveMeasuresTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + if (!indexExists()) { + context.execute(new CreateIndexBuilder() + .setUnique(true) + .setTable(TABLE_NAME) + .setName(INDEX_NAME) + .addColumn(newVarcharColumnDefBuilder() + .setColumnName("component_uuid") + .setIsNullable(false) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build()) + .addColumn(newVarcharColumnDefBuilder() + .setColumnName("metric_uuid") + .setIsNullable(false) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build()) + .build()); + } + } + + private boolean indexExists() throws SQLException { + try (Connection connection = getDatabase().getDataSource().getConnection()) { + return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); + } + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddMetricUuidColumnToLiveMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddMetricUuidColumnToLiveMeasures.java new file mode 100644 index 00000000000..bd0a5488e2b --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddMetricUuidColumnToLiveMeasures.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics.livemeasures; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddMetricUuidColumnToLiveMeasures extends DdlChange { + private static final String TABLE = "live_measures"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("metric_uuid") + .setIsNullable(true) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public AddMetricUuidColumnToLiveMeasures(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddColumnsBuilder(getDialect(), TABLE) + .addColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/DropIndexOnMetricIdOfLiveMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/DropIndexOnMetricIdOfLiveMeasuresTable.java new file mode 100644 index 00000000000..08b63ea0caf --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/DropIndexOnMetricIdOfLiveMeasuresTable.java @@ -0,0 +1,52 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics.livemeasures; + +import java.sql.Connection; +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.DatabaseUtils; +import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropIndexOnMetricIdOfLiveMeasuresTable extends DdlChange { + private static final String TABLE_NAME = "live_measures"; + private static final String INDEX_NAME = "live_measures_component"; + + public DropIndexOnMetricIdOfLiveMeasuresTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + if (indexExists()) { + context.execute(new DropIndexBuilder(getDialect()) + .setTable(TABLE_NAME) + .setName(INDEX_NAME) + .build()); + } + } + + private boolean indexExists() throws SQLException { + try (Connection connection = getDatabase().getDataSource().getConnection()) { + return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); + } + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/DropMetricIdColumnOfLiveMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/DropMetricIdColumnOfLiveMeasuresTable.java new file mode 100644 index 00000000000..708532d5e9e --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/DropMetricIdColumnOfLiveMeasuresTable.java @@ -0,0 +1,36 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics.livemeasures; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropMetricIdColumnOfLiveMeasuresTable extends DdlChange { + public DropMetricIdColumnOfLiveMeasuresTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropColumnsBuilder(getDialect(), "live_measures", "metric_id").build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/MakeLiveMeasuresMetricUuidNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/MakeLiveMeasuresMetricUuidNotNullable.java new file mode 100644 index 00000000000..11b72b28723 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/MakeLiveMeasuresMetricUuidNotNullable.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics.livemeasures; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class MakeLiveMeasuresMetricUuidNotNullable extends DdlChange { + private static final String TABLE = "live_measures"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("metric_uuid") + .setIsNullable(false) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public MakeLiveMeasuresMetricUuidNotNullable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AlterColumnsBuilder(getDialect(), TABLE) + .updateColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/PopulateLiveMeasuresMetricUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/PopulateLiveMeasuresMetricUuid.java new file mode 100644 index 00000000000..6284c7f8153 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/PopulateLiveMeasuresMetricUuid.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics.livemeasures; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulateLiveMeasuresMetricUuid extends DataChange { + + public PopulateLiveMeasuresMetricUuid(Database db) { + super(db); + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select lm.uuid, m.uuid " + + "from live_measures lm " + + "join metrics m on lm.metric_id = m.id"); + + massUpdate.update("update live_measures set metric_uuid = ? where uuid = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, row.getString(2)); + update.setString(2, row.getString(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/AddMetricUuidColumnToManualMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/AddMetricUuidColumnToManualMeasures.java new file mode 100644 index 00000000000..de68b6bd4d5 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/AddMetricUuidColumnToManualMeasures.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics.manualmeasures; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddMetricUuidColumnToManualMeasures extends DdlChange { + private static final String TABLE = "manual_measures"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("metric_uuid") + .setIsNullable(true) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public AddMetricUuidColumnToManualMeasures(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddColumnsBuilder(getDialect(), TABLE) + .addColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/DropMetricIdColumnOfManualMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/DropMetricIdColumnOfManualMeasuresTable.java new file mode 100644 index 00000000000..1d9b77b2afd --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/DropMetricIdColumnOfManualMeasuresTable.java @@ -0,0 +1,36 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics.manualmeasures; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropMetricIdColumnOfManualMeasuresTable extends DdlChange { + public DropMetricIdColumnOfManualMeasuresTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropColumnsBuilder(getDialect(), "manual_measures", "metric_id").build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/MakeManualMeasuresMetricUuidNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/MakeManualMeasuresMetricUuidNotNullable.java new file mode 100644 index 00000000000..70e22b4fa7d --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/MakeManualMeasuresMetricUuidNotNullable.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics.manualmeasures; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class MakeManualMeasuresMetricUuidNotNullable extends DdlChange { + private static final String TABLE = "manual_measures"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("metric_uuid") + .setIsNullable(false) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public MakeManualMeasuresMetricUuidNotNullable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AlterColumnsBuilder(getDialect(), TABLE) + .updateColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/PopulateManualMeasuresMetricUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/PopulateManualMeasuresMetricUuid.java new file mode 100644 index 00000000000..120c98f3203 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/PopulateManualMeasuresMetricUuid.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics.manualmeasures; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulateManualMeasuresMetricUuid extends DataChange { + + public PopulateManualMeasuresMetricUuid(Database db) { + super(db); + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select mm.uuid, m.uuid " + + "from manual_measures mm " + + "join metrics m on mm.metric_id = m.id"); + + massUpdate.update("update manual_measures set metric_uuid = ? where uuid = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, row.getString(2)); + update.setString(2, row.getString(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddIndexOnMetricUuidOfProjectMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddIndexOnMetricUuidOfProjectMeasuresTable.java new file mode 100644 index 00000000000..8f6b8f37404 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddIndexOnMetricUuidOfProjectMeasuresTable.java @@ -0,0 +1,66 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics.projectmeasures; + +import java.sql.Connection; +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.DatabaseUtils; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddIndexOnMetricUuidOfProjectMeasuresTable extends DdlChange { + private static final String TABLE_NAME = "project_measures"; + private static final String INDEX_NAME = "measures_analysis_metric"; + + public AddIndexOnMetricUuidOfProjectMeasuresTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + if (!indexExists()) { + context.execute(new CreateIndexBuilder() + .setUnique(false) + .setTable(TABLE_NAME) + .setName(INDEX_NAME) + .addColumn(newVarcharColumnDefBuilder() + .setColumnName("analysis_uuid") + .setIsNullable(false) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build()) + .addColumn(newVarcharColumnDefBuilder() + .setColumnName("metric_uuid") + .setIsNullable(false) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build()) + .build()); + } + } + + private boolean indexExists() throws SQLException { + try (Connection connection = getDatabase().getDataSource().getConnection()) { + return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); + } + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddMetricUuidColumnToProjectMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddMetricUuidColumnToProjectMeasures.java new file mode 100644 index 00000000000..56c48c7c145 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddMetricUuidColumnToProjectMeasures.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics.projectmeasures; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddMetricUuidColumnToProjectMeasures extends DdlChange { + private static final String TABLE = "project_measures"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("metric_uuid") + .setIsNullable(true) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public AddMetricUuidColumnToProjectMeasures(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddColumnsBuilder(getDialect(), TABLE) + .addColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DropIndexOnMetricIdOfProjectMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DropIndexOnMetricIdOfProjectMeasuresTable.java new file mode 100644 index 00000000000..7c632957917 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DropIndexOnMetricIdOfProjectMeasuresTable.java @@ -0,0 +1,52 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics.projectmeasures; + +import java.sql.Connection; +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.DatabaseUtils; +import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropIndexOnMetricIdOfProjectMeasuresTable extends DdlChange { + private static final String TABLE_NAME = "project_measures"; + private static final String INDEX_NAME = "measures_analysis_metric"; + + public DropIndexOnMetricIdOfProjectMeasuresTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + if (indexExists()) { + context.execute(new DropIndexBuilder(getDialect()) + .setTable(TABLE_NAME) + .setName(INDEX_NAME) + .build()); + } + } + + private boolean indexExists() throws SQLException { + try (Connection connection = getDatabase().getDataSource().getConnection()) { + return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); + } + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DropMetricIdColumnOfProjectMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DropMetricIdColumnOfProjectMeasuresTable.java new file mode 100644 index 00000000000..0f711b435e6 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DropMetricIdColumnOfProjectMeasuresTable.java @@ -0,0 +1,36 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics.projectmeasures; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropMetricIdColumnOfProjectMeasuresTable extends DdlChange { + public DropMetricIdColumnOfProjectMeasuresTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropColumnsBuilder(getDialect(), "project_measures", "metric_id").build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/MakeProjectMeasuresMetricUuidNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/MakeProjectMeasuresMetricUuidNotNullable.java new file mode 100644 index 00000000000..c9f7001ef8a --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/MakeProjectMeasuresMetricUuidNotNullable.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics.projectmeasures; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class MakeProjectMeasuresMetricUuidNotNullable extends DdlChange { + private static final String TABLE = "project_measures"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("metric_uuid") + .setIsNullable(false) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public MakeProjectMeasuresMetricUuidNotNullable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AlterColumnsBuilder(getDialect(), TABLE) + .updateColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/PopulateProjectMeasuresMetricUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/PopulateProjectMeasuresMetricUuid.java new file mode 100644 index 00000000000..ccf76bf519e --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/PopulateProjectMeasuresMetricUuid.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics.projectmeasures; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulateProjectMeasuresMetricUuid extends DataChange { + + public PopulateProjectMeasuresMetricUuid(Database db) { + super(db); + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select pm.uuid, m.uuid " + + "from project_measures pm " + + "join metrics m on pm.metric_id = m.id"); + + massUpdate.update("update project_measures set metric_uuid = ? where uuid = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, row.getString(2)); + update.setString(2, row.getString(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/AddMetricUuidColumnToQualityGateConditions.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/AddMetricUuidColumnToQualityGateConditions.java new file mode 100644 index 00000000000..4ad5260a62e --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/AddMetricUuidColumnToQualityGateConditions.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics.qualitygateconditions; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddMetricUuidColumnToQualityGateConditions extends DdlChange { + private static final String TABLE = "quality_gate_conditions"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("metric_uuid") + .setIsNullable(true) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public AddMetricUuidColumnToQualityGateConditions(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddColumnsBuilder(getDialect(), TABLE) + .addColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/DropMetricIdColumnOfQualityGateConditionsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/DropMetricIdColumnOfQualityGateConditionsTable.java new file mode 100644 index 00000000000..3b29c1c4d44 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/DropMetricIdColumnOfQualityGateConditionsTable.java @@ -0,0 +1,36 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics.qualitygateconditions; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropMetricIdColumnOfQualityGateConditionsTable extends DdlChange { + public DropMetricIdColumnOfQualityGateConditionsTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropColumnsBuilder(getDialect(), "quality_gate_conditions", "metric_id").build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/MakeQualityGateConditionsMetricUuidNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/MakeQualityGateConditionsMetricUuidNotNullable.java new file mode 100644 index 00000000000..6cd72c5fd29 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/MakeQualityGateConditionsMetricUuidNotNullable.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics.qualitygateconditions; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class MakeQualityGateConditionsMetricUuidNotNullable extends DdlChange { + private static final String TABLE = "quality_gate_conditions"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("metric_uuid") + .setIsNullable(false) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public MakeQualityGateConditionsMetricUuidNotNullable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AlterColumnsBuilder(getDialect(), TABLE) + .updateColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/PopulateQualityGateConditionsMetricUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/PopulateQualityGateConditionsMetricUuid.java new file mode 100644 index 00000000000..0063ebc6c5f --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/PopulateQualityGateConditionsMetricUuid.java @@ -0,0 +1,52 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics.qualitygateconditions; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulateQualityGateConditionsMetricUuid extends DataChange { + + public PopulateQualityGateConditionsMetricUuid(Database db) { + super(db); + } + + @Override + protected void execute(Context context) throws SQLException { + // delete quality gate conditions without a metric + context.prepareUpsert("delete from quality_gate_conditions where metric_id is null").execute(); + + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select qgc.uuid, m.uuid " + + "from quality_gate_conditions qgc " + + "join metrics m on qgc.metric_id = m.id"); + + massUpdate.update("update quality_gate_conditions set metric_uuid = ? where uuid = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, row.getString(2)); + update.setString(2, row.getString(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/AddPrimaryKeyOnUuidColumnOfNotificationTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/AddPrimaryKeyOnUuidColumnOfNotificationTable.java new file mode 100644 index 00000000000..3b543820aaf --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/AddPrimaryKeyOnUuidColumnOfNotificationTable.java @@ -0,0 +1,38 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.notifications; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; + +public class AddPrimaryKeyOnUuidColumnOfNotificationTable extends DdlChange { + + public AddPrimaryKeyOnUuidColumnOfNotificationTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddPrimaryKeyBuilder("notifications", "uuid").build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/AddUuidAndCreatedAtColumnsToNotification.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/AddUuidAndCreatedAtColumnsToNotification.java new file mode 100644 index 00000000000..3b6a0f77070 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/AddUuidAndCreatedAtColumnsToNotification.java @@ -0,0 +1,58 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.notifications; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.BigIntegerColumnDef; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.BigIntegerColumnDef.newBigIntegerColumnDefBuilder; +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddUuidAndCreatedAtColumnsToNotification extends DdlChange { + private static final String TABLE = "notifications"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("uuid") + .setIsNullable(true) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + private static final BigIntegerColumnDef createdAtColumnDefinition = newBigIntegerColumnDefBuilder() + .setColumnName("created_at") + .setIsNullable(true) + .build(); + + public AddUuidAndCreatedAtColumnsToNotification(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddColumnsBuilder(getDialect(), TABLE) + .addColumn(uuidColumnDefinition) + .addColumn(createdAtColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/DropIdColumnOfNotificationTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/DropIdColumnOfNotificationTable.java new file mode 100644 index 00000000000..063feed271e --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/DropIdColumnOfNotificationTable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.notifications; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; + +public class DropIdColumnOfNotificationTable extends DropIdColumn { + private static final String TABLE = "notifications"; + + public DropIdColumnOfNotificationTable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/DropPrimaryKeyOnIdColumnOfNotificationTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/DropPrimaryKeyOnIdColumnOfNotificationTable.java new file mode 100644 index 00000000000..f103794e537 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/DropPrimaryKeyOnIdColumnOfNotificationTable.java @@ -0,0 +1,32 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.notifications; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; + +public class DropPrimaryKeyOnIdColumnOfNotificationTable extends DropPrimaryKeyOnIdColumn { + private static final String TABLE_NAME = "notifications"; + + public DropPrimaryKeyOnIdColumnOfNotificationTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { + super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/MakeNotificationUuidAndCreatedAtColumnsNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/MakeNotificationUuidAndCreatedAtColumnsNotNullable.java new file mode 100644 index 00000000000..5f866a01b67 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/MakeNotificationUuidAndCreatedAtColumnsNotNullable.java @@ -0,0 +1,59 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.notifications; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.BigIntegerColumnDef; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.BigIntegerColumnDef.newBigIntegerColumnDefBuilder; +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class MakeNotificationUuidAndCreatedAtColumnsNotNullable extends DdlChange { + private static final String TABLE = "notifications"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("uuid") + .setIsNullable(false) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + private static final BigIntegerColumnDef createdAtColumnDefinition = newBigIntegerColumnDefBuilder() + .setColumnName("created_at") + .setIsNullable(false) + .build(); + + + public MakeNotificationUuidAndCreatedAtColumnsNotNullable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AlterColumnsBuilder(getDialect(), TABLE) + .updateColumn(uuidColumnDefinition) + .updateColumn(createdAtColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/PopulateNotificationUuidAndCreatedAt.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/PopulateNotificationUuidAndCreatedAt.java new file mode 100644 index 00000000000..9bca79f546d --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/PopulateNotificationUuidAndCreatedAt.java @@ -0,0 +1,60 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.notifications; + +import java.sql.SQLException; +import java.util.concurrent.atomic.AtomicLong; +import org.sonar.api.utils.System2; +import org.sonar.core.util.UuidFactory; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulateNotificationUuidAndCreatedAt extends DataChange { + + private final UuidFactory uuidFactory; + private final System2 system2; + + public PopulateNotificationUuidAndCreatedAt(Database db, UuidFactory uuidFactory, System2 system2) { + super(db); + this.uuidFactory = uuidFactory; + this.system2 = system2; + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select id from notifications where uuid is null order by id asc"); + massUpdate.update("update notifications set uuid = ?, created_at = ? where id = ?"); + + // now - 7 days, to have previous notification in the past + long lastWeek = system2.now() - (1000 * 60 * 60 * 24 * 7); + + AtomicLong cpt = new AtomicLong(0); + massUpdate.execute((row, update) -> { + update.setString(1, uuidFactory.create()); + update.setLong(2, lastWeek + cpt.longValue()); + update.setLong(3, row.getLong(1)); + cpt.addAndGet(1); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/package-info.java new file mode 100644 index 00000000000..f29934418ee --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/package-info.java @@ -0,0 +1,23 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +@ParametersAreNonnullByDefault +package org.sonar.server.platform.db.migration.version.v84; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTable.java new file mode 100644 index 00000000000..02546b6fa3b --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTable.java @@ -0,0 +1,38 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permissiontemplates; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; + +public class AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTable extends DdlChange { + + public AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddPrimaryKeyBuilder("permission_templates", "uuid").build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddUuidColumnToPermissionTemplates.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddUuidColumnToPermissionTemplates.java new file mode 100644 index 00000000000..0de6df2b14d --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddUuidColumnToPermissionTemplates.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permissiontemplates; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.AddUuidColumnToTable; + +public class AddUuidColumnToPermissionTemplates extends AddUuidColumnToTable { + private static final String TABLE_NAME = "permission_templates"; + + public AddUuidColumnToPermissionTemplates(Database db) { + super(db, TABLE_NAME); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropIdColumnOfPermissionTemplatesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropIdColumnOfPermissionTemplatesTable.java new file mode 100644 index 00000000000..89c72bdab70 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropIdColumnOfPermissionTemplatesTable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permissiontemplates; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; + +public class DropIdColumnOfPermissionTemplatesTable extends DropIdColumn { + private static final String TABLE_NAME = "permission_templates"; + + public DropIdColumnOfPermissionTemplatesTable(Database db) { + super(db, TABLE_NAME); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropKeeColumnOfPermissionTemplatesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropKeeColumnOfPermissionTemplatesTable.java new file mode 100644 index 00000000000..473013c5845 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropKeeColumnOfPermissionTemplatesTable.java @@ -0,0 +1,37 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permissiontemplates; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropKeeColumnOfPermissionTemplatesTable extends DdlChange { + + public DropKeeColumnOfPermissionTemplatesTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropColumnsBuilder(getDialect(), "permission_templates", "kee").build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropPrimaryKeyOnIdColumnOfPermissionTemplatesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropPrimaryKeyOnIdColumnOfPermissionTemplatesTable.java new file mode 100644 index 00000000000..dd699378242 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropPrimaryKeyOnIdColumnOfPermissionTemplatesTable.java @@ -0,0 +1,32 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permissiontemplates; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; + +public class DropPrimaryKeyOnIdColumnOfPermissionTemplatesTable extends DropPrimaryKeyOnIdColumn { + private static final String TABLE_NAME = "permission_templates"; + + public DropPrimaryKeyOnIdColumnOfPermissionTemplatesTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { + super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/MakePermissionTemplateUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/MakePermissionTemplateUuidColumnNotNullable.java new file mode 100644 index 00000000000..383a96692dd --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/MakePermissionTemplateUuidColumnNotNullable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permissiontemplates; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.MakeUuidColumnNotNullable; + +public class MakePermissionTemplateUuidColumnNotNullable extends MakeUuidColumnNotNullable { + private static final String TABLE_NAME = "permission_templates"; + + public MakePermissionTemplateUuidColumnNotNullable(Database db) { + super(db, TABLE_NAME); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/PopulatePermissionTemplatesUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/PopulatePermissionTemplatesUuid.java new file mode 100644 index 00000000000..4e9d82ee9ec --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/PopulatePermissionTemplatesUuid.java @@ -0,0 +1,58 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permissiontemplates; + +import java.sql.SQLException; +import org.sonar.core.util.UuidFactory; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulatePermissionTemplatesUuid extends DataChange { + + private UuidFactory uuidFactory; + + public PopulatePermissionTemplatesUuid(Database db, UuidFactory uuidFactory) { + super(db); + this.uuidFactory = uuidFactory; + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select kee from permission_templates where uuid is null"); + massUpdate.update("update permission_templates set uuid = ? where kee = ?"); + + massUpdate.execute((row, update) -> { + String kee = row.getString(1); + String uuid = kee; + + //kee column was declared with 100 char length, so we regenerate if it happened + if (kee.length() > 40) { + uuid = uuidFactory.create(); + } + + update.setString(1, uuid); + update.setString(2, kee); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/AddTemplateUuidColumnToPermTemplatesGroups.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/AddTemplateUuidColumnToPermTemplatesGroups.java new file mode 100644 index 00000000000..9e76ca4cd7d --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/AddTemplateUuidColumnToPermTemplatesGroups.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesgroups; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddTemplateUuidColumnToPermTemplatesGroups extends DdlChange { + private static final String TABLE = "perm_templates_groups"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("template_uuid") + .setIsNullable(true) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public AddTemplateUuidColumnToPermTemplatesGroups(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddColumnsBuilder(getDialect(), TABLE) + .addColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/DropTemplateIdColumnOfPermTemplatesGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/DropTemplateIdColumnOfPermTemplatesGroupsTable.java new file mode 100644 index 00000000000..30f09cc2188 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/DropTemplateIdColumnOfPermTemplatesGroupsTable.java @@ -0,0 +1,37 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesgroups; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropTemplateIdColumnOfPermTemplatesGroupsTable extends DdlChange { + + public DropTemplateIdColumnOfPermTemplatesGroupsTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropColumnsBuilder(getDialect(), "perm_templates_groups", "template_id").build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/MakePermTemplatesGroupsTemplateUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/MakePermTemplatesGroupsTemplateUuidColumnNotNullable.java new file mode 100644 index 00000000000..763be7ed480 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/MakePermTemplatesGroupsTemplateUuidColumnNotNullable.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesgroups; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class MakePermTemplatesGroupsTemplateUuidColumnNotNullable extends DdlChange { + private static final String TABLE = "perm_templates_groups"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("template_uuid") + .setIsNullable(false) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public MakePermTemplatesGroupsTemplateUuidColumnNotNullable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AlterColumnsBuilder(getDialect(), TABLE) + .updateColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/PopulatePermTemplatesGroupsTemplateUuidColumn.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/PopulatePermTemplatesGroupsTemplateUuidColumn.java new file mode 100644 index 00000000000..28fc16028cb --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/PopulatePermTemplatesGroupsTemplateUuidColumn.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesgroups; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulatePermTemplatesGroupsTemplateUuidColumn extends DataChange { + + public PopulatePermTemplatesGroupsTemplateUuidColumn(Database db) { + super(db); + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select ptg.uuid, pt.uuid " + + "from perm_templates_groups ptg " + + "join permission_templates pt on ptg.template_id = pt.id " + + "where ptg.template_uuid is null"); + massUpdate.update("update perm_templates_groups set template_uuid = ? where uuid = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, row.getString(2)); + update.setString(2, row.getString(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/AddTemplateUuidColumnToPermTemplatesUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/AddTemplateUuidColumnToPermTemplatesUsers.java new file mode 100644 index 00000000000..b394c98856b --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/AddTemplateUuidColumnToPermTemplatesUsers.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesusers; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddTemplateUuidColumnToPermTemplatesUsers extends DdlChange { + private static final String TABLE = "perm_templates_users"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("template_uuid") + .setIsNullable(true) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public AddTemplateUuidColumnToPermTemplatesUsers(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddColumnsBuilder(getDialect(), TABLE) + .addColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/DropTemplateIdColumnOfPermTemplatesUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/DropTemplateIdColumnOfPermTemplatesUsersTable.java new file mode 100644 index 00000000000..80d75345cfc --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/DropTemplateIdColumnOfPermTemplatesUsersTable.java @@ -0,0 +1,37 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesusers; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropTemplateIdColumnOfPermTemplatesUsersTable extends DdlChange { + + public DropTemplateIdColumnOfPermTemplatesUsersTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropColumnsBuilder(getDialect(), "perm_templates_users", "template_id").build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/MakePermTemplatesUsersTemplateUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/MakePermTemplatesUsersTemplateUuidColumnNotNullable.java new file mode 100644 index 00000000000..55fe045e7c8 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/MakePermTemplatesUsersTemplateUuidColumnNotNullable.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesusers; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class MakePermTemplatesUsersTemplateUuidColumnNotNullable extends DdlChange { + private static final String TABLE = "perm_templates_users"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("template_uuid") + .setIsNullable(false) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public MakePermTemplatesUsersTemplateUuidColumnNotNullable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AlterColumnsBuilder(getDialect(), TABLE) + .updateColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/PopulatePermTemplatesUsersTemplateUuidColumn.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/PopulatePermTemplatesUsersTemplateUuidColumn.java new file mode 100644 index 00000000000..853c4d3540c --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/PopulatePermTemplatesUsersTemplateUuidColumn.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesusers; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulatePermTemplatesUsersTemplateUuidColumn extends DataChange { + + public PopulatePermTemplatesUsersTemplateUuidColumn(Database db) { + super(db); + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select ptu.uuid, pt.uuid " + + "from perm_templates_users ptu " + + "join permission_templates pt on ptu.template_id = pt.id " + + "where ptu.template_uuid is null"); + massUpdate.update("update perm_templates_users set template_uuid = ? where uuid = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, row.getString(2)); + update.setString(2, row.getString(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/AddTemplateUuidColumnToPermTplCharacteristics.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/AddTemplateUuidColumnToPermTplCharacteristics.java new file mode 100644 index 00000000000..7517468b12e --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/AddTemplateUuidColumnToPermTplCharacteristics.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtplcharacteristics; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddTemplateUuidColumnToPermTplCharacteristics extends DdlChange { + private static final String TABLE = "perm_tpl_characteristics"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("template_uuid") + .setIsNullable(true) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public AddTemplateUuidColumnToPermTplCharacteristics(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddColumnsBuilder(getDialect(), TABLE) + .addColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTable.java new file mode 100644 index 00000000000..ba455bb4651 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTable.java @@ -0,0 +1,67 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtplcharacteristics; + +import java.sql.Connection; +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.DatabaseUtils; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTable extends DdlChange { + private static final String TABLE_NAME = "perm_tpl_characteristics"; + private static final String INDEX_NAME = "uniq_perm_tpl_charac"; + + public AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + if (!indexExists()) { + context.execute(new CreateIndexBuilder() + .setUnique(true) + .setTable(TABLE_NAME) + .setName(INDEX_NAME) + .addColumn(newVarcharColumnDefBuilder() + .setColumnName("template_uuid") + .setIsNullable(false) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build()) + .addColumn(newVarcharColumnDefBuilder() + .setColumnName("permission_key") + .setIsNullable(false) + .setLimit(64) + .build()) + .build()); + } + + } + + private boolean indexExists() throws SQLException { + try (Connection connection = getDatabase().getDataSource().getConnection()) { + return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); + } + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/DropTemplateIdColumnOfPermTplCharacteristicsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/DropTemplateIdColumnOfPermTplCharacteristicsTable.java new file mode 100644 index 00000000000..8453e2fe1ed --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/DropTemplateIdColumnOfPermTplCharacteristicsTable.java @@ -0,0 +1,37 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtplcharacteristics; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropTemplateIdColumnOfPermTplCharacteristicsTable extends DdlChange { + + public DropTemplateIdColumnOfPermTplCharacteristicsTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropColumnsBuilder(getDialect(), "perm_tpl_characteristics", "template_id").build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTable.java new file mode 100644 index 00000000000..e1797a97ea3 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTable.java @@ -0,0 +1,52 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtplcharacteristics; + +import java.sql.Connection; +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.DatabaseUtils; +import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTable extends DdlChange { + private static final String TABLE_NAME = "perm_tpl_characteristics"; + private static final String INDEX_NAME = "uniq_perm_tpl_charac"; + + public DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + if (indexExists()) { + context.execute(new DropIndexBuilder(getDialect()) + .setTable(TABLE_NAME) + .setName(INDEX_NAME) + .build()); + } + } + + private boolean indexExists() throws SQLException { + try (Connection connection = getDatabase().getDataSource().getConnection()) { + return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); + } + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/MakePermTplCharacteristicsTemplateUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/MakePermTplCharacteristicsTemplateUuidColumnNotNullable.java new file mode 100644 index 00000000000..7cde0765930 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/MakePermTplCharacteristicsTemplateUuidColumnNotNullable.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtplcharacteristics; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class MakePermTplCharacteristicsTemplateUuidColumnNotNullable extends DdlChange { + private static final String TABLE = "perm_tpl_characteristics"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("template_uuid") + .setIsNullable(false) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public MakePermTplCharacteristicsTemplateUuidColumnNotNullable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AlterColumnsBuilder(getDialect(), TABLE) + .updateColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/PopulatePermTplCharacteristicsTemplateUuidColumn.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/PopulatePermTplCharacteristicsTemplateUuidColumn.java new file mode 100644 index 00000000000..778e1e33819 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/PopulatePermTplCharacteristicsTemplateUuidColumn.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtplcharacteristics; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulatePermTplCharacteristicsTemplateUuidColumn extends DataChange { + + public PopulatePermTplCharacteristicsTemplateUuidColumn(Database db) { + super(db); + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select ptc.uuid, pt.uuid " + + "from perm_tpl_characteristics ptc " + + "join permission_templates pt on ptc.template_id = pt.id " + + "where ptc.template_uuid is null"); + massUpdate.update("update perm_tpl_characteristics set template_uuid = ? where uuid = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, row.getString(2)); + update.setString(2, row.getString(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTable.java new file mode 100644 index 00000000000..0aaf0b182ba --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTable.java @@ -0,0 +1,38 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permtemplatesgroups; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; + +public class AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTable extends DdlChange { + + public AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddPrimaryKeyBuilder("perm_templates_groups", "uuid").build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddUuidColumnToPermTemplatesGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddUuidColumnToPermTemplatesGroupsTable.java new file mode 100644 index 00000000000..894d3b88663 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddUuidColumnToPermTemplatesGroupsTable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permtemplatesgroups; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.AddUuidColumnToTable; + +public class AddUuidColumnToPermTemplatesGroupsTable extends AddUuidColumnToTable { + private static final String TABLE = "perm_templates_groups"; + + public AddUuidColumnToPermTemplatesGroupsTable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropIdColumnOfPermTemplatesGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropIdColumnOfPermTemplatesGroupsTable.java new file mode 100644 index 00000000000..060521decdd --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropIdColumnOfPermTemplatesGroupsTable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permtemplatesgroups; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; + +public class DropIdColumnOfPermTemplatesGroupsTable extends DropIdColumn { + private static final String TABLE = "perm_templates_groups"; + + public DropIdColumnOfPermTemplatesGroupsTable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTable.java new file mode 100644 index 00000000000..0411a6c8ad0 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTable.java @@ -0,0 +1,32 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permtemplatesgroups; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; + +public class DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTable extends DropPrimaryKeyOnIdColumn { + private static final String TABLE_NAME = "perm_templates_groups"; + + public DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { + super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/MakePermTemplatesGroupsUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/MakePermTemplatesGroupsUuidColumnNotNullable.java new file mode 100644 index 00000000000..ca7867c7421 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/MakePermTemplatesGroupsUuidColumnNotNullable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permtemplatesgroups; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.MakeUuidColumnNotNullable; + +public class MakePermTemplatesGroupsUuidColumnNotNullable extends MakeUuidColumnNotNullable { + private static final String TABLE = "perm_templates_groups"; + + public MakePermTemplatesGroupsUuidColumnNotNullable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/PopulatePermTemplatesGroupsUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/PopulatePermTemplatesGroupsUuid.java new file mode 100644 index 00000000000..8bf86f8f47d --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/PopulatePermTemplatesGroupsUuid.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permtemplatesgroups; + +import java.sql.SQLException; +import org.sonar.core.util.UuidFactory; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulatePermTemplatesGroupsUuid extends DataChange { + + private final UuidFactory uuidFactory; + + public PopulatePermTemplatesGroupsUuid(Database db, UuidFactory uuidFactory) { + super(db); + this.uuidFactory = uuidFactory; + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select id from perm_templates_groups where uuid is null order by id asc"); + massUpdate.update("update perm_templates_groups set uuid = ? where id = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, uuidFactory.create()); + update.setLong(2, row.getLong(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTable.java new file mode 100644 index 00000000000..baf679d9b42 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTable.java @@ -0,0 +1,38 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permtemplatesusers; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; + +public class AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTable extends DdlChange { + + public AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddPrimaryKeyBuilder("perm_templates_users", "uuid").build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddUuidColumnToPermTemplatesUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddUuidColumnToPermTemplatesUsersTable.java new file mode 100644 index 00000000000..ac402e1a711 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddUuidColumnToPermTemplatesUsersTable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permtemplatesusers; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.AddUuidColumnToTable; + +public class AddUuidColumnToPermTemplatesUsersTable extends AddUuidColumnToTable { + private static final String TABLE = "perm_templates_users"; + + public AddUuidColumnToPermTemplatesUsersTable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropIdColumnOfPermTemplatesUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropIdColumnOfPermTemplatesUsersTable.java new file mode 100644 index 00000000000..5bebd035f80 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropIdColumnOfPermTemplatesUsersTable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permtemplatesusers; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; + +public class DropIdColumnOfPermTemplatesUsersTable extends DropIdColumn { + private static final String TABLE = "perm_templates_users"; + + public DropIdColumnOfPermTemplatesUsersTable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTable.java new file mode 100644 index 00000000000..209d31fe87c --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTable.java @@ -0,0 +1,32 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permtemplatesusers; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; + +public class DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTable extends DropPrimaryKeyOnIdColumn { + private static final String TABLE_NAME = "perm_templates_users"; + + public DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { + super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/MakePermTemplatesUsersUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/MakePermTemplatesUsersUuidColumnNotNullable.java new file mode 100644 index 00000000000..6f5bd00c630 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/MakePermTemplatesUsersUuidColumnNotNullable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permtemplatesusers; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.MakeUuidColumnNotNullable; + +public class MakePermTemplatesUsersUuidColumnNotNullable extends MakeUuidColumnNotNullable { + private static final String TABLE = "perm_templates_users"; + + public MakePermTemplatesUsersUuidColumnNotNullable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/PopulatePermTemplatesUsersUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/PopulatePermTemplatesUsersUuid.java new file mode 100644 index 00000000000..d56b6fe2652 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/PopulatePermTemplatesUsersUuid.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permtemplatesusers; + +import java.sql.SQLException; +import org.sonar.core.util.UuidFactory; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulatePermTemplatesUsersUuid extends DataChange { + + private final UuidFactory uuidFactory; + + public PopulatePermTemplatesUsersUuid(Database db, UuidFactory uuidFactory) { + super(db); + this.uuidFactory = uuidFactory; + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select id from perm_templates_users where uuid is null order by id asc"); + massUpdate.update("update perm_templates_users set uuid = ? where id = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, uuidFactory.create()); + update.setLong(2, row.getLong(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTable.java new file mode 100644 index 00000000000..348635f10b3 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTable.java @@ -0,0 +1,38 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permtplcharacteristics; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; + +public class AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTable extends DdlChange { + + public AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddPrimaryKeyBuilder("perm_tpl_characteristics", "uuid").build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddUuidColumnToPermTplCharacteristicsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddUuidColumnToPermTplCharacteristicsTable.java new file mode 100644 index 00000000000..283ae673b4a --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddUuidColumnToPermTplCharacteristicsTable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permtplcharacteristics; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.AddUuidColumnToTable; + +public class AddUuidColumnToPermTplCharacteristicsTable extends AddUuidColumnToTable { + private static final String TABLE = "perm_tpl_characteristics"; + + public AddUuidColumnToPermTplCharacteristicsTable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropIdColumnOfPermTplCharacteristicsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropIdColumnOfPermTplCharacteristicsTable.java new file mode 100644 index 00000000000..98ed0a72d22 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropIdColumnOfPermTplCharacteristicsTable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permtplcharacteristics; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; + +public class DropIdColumnOfPermTplCharacteristicsTable extends DropIdColumn { + private static final String TABLE = "perm_tpl_characteristics"; + + public DropIdColumnOfPermTplCharacteristicsTable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTable.java new file mode 100644 index 00000000000..96375daccbe --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTable.java @@ -0,0 +1,32 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permtplcharacteristics; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; + +public class DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTable extends DropPrimaryKeyOnIdColumn { + private static final String TABLE_NAME = "perm_tpl_characteristics"; + + public DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { + super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/MakePermTplCharacteristicsUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/MakePermTplCharacteristicsUuidColumnNotNullable.java new file mode 100644 index 00000000000..76373c247e6 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/MakePermTplCharacteristicsUuidColumnNotNullable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permtplcharacteristics; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.MakeUuidColumnNotNullable; + +public class MakePermTplCharacteristicsUuidColumnNotNullable extends MakeUuidColumnNotNullable { + private static final String TABLE = "perm_tpl_characteristics"; + + public MakePermTplCharacteristicsUuidColumnNotNullable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/PopulatePermTplCharacteristicsUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/PopulatePermTplCharacteristicsUuid.java new file mode 100644 index 00000000000..d688c947c3f --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/PopulatePermTplCharacteristicsUuid.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permtplcharacteristics; + +import java.sql.SQLException; +import org.sonar.core.util.UuidFactory; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulatePermTplCharacteristicsUuid extends DataChange { + + private final UuidFactory uuidFactory; + + public PopulatePermTplCharacteristicsUuid(Database db, UuidFactory uuidFactory) { + super(db); + this.uuidFactory = uuidFactory; + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select id from perm_tpl_characteristics where uuid is null order by id asc"); + massUpdate.update("update perm_tpl_characteristics set uuid = ? where id = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, uuidFactory.create()); + update.setLong(2, row.getLong(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddPrimaryKeyOnUuidColumnOfProjectMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddPrimaryKeyOnUuidColumnOfProjectMeasuresTable.java new file mode 100644 index 00000000000..312c9bd86ed --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddPrimaryKeyOnUuidColumnOfProjectMeasuresTable.java @@ -0,0 +1,38 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.projectmeasures; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; + +public class AddPrimaryKeyOnUuidColumnOfProjectMeasuresTable extends DdlChange { + + public AddPrimaryKeyOnUuidColumnOfProjectMeasuresTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddPrimaryKeyBuilder("project_measures", "uuid").build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddUuidColumnToProjectMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddUuidColumnToProjectMeasures.java new file mode 100644 index 00000000000..38e16b37db6 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddUuidColumnToProjectMeasures.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.projectmeasures; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.AddUuidColumnToTable; + +public class AddUuidColumnToProjectMeasures extends AddUuidColumnToTable { + private static final String TABLE = "project_measures"; + + public AddUuidColumnToProjectMeasures(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropIdColumnOfProjectMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropIdColumnOfProjectMeasuresTable.java new file mode 100644 index 00000000000..b5a3ad0b55b --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropIdColumnOfProjectMeasuresTable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.projectmeasures; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; + +public class DropIdColumnOfProjectMeasuresTable extends DropIdColumn { + private static final String TABLE = "project_measures"; + + public DropIdColumnOfProjectMeasuresTable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropPrimaryKeyOnIdColumnOfProjectMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropPrimaryKeyOnIdColumnOfProjectMeasuresTable.java new file mode 100644 index 00000000000..f37523647bc --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropPrimaryKeyOnIdColumnOfProjectMeasuresTable.java @@ -0,0 +1,32 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.projectmeasures; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; + +public class DropPrimaryKeyOnIdColumnOfProjectMeasuresTable extends DropPrimaryKeyOnIdColumn { + private static final String TABLE_NAME = "project_measures"; + + public DropPrimaryKeyOnIdColumnOfProjectMeasuresTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { + super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/MakeProjectMeasuresUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/MakeProjectMeasuresUuidColumnNotNullable.java new file mode 100644 index 00000000000..7eb5c5a7609 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/MakeProjectMeasuresUuidColumnNotNullable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.projectmeasures; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.MakeUuidColumnNotNullable; + +public class MakeProjectMeasuresUuidColumnNotNullable extends MakeUuidColumnNotNullable { + private static final String TABLE = "project_measures"; + + public MakeProjectMeasuresUuidColumnNotNullable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/PopulateProjectMeasureUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/PopulateProjectMeasureUuid.java new file mode 100644 index 00000000000..2d684cf6a21 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/PopulateProjectMeasureUuid.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.projectmeasures; + +import java.sql.SQLException; +import org.sonar.core.util.UuidFactory; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulateProjectMeasureUuid extends DataChange { + + private final UuidFactory uuidFactory; + + public PopulateProjectMeasureUuid(Database db, UuidFactory uuidFactory) { + super(db); + this.uuidFactory = uuidFactory; + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select id from project_measures where uuid is null"); + massUpdate.update("update project_measures set uuid = ? where id = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, uuidFactory.create()); + update.setLong(2, row.getLong(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTable.java new file mode 100644 index 00000000000..c47e26cb3d0 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTable.java @@ -0,0 +1,38 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.projectqprofiles; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; + +public class AddPrimaryKeyOnUuidColumnOfProjectQProfilesTable extends DdlChange { + + public AddPrimaryKeyOnUuidColumnOfProjectQProfilesTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddPrimaryKeyBuilder("project_qprofiles", "uuid").build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddUuidColumnToProjectQProfilesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddUuidColumnToProjectQProfilesTable.java new file mode 100644 index 00000000000..83107dca442 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddUuidColumnToProjectQProfilesTable.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.projectqprofiles; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddUuidColumnToProjectQProfilesTable extends DdlChange { + private static final String TABLE = "project_qprofiles"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("uuid") + .setIsNullable(true) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public AddUuidColumnToProjectQProfilesTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddColumnsBuilder(getDialect(), TABLE) + .addColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropIdColumnOfProjectQProfilesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropIdColumnOfProjectQProfilesTable.java new file mode 100644 index 00000000000..b6792457e26 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropIdColumnOfProjectQProfilesTable.java @@ -0,0 +1,41 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.projectqprofiles; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropIdColumnOfProjectQProfilesTable extends DdlChange { + + private Database db; + + public DropIdColumnOfProjectQProfilesTable(Database db) { + super(db); + this.db = db; + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropColumnsBuilder(db.getDialect(), "project_qprofiles", "id").build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTable.java new file mode 100644 index 00000000000..fb86b8b1df8 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTable.java @@ -0,0 +1,41 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.projectqprofiles; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; + +public class DropPrimaryKeyOnIdColumnOfProjectQProfilesTable extends DdlChange { + + private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator; + + public DropPrimaryKeyOnIdColumnOfProjectQProfilesTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { + super(db); + this.dropPrimaryKeySqlGenerator = dropPrimaryKeySqlGenerator; + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(dropPrimaryKeySqlGenerator.generate("project_qprofiles", "id", true)); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/MakeProjectQProfilesUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/MakeProjectQProfilesUuidColumnNotNullable.java new file mode 100644 index 00000000000..b0e837835e1 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/MakeProjectQProfilesUuidColumnNotNullable.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.projectqprofiles; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class MakeProjectQProfilesUuidColumnNotNullable extends DdlChange { + private static final String TABLE = "project_qprofiles"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("uuid") + .setIsNullable(false) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public MakeProjectQProfilesUuidColumnNotNullable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AlterColumnsBuilder(getDialect(), TABLE) + .updateColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/PopulateProjectQProfilesUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/PopulateProjectQProfilesUuid.java new file mode 100644 index 00000000000..07e3fdf3837 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/PopulateProjectQProfilesUuid.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.projectqprofiles; + +import java.sql.SQLException; +import org.sonar.core.util.UuidFactory; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulateProjectQProfilesUuid extends DataChange { + + private final UuidFactory uuidFactory; + + public PopulateProjectQProfilesUuid(Database db, UuidFactory uuidFactory) { + super(db); + this.uuidFactory = uuidFactory; + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select id from project_qprofiles where uuid is null"); + massUpdate.update("update project_qprofiles set uuid = ? where id = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, uuidFactory.create()); + update.setLong(2, row.getLong(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/AddPrimaryKeyOnUuidColumnOfPropertiesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/AddPrimaryKeyOnUuidColumnOfPropertiesTable.java new file mode 100644 index 00000000000..d86eb0578e9 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/AddPrimaryKeyOnUuidColumnOfPropertiesTable.java @@ -0,0 +1,38 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.properties; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; + +public class AddPrimaryKeyOnUuidColumnOfPropertiesTable extends DdlChange { + + public AddPrimaryKeyOnUuidColumnOfPropertiesTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddPrimaryKeyBuilder("properties", "uuid").build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/AddUuidColumnToProperties.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/AddUuidColumnToProperties.java new file mode 100644 index 00000000000..e8db0c47cc7 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/AddUuidColumnToProperties.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.properties; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.AddUuidColumnToTable; + +public class AddUuidColumnToProperties extends AddUuidColumnToTable { + private static final String TABLE_NAME = "properties"; + + public AddUuidColumnToProperties(Database db) { + super(db, TABLE_NAME); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/DropIdColumnOfPropertiesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/DropIdColumnOfPropertiesTable.java new file mode 100644 index 00000000000..680b7c2f8f6 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/DropIdColumnOfPropertiesTable.java @@ -0,0 +1,37 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.properties; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropIdColumnOfPropertiesTable extends DdlChange { + + public DropIdColumnOfPropertiesTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropColumnsBuilder(getDialect(), "properties", "id").build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/DropPrimaryKeyOnIdColumnOfPropertiesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/DropPrimaryKeyOnIdColumnOfPropertiesTable.java new file mode 100644 index 00000000000..53d1f0fa259 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/DropPrimaryKeyOnIdColumnOfPropertiesTable.java @@ -0,0 +1,34 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.properties; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; + +public class DropPrimaryKeyOnIdColumnOfPropertiesTable extends DropPrimaryKeyOnIdColumn { + + private static final String TABLE_NAME = "properties"; + + public DropPrimaryKeyOnIdColumnOfPropertiesTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { + super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/MakePropertiesUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/MakePropertiesUuidColumnNotNullable.java new file mode 100644 index 00000000000..ee1e59521f4 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/MakePropertiesUuidColumnNotNullable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.properties; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.MakeUuidColumnNotNullable; + +public class MakePropertiesUuidColumnNotNullable extends MakeUuidColumnNotNullable { + private static final String TABLE_NAME = "properties"; + + public MakePropertiesUuidColumnNotNullable(Database db) { + super(db, TABLE_NAME); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/PopulatePropertiesUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/PopulatePropertiesUuid.java new file mode 100644 index 00000000000..6498f329b51 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/PopulatePropertiesUuid.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.properties; + +import java.sql.SQLException; +import org.sonar.core.util.UuidFactory; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulatePropertiesUuid extends DataChange { + + private final UuidFactory uuidFactory; + + public PopulatePropertiesUuid(Database db, UuidFactory uuidFactory) { + super(db); + this.uuidFactory = uuidFactory; + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select id from properties where uuid is null order by id asc"); + massUpdate.update("update properties set uuid = ? where id = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, uuidFactory.create()); + update.setLong(2, row.getLong(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTable.java new file mode 100644 index 00000000000..7cb786d5d53 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTable.java @@ -0,0 +1,38 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.qualitygateconditions; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; + +public class AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTable extends DdlChange { + + public AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddPrimaryKeyBuilder("quality_gate_conditions", "uuid").build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddUuidColumnToQualityGateConditionsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddUuidColumnToQualityGateConditionsTable.java new file mode 100644 index 00000000000..0ecefb1abce --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddUuidColumnToQualityGateConditionsTable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.qualitygateconditions; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.AddUuidColumnToTable; + +public class AddUuidColumnToQualityGateConditionsTable extends AddUuidColumnToTable { + private static final String TABLE = "quality_gate_conditions"; + + public AddUuidColumnToQualityGateConditionsTable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropIdColumnOfQualityGateConditionsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropIdColumnOfQualityGateConditionsTable.java new file mode 100644 index 00000000000..dc4d81ae5f6 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropIdColumnOfQualityGateConditionsTable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.qualitygateconditions; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; + +public class DropIdColumnOfQualityGateConditionsTable extends DropIdColumn { + private static final String TABLE = "quality_gate_conditions"; + + public DropIdColumnOfQualityGateConditionsTable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropPrimaryKeyOnIdColumnOfQualityGateConditionsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropPrimaryKeyOnIdColumnOfQualityGateConditionsTable.java new file mode 100644 index 00000000000..5008c4068a8 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropPrimaryKeyOnIdColumnOfQualityGateConditionsTable.java @@ -0,0 +1,32 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.qualitygateconditions; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; + +public class DropPrimaryKeyOnIdColumnOfQualityGateConditionsTable extends DropPrimaryKeyOnIdColumn { + private static final String TABLE_NAME = "quality_gate_conditions"; + + public DropPrimaryKeyOnIdColumnOfQualityGateConditionsTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { + super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/MakeQualityGateConditionsUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/MakeQualityGateConditionsUuidColumnNotNullable.java new file mode 100644 index 00000000000..3203f5c624d --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/MakeQualityGateConditionsUuidColumnNotNullable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.qualitygateconditions; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.MakeUuidColumnNotNullable; + +public class MakeQualityGateConditionsUuidColumnNotNullable extends MakeUuidColumnNotNullable { + private static final String TABLE = "quality_gate_conditions"; + + public MakeQualityGateConditionsUuidColumnNotNullable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/PopulateQualityGateConditionsUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/PopulateQualityGateConditionsUuid.java new file mode 100644 index 00000000000..06561eb6e48 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/PopulateQualityGateConditionsUuid.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.qualitygateconditions; + +import java.sql.SQLException; +import org.sonar.core.util.UuidFactory; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulateQualityGateConditionsUuid extends DataChange { + + private final UuidFactory uuidFactory; + + public PopulateQualityGateConditionsUuid(Database db, UuidFactory uuidFactory) { + super(db); + this.uuidFactory = uuidFactory; + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select id from quality_gate_conditions where uuid is null order by id asc"); + massUpdate.update("update quality_gate_conditions set uuid = ? where id = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, uuidFactory.create()); + update.setLong(2, row.getLong(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddPrimaryKeyOnUuidColumnOfQGatesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddPrimaryKeyOnUuidColumnOfQGatesTable.java new file mode 100644 index 00000000000..13881446536 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddPrimaryKeyOnUuidColumnOfQGatesTable.java @@ -0,0 +1,38 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.qualitygates; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; + +public class AddPrimaryKeyOnUuidColumnOfQGatesTable extends DdlChange { + + public AddPrimaryKeyOnUuidColumnOfQGatesTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddPrimaryKeyBuilder("quality_gates", "uuid").build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddQGateUuidColumnForQGateConditions.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddQGateUuidColumnForQGateConditions.java new file mode 100644 index 00000000000..2c97db2b708 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddQGateUuidColumnForQGateConditions.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.qualitygates; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddQGateUuidColumnForQGateConditions extends DdlChange { + private static final String TABLE = "quality_gate_conditions"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("qgate_uuid") + .setIsNullable(true) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public AddQGateUuidColumnForQGateConditions(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddColumnsBuilder(getDialect(), TABLE) + .addColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropIdColumnOfQGateTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropIdColumnOfQGateTable.java new file mode 100644 index 00000000000..97a36ae4c6a --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropIdColumnOfQGateTable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.qualitygates; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; + +public class DropIdColumnOfQGateTable extends DropIdColumn { + private static final String TABLE = "quality_gates"; + + public DropIdColumnOfQGateTable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropOrphansQGateConditions.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropOrphansQGateConditions.java new file mode 100644 index 00000000000..cbd61e6e096 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropOrphansQGateConditions.java @@ -0,0 +1,45 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.qualitygates; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class DropOrphansQGateConditions extends DataChange { + + public DropOrphansQGateConditions(Database db) { + super(db); + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select uuid from quality_gate_conditions where qgate_uuid is null"); + massUpdate.update("delete from quality_gate_conditions where uuid = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, row.getString(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropPrimaryKeyOnIdColumnOfQGatesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropPrimaryKeyOnIdColumnOfQGatesTable.java new file mode 100644 index 00000000000..d163d436f74 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropPrimaryKeyOnIdColumnOfQGatesTable.java @@ -0,0 +1,34 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.qualitygates; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; + +public class DropPrimaryKeyOnIdColumnOfQGatesTable extends DropPrimaryKeyOnIdColumn { + + private static final String TABLE_NAME = "quality_gates"; + + public DropPrimaryKeyOnIdColumnOfQGatesTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { + super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropQGateIdColumnForQGateConditions.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropQGateIdColumnForQGateConditions.java new file mode 100644 index 00000000000..80069b91140 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropQGateIdColumnForQGateConditions.java @@ -0,0 +1,41 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.qualitygates; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropQGateIdColumnForQGateConditions extends DdlChange { + + private Database db; + + public DropQGateIdColumnForQGateConditions(Database db) { + super(db); + this.db = db; + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropColumnsBuilder(db.getDialect(), "quality_gate_conditions", "qgate_id").build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropUniqueIndexOnUuidColumnOfQualityGatesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropUniqueIndexOnUuidColumnOfQualityGatesTable.java new file mode 100644 index 00000000000..6e51337ef03 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropUniqueIndexOnUuidColumnOfQualityGatesTable.java @@ -0,0 +1,40 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.qualitygates; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropUniqueIndexOnUuidColumnOfQualityGatesTable extends DdlChange { + + public DropUniqueIndexOnUuidColumnOfQualityGatesTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropIndexBuilder(getDialect()) + .setTable("quality_gates") + .setName("uniq_quality_gates_uuid") + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/MakeQGateUuidColumnNotNullableForQGateConditions.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/MakeQGateUuidColumnNotNullableForQGateConditions.java new file mode 100644 index 00000000000..eeaa41dc341 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/MakeQGateUuidColumnNotNullableForQGateConditions.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.qualitygates; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class MakeQGateUuidColumnNotNullableForQGateConditions extends DdlChange { + private static final String TABLE = "quality_gate_conditions"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("qgate_uuid") + .setIsNullable(false) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public MakeQGateUuidColumnNotNullableForQGateConditions(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AlterColumnsBuilder(getDialect(), TABLE) + .updateColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/PopulateQGateUuidColumnForQGateConditions.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/PopulateQGateUuidColumnForQGateConditions.java new file mode 100644 index 00000000000..3b33aa2e3a1 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/PopulateQGateUuidColumnForQGateConditions.java @@ -0,0 +1,46 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.qualitygates; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulateQGateUuidColumnForQGateConditions extends DataChange { + + public PopulateQGateUuidColumnForQGateConditions(Database db) { + super(db); + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select uuid, id from quality_gates order by id asc"); + massUpdate.update("update quality_gate_conditions set qgate_uuid = ? where qgate_id = ? and qgate_uuid is null"); + + massUpdate.execute((row, update) -> { + update.setString(1, row.getString(1)); + update.setLong(2, row.getLong(2)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/AddPrimaryKeyOnUuidColumnOfRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/AddPrimaryKeyOnUuidColumnOfRulesTable.java new file mode 100644 index 00000000000..2b4c6b6aefc --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/AddPrimaryKeyOnUuidColumnOfRulesTable.java @@ -0,0 +1,38 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; + +public class AddPrimaryKeyOnUuidColumnOfRulesTable extends DdlChange { + + public AddPrimaryKeyOnUuidColumnOfRulesTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddPrimaryKeyBuilder("rules", "uuid").build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/AddUuidAndTemplateUuidColumnsToRules.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/AddUuidAndTemplateUuidColumnsToRules.java new file mode 100644 index 00000000000..0e84d437b7b --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/AddUuidAndTemplateUuidColumnsToRules.java @@ -0,0 +1,58 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddUuidAndTemplateUuidColumnsToRules extends DdlChange { + private static final String TABLE = "rules"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("uuid") + .setIsNullable(true) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + private static final VarcharColumnDef templateUuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("template_uuid") + .setIsNullable(true) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public AddUuidAndTemplateUuidColumnsToRules(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddColumnsBuilder(getDialect(), TABLE) + .addColumn(uuidColumnDefinition) + .addColumn(templateUuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/DropIdColumnOfRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/DropIdColumnOfRulesTable.java new file mode 100644 index 00000000000..43e9d9e6cc2 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/DropIdColumnOfRulesTable.java @@ -0,0 +1,37 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropIdColumnOfRulesTable extends DdlChange { + + public DropIdColumnOfRulesTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropColumnsBuilder(getDialect(), "rules", "id").build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/DropPrimaryKeyOnIdColumnOfRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/DropPrimaryKeyOnIdColumnOfRulesTable.java new file mode 100644 index 00000000000..362aa8873ed --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/DropPrimaryKeyOnIdColumnOfRulesTable.java @@ -0,0 +1,41 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; + +public class DropPrimaryKeyOnIdColumnOfRulesTable extends DdlChange { + + private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator; + + public DropPrimaryKeyOnIdColumnOfRulesTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { + super(db); + this.dropPrimaryKeySqlGenerator = dropPrimaryKeySqlGenerator; + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(dropPrimaryKeySqlGenerator.generate("rules", "id", true)); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/DropTemplateIdColumnOfRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/DropTemplateIdColumnOfRulesTable.java new file mode 100644 index 00000000000..23f848520de --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/DropTemplateIdColumnOfRulesTable.java @@ -0,0 +1,37 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropTemplateIdColumnOfRulesTable extends DdlChange { + + public DropTemplateIdColumnOfRulesTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropColumnsBuilder(getDialect(), "rules", "template_id").build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/MakeRulesUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/MakeRulesUuidColumnNotNullable.java new file mode 100644 index 00000000000..5a3c6be5be8 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/MakeRulesUuidColumnNotNullable.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class MakeRulesUuidColumnNotNullable extends DdlChange { + private static final String TABLE = "rules"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("uuid") + .setIsNullable(false) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public MakeRulesUuidColumnNotNullable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AlterColumnsBuilder(getDialect(), TABLE) + .updateColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/PopulateRulesTemplateUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/PopulateRulesTemplateUuid.java new file mode 100644 index 00000000000..eea045609bf --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/PopulateRulesTemplateUuid.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulateRulesTemplateUuid extends DataChange { + + public PopulateRulesTemplateUuid(Database db) { + super(db); + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select( + "select ru.id, rt.uuid from rules ru " + + "left join rules rt on rt.id = ru.template_id " + + "where ru.template_uuid is null and ru.template_id is not null"); + massUpdate.update("update rules set template_uuid = ? where id = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, row.getString(2)); + update.setLong(2, row.getLong(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/PopulateRulesUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/PopulateRulesUuid.java new file mode 100644 index 00000000000..b21c99813f2 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/PopulateRulesUuid.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules; + +import java.sql.SQLException; +import org.sonar.core.util.UuidFactory; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulateRulesUuid extends DataChange { + + private final UuidFactory uuidFactory; + + public PopulateRulesUuid(Database db, UuidFactory uuidFactory) { + super(db); + this.uuidFactory = uuidFactory; + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select id from rules where uuid is null"); + massUpdate.update("update rules set uuid = ? where id = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, uuidFactory.create()); + update.setLong(2, row.getLong(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/AddIndexToActiveRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/AddIndexToActiveRulesTable.java new file mode 100644 index 00000000000..021c54c9f75 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/AddIndexToActiveRulesTable.java @@ -0,0 +1,70 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.activerules; + +import java.sql.Connection; +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.DatabaseUtils; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddIndexToActiveRulesTable extends DdlChange { + private static final String TABLE = "active_rules"; + private static final String INDEX_NAME = "uniq_profile_rule_uuids"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("rule_uuid") + .setIsNullable(false) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + private static final VarcharColumnDef profileUuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("profile_uuid") + .setIsNullable(false) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public AddIndexToActiveRulesTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + if (!indexExists()) { + context.execute(new CreateIndexBuilder() + .setTable(TABLE) + .setName(INDEX_NAME) + .addColumn(profileUuidColumnDefinition) + .addColumn(uuidColumnDefinition) + .setUnique(true) + .build()); + } + } + + private boolean indexExists() throws SQLException { + try (Connection connection = getDatabase().getDataSource().getConnection()) { + return DatabaseUtils.indexExists(TABLE, INDEX_NAME, connection); + } + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/AddRuleUuidColumnToActiveRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/AddRuleUuidColumnToActiveRulesTable.java new file mode 100644 index 00000000000..aa92b587e99 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/AddRuleUuidColumnToActiveRulesTable.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.activerules; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddRuleUuidColumnToActiveRulesTable extends DdlChange { + private static final String TABLE = "active_rules"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("rule_uuid") + .setIsNullable(true) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public AddRuleUuidColumnToActiveRulesTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddColumnsBuilder(getDialect(), TABLE) + .addColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/DropIndexOnRuleIdColumnOfActiveRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/DropIndexOnRuleIdColumnOfActiveRulesTable.java new file mode 100644 index 00000000000..0ba65c96767 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/DropIndexOnRuleIdColumnOfActiveRulesTable.java @@ -0,0 +1,43 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.activerules; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropIndexOnRuleIdColumnOfActiveRulesTable extends DdlChange { + private static final String TABLE_NAME = "active_rules"; + private static final String INDEX_NAME = "uniq_profile_rule_ids"; + + public DropIndexOnRuleIdColumnOfActiveRulesTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropIndexBuilder(getDialect()) + .setTable(TABLE_NAME) + .setName(INDEX_NAME) + .build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/DropRuleIdColumnOfActiveRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/DropRuleIdColumnOfActiveRulesTable.java new file mode 100644 index 00000000000..9e0b595d2b9 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/DropRuleIdColumnOfActiveRulesTable.java @@ -0,0 +1,37 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.activerules; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropRuleIdColumnOfActiveRulesTable extends DdlChange { + + public DropRuleIdColumnOfActiveRulesTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropColumnsBuilder(getDialect(), "active_rules", "rule_id").build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/MakeActiveRulesRuleUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/MakeActiveRulesRuleUuidColumnNotNullable.java new file mode 100644 index 00000000000..15d7d705040 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/MakeActiveRulesRuleUuidColumnNotNullable.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.activerules; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class MakeActiveRulesRuleUuidColumnNotNullable extends DdlChange { + private static final String TABLE = "active_rules"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("rule_uuid") + .setIsNullable(false) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public MakeActiveRulesRuleUuidColumnNotNullable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AlterColumnsBuilder(getDialect(), TABLE) + .updateColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/PopulateActiveRulesRuleUuidColumn.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/PopulateActiveRulesRuleUuidColumn.java new file mode 100644 index 00000000000..492c4b8861d --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/PopulateActiveRulesRuleUuidColumn.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.activerules; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulateActiveRulesRuleUuidColumn extends DataChange { + + public PopulateActiveRulesRuleUuidColumn(Database db) { + super(db); + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select ar.rule_id, ru.uuid " + + "from active_rules ar " + + "join rules ru on ar.rule_id = ru.id " + + "where ar.rule_uuid is null"); + massUpdate.update("update active_rules set rule_uuid = ? where rule_id = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, row.getString(2)); + update.setLong(2, row.getLong(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/AddIndexToDeprecatedRuleKeysTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/AddIndexToDeprecatedRuleKeysTable.java new file mode 100644 index 00000000000..b15ecfc3ade --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/AddIndexToDeprecatedRuleKeysTable.java @@ -0,0 +1,63 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.deprecatedrulekeys; + +import java.sql.Connection; +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.DatabaseUtils; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddIndexToDeprecatedRuleKeysTable extends DdlChange { + private static final String TABLE = "deprecated_rule_keys"; + private static final String INDEX_NAME = "rule_uuid_deprecated_rule_keys"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("rule_uuid") + .setIsNullable(false) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public AddIndexToDeprecatedRuleKeysTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + if (!indexExists()) { + context.execute(new CreateIndexBuilder() + .setTable(TABLE) + .setName(INDEX_NAME) + .addColumn(uuidColumnDefinition) + .build()); + } + } + + private boolean indexExists() throws SQLException { + try (Connection connection = getDatabase().getDataSource().getConnection()) { + return DatabaseUtils.indexExists(TABLE, INDEX_NAME, connection); + } + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/AddRuleUuidColumnToDeprecatedRuleKeysTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/AddRuleUuidColumnToDeprecatedRuleKeysTable.java new file mode 100644 index 00000000000..77abd57458a --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/AddRuleUuidColumnToDeprecatedRuleKeysTable.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.deprecatedrulekeys; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddRuleUuidColumnToDeprecatedRuleKeysTable extends DdlChange { + private static final String TABLE = "deprecated_rule_keys"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("rule_uuid") + .setIsNullable(true) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public AddRuleUuidColumnToDeprecatedRuleKeysTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddColumnsBuilder(getDialect(), TABLE) + .addColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTable.java new file mode 100644 index 00000000000..9aea9da32cf --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTable.java @@ -0,0 +1,41 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.deprecatedrulekeys; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTable extends DdlChange { + + public DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropIndexBuilder(getDialect()) + .setTable("deprecated_rule_keys") + .setName("rule_id_deprecated_rule_keys") + .build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/DropRuleIdColumnOfDeprecatedRuleKeysTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/DropRuleIdColumnOfDeprecatedRuleKeysTable.java new file mode 100644 index 00000000000..b5ce1c41849 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/DropRuleIdColumnOfDeprecatedRuleKeysTable.java @@ -0,0 +1,37 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.deprecatedrulekeys; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropRuleIdColumnOfDeprecatedRuleKeysTable extends DdlChange { + + public DropRuleIdColumnOfDeprecatedRuleKeysTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropColumnsBuilder(getDialect(), "deprecated_rule_keys", "rule_id").build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/MakeDeprecatedRuleKeysRuleUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/MakeDeprecatedRuleKeysRuleUuidColumnNotNullable.java new file mode 100644 index 00000000000..ccab567214f --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/MakeDeprecatedRuleKeysRuleUuidColumnNotNullable.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.deprecatedrulekeys; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class MakeDeprecatedRuleKeysRuleUuidColumnNotNullable extends DdlChange { + private static final String TABLE = "deprecated_rule_keys"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("rule_uuid") + .setIsNullable(false) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public MakeDeprecatedRuleKeysRuleUuidColumnNotNullable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AlterColumnsBuilder(getDialect(), TABLE) + .updateColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/PopulateDeprecatedRuleKeysRuleUuidColumn.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/PopulateDeprecatedRuleKeysRuleUuidColumn.java new file mode 100644 index 00000000000..8e35f83f766 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/PopulateDeprecatedRuleKeysRuleUuidColumn.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.deprecatedrulekeys; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulateDeprecatedRuleKeysRuleUuidColumn extends DataChange { + + public PopulateDeprecatedRuleKeysRuleUuidColumn(Database db) { + super(db); + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select drk.rule_id, ru.uuid " + + "from deprecated_rule_keys drk " + + "join rules ru on drk.rule_id = ru.id " + + "where drk.rule_uuid is null"); + massUpdate.update("update deprecated_rule_keys set rule_uuid = ? where rule_id = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, row.getString(2)); + update.setLong(2, row.getLong(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/AddIndexToIssuesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/AddIndexToIssuesTable.java new file mode 100644 index 00000000000..91d8ba9152e --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/AddIndexToIssuesTable.java @@ -0,0 +1,62 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.issues; + +import java.sql.Connection; +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.DatabaseUtils; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddIndexToIssuesTable extends DdlChange { + private static final String TABLE = "issues"; + private static final String INDEX_NAME = "issues_rule_uuid"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("rule_uuid") + .setIsNullable(true) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public AddIndexToIssuesTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + if (!indexExists()) { + context.execute(new CreateIndexBuilder() + .setTable(TABLE) + .setName(INDEX_NAME) + .addColumn(uuidColumnDefinition) + .build()); + } + } + + private boolean indexExists() throws SQLException { + try (Connection connection = getDatabase().getDataSource().getConnection()) { + return DatabaseUtils.indexExists(TABLE, INDEX_NAME, connection); + } + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/AddRuleUuidColumnToIssuesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/AddRuleUuidColumnToIssuesTable.java new file mode 100644 index 00000000000..037cf2f9837 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/AddRuleUuidColumnToIssuesTable.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.issues; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddRuleUuidColumnToIssuesTable extends DdlChange { + private static final String TABLE = "issues"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("rule_uuid") + .setIsNullable(true) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public AddRuleUuidColumnToIssuesTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddColumnsBuilder(getDialect(), TABLE) + .addColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/DropIndexOnRuleIdColumnOfIssuesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/DropIndexOnRuleIdColumnOfIssuesTable.java new file mode 100644 index 00000000000..623e33c5ffd --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/DropIndexOnRuleIdColumnOfIssuesTable.java @@ -0,0 +1,41 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.issues; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropIndexOnRuleIdColumnOfIssuesTable extends DdlChange { + + public DropIndexOnRuleIdColumnOfIssuesTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropIndexBuilder(getDialect()) + .setTable("issues") + .setName("issues_rule_id") + .build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/DropRuleIdColumnOfIssuesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/DropRuleIdColumnOfIssuesTable.java new file mode 100644 index 00000000000..18a1e15f674 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/DropRuleIdColumnOfIssuesTable.java @@ -0,0 +1,37 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.issues; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropRuleIdColumnOfIssuesTable extends DdlChange { + + public DropRuleIdColumnOfIssuesTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropColumnsBuilder(getDialect(), "issues", "rule_id").build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/PopulateIssuesRuleUuidColumn.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/PopulateIssuesRuleUuidColumn.java new file mode 100644 index 00000000000..b0bd0c196a2 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/PopulateIssuesRuleUuidColumn.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.issues; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulateIssuesRuleUuidColumn extends DataChange { + + public PopulateIssuesRuleUuidColumn(Database db) { + super(db); + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select iss.rule_id, ru.uuid " + + "from issues iss " + + "join rules ru on iss.rule_id = ru.id " + + "where iss.rule_uuid is null"); + massUpdate.update("update issues set rule_uuid = ? where rule_id = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, row.getString(2)); + update.setLong(2, row.getLong(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTable.java new file mode 100644 index 00000000000..fad1c61489f --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTable.java @@ -0,0 +1,38 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.rulesmetadata; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; + +public class AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTable extends DdlChange { + + public AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddPrimaryKeyBuilder("rules_metadata", "rule_uuid", "organization_uuid").build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddRuleUuidColumnToRulesMetadataTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddRuleUuidColumnToRulesMetadataTable.java new file mode 100644 index 00000000000..f6d98874722 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddRuleUuidColumnToRulesMetadataTable.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.rulesmetadata; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddRuleUuidColumnToRulesMetadataTable extends DdlChange { + private static final String TABLE = "rules_metadata"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("rule_uuid") + .setIsNullable(true) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public AddRuleUuidColumnToRulesMetadataTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddColumnsBuilder(getDialect(), TABLE) + .addColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropPrimaryKeyOnIdColumnOfRulesMetadataTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropPrimaryKeyOnIdColumnOfRulesMetadataTable.java new file mode 100644 index 00000000000..62ff3000211 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropPrimaryKeyOnIdColumnOfRulesMetadataTable.java @@ -0,0 +1,41 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.rulesmetadata; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; + +public class DropPrimaryKeyOnIdColumnOfRulesMetadataTable extends DdlChange { + + private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator; + + public DropPrimaryKeyOnIdColumnOfRulesMetadataTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { + super(db); + this.dropPrimaryKeySqlGenerator = dropPrimaryKeySqlGenerator; + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(dropPrimaryKeySqlGenerator.generate("rules_metadata", "rule_id", false)); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropRuleIdColumnOfRulesMetadataTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropRuleIdColumnOfRulesMetadataTable.java new file mode 100644 index 00000000000..550557c64bb --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropRuleIdColumnOfRulesMetadataTable.java @@ -0,0 +1,37 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.rulesmetadata; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropRuleIdColumnOfRulesMetadataTable extends DdlChange { + + public DropRuleIdColumnOfRulesMetadataTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropColumnsBuilder(getDialect(), "rules_metadata", "rule_id").build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/MakeRulesMetadataRuleUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/MakeRulesMetadataRuleUuidColumnNotNullable.java new file mode 100644 index 00000000000..f04816770a0 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/MakeRulesMetadataRuleUuidColumnNotNullable.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.rulesmetadata; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class MakeRulesMetadataRuleUuidColumnNotNullable extends DdlChange { + private static final String TABLE = "rules_metadata"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("rule_uuid") + .setIsNullable(false) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public MakeRulesMetadataRuleUuidColumnNotNullable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AlterColumnsBuilder(getDialect(), TABLE) + .updateColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/PopulateRulesMetadataRuleUuidColumn.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/PopulateRulesMetadataRuleUuidColumn.java new file mode 100644 index 00000000000..6021a6975b4 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/PopulateRulesMetadataRuleUuidColumn.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.rulesmetadata; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulateRulesMetadataRuleUuidColumn extends DataChange { + + public PopulateRulesMetadataRuleUuidColumn(Database db) { + super(db); + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select rm.rule_id, ru.uuid " + + "from rules_metadata rm " + + "join rules ru on rm.rule_id = ru.id " + + "where rm.rule_uuid is null"); + massUpdate.update("update rules_metadata set rule_uuid = ? where rule_id = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, row.getString(2)); + update.setLong(2, row.getLong(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/AddIndexesToRulesParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/AddIndexesToRulesParametersTable.java new file mode 100644 index 00000000000..ea2e66feb50 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/AddIndexesToRulesParametersTable.java @@ -0,0 +1,81 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.rulesparameters; + +import java.sql.Connection; +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.DatabaseUtils; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddIndexesToRulesParametersTable extends DdlChange { + private static final String TABLE = "rules_parameters"; + private static final String RULE_UUID_INDEX = "rules_parameters_rule_uuid"; + private static final String RULE_UUID_NAME_UNIQUE_INDEX = "rules_parameters_unique"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("rule_uuid") + .setIsNullable(true) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + private static final VarcharColumnDef nameColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("name") + .setLimit(128) + .setIsNullable(false) + .build(); + + public AddIndexesToRulesParametersTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + if (indexDoesNotExist(RULE_UUID_INDEX)) { + context.execute(new CreateIndexBuilder() + .setTable(TABLE) + .setName(RULE_UUID_INDEX) + .addColumn(uuidColumnDefinition) + .build()); + } + + if (indexDoesNotExist(RULE_UUID_NAME_UNIQUE_INDEX)) { + context.execute(new CreateIndexBuilder() + .setTable(TABLE) + .setName(RULE_UUID_NAME_UNIQUE_INDEX) + .addColumn(uuidColumnDefinition) + .addColumn(nameColumnDefinition) + .setUnique(true) + .build()); + } + } + + private boolean indexDoesNotExist(String index) throws SQLException { + try (Connection connection = getDatabase().getDataSource().getConnection()) { + return !DatabaseUtils.indexExists(TABLE, index, connection); + } + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/AddRuleUuidColumnToRulesParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/AddRuleUuidColumnToRulesParametersTable.java new file mode 100644 index 00000000000..736f4b4bfde --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/AddRuleUuidColumnToRulesParametersTable.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.rulesparameters; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddRuleUuidColumnToRulesParametersTable extends DdlChange { + private static final String TABLE = "rules_parameters"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("rule_uuid") + .setIsNullable(true) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public AddRuleUuidColumnToRulesParametersTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddColumnsBuilder(getDialect(), TABLE) + .addColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/DropIndexesOnRuleIdColumnOfRulesParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/DropIndexesOnRuleIdColumnOfRulesParametersTable.java new file mode 100644 index 00000000000..9d2d4667d94 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/DropIndexesOnRuleIdColumnOfRulesParametersTable.java @@ -0,0 +1,45 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.rulesparameters; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropIndexesOnRuleIdColumnOfRulesParametersTable extends DdlChange { + + public DropIndexesOnRuleIdColumnOfRulesParametersTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropIndexBuilder(getDialect()) + .setTable("rules_parameters") + .setName("rules_parameters_rule_id") + .build()); + context.execute(new DropIndexBuilder(getDialect()) + .setTable("rules_parameters") + .setName("rules_parameters_unique") + .build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/DropRuleIdColumnOfRulesParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/DropRuleIdColumnOfRulesParametersTable.java new file mode 100644 index 00000000000..95d21e115a3 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/DropRuleIdColumnOfRulesParametersTable.java @@ -0,0 +1,37 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.rulesparameters; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropRuleIdColumnOfRulesParametersTable extends DdlChange { + + public DropRuleIdColumnOfRulesParametersTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropColumnsBuilder(getDialect(), "rules_parameters", "rule_id").build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/MakeRulesParametersRuleUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/MakeRulesParametersRuleUuidColumnNotNullable.java new file mode 100644 index 00000000000..4655cbf1f3d --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/MakeRulesParametersRuleUuidColumnNotNullable.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.rulesparameters; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class MakeRulesParametersRuleUuidColumnNotNullable extends DdlChange { + private static final String TABLE = "rules_parameters"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("rule_uuid") + .setIsNullable(false) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public MakeRulesParametersRuleUuidColumnNotNullable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AlterColumnsBuilder(getDialect(), TABLE) + .updateColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/PopulateRulesParametersRuleUuidColumn.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/PopulateRulesParametersRuleUuidColumn.java new file mode 100644 index 00000000000..24d28e8047d --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/PopulateRulesParametersRuleUuidColumn.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.rulesparameters; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulateRulesParametersRuleUuidColumn extends DataChange { + + public PopulateRulesParametersRuleUuidColumn(Database db) { + super(db); + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select rp.rule_id, ru.uuid " + + "from rules_parameters rp " + + "join rules ru on rp.rule_id = ru.id " + + "where rp.rule_uuid is null"); + massUpdate.update("update rules_parameters set rule_uuid = ? where rule_id = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, row.getString(2)); + update.setLong(2, row.getLong(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddPrimaryKeyOnUuidColumnOfRulesParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddPrimaryKeyOnUuidColumnOfRulesParametersTable.java new file mode 100644 index 00000000000..d2fd3271aeb --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddPrimaryKeyOnUuidColumnOfRulesParametersTable.java @@ -0,0 +1,38 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesparameters; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; + +public class AddPrimaryKeyOnUuidColumnOfRulesParametersTable extends DdlChange { + + public AddPrimaryKeyOnUuidColumnOfRulesParametersTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddPrimaryKeyBuilder("rules_parameters", "uuid").build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddUuidColumnToRulesParameters.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddUuidColumnToRulesParameters.java new file mode 100644 index 00000000000..444990d9237 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddUuidColumnToRulesParameters.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesparameters; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.AddUuidColumnToTable; + +public class AddUuidColumnToRulesParameters extends AddUuidColumnToTable { + private static final String TABLE_NAME = "rules_parameters"; + + public AddUuidColumnToRulesParameters(Database db) { + super(db, TABLE_NAME); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropIdColumnOfRulesParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropIdColumnOfRulesParametersTable.java new file mode 100644 index 00000000000..fabc5aa46c4 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropIdColumnOfRulesParametersTable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesparameters; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; + +public class DropIdColumnOfRulesParametersTable extends DropIdColumn { + private static final String TABLE_NAME = "rules_parameters"; + + public DropIdColumnOfRulesParametersTable(Database db) { + super(db, TABLE_NAME); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropPrimaryKeyOnIdColumnOfRulesParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropPrimaryKeyOnIdColumnOfRulesParametersTable.java new file mode 100644 index 00000000000..f2b4984d361 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropPrimaryKeyOnIdColumnOfRulesParametersTable.java @@ -0,0 +1,32 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesparameters; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; + +public class DropPrimaryKeyOnIdColumnOfRulesParametersTable extends DropPrimaryKeyOnIdColumn { + private static final String TABLE_NAME = "rules_parameters"; + + public DropPrimaryKeyOnIdColumnOfRulesParametersTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { + super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/MakeRulesParametersUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/MakeRulesParametersUuidColumnNotNullable.java new file mode 100644 index 00000000000..4e7534215bf --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/MakeRulesParametersUuidColumnNotNullable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesparameters; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.MakeUuidColumnNotNullable; + +public class MakeRulesParametersUuidColumnNotNullable extends MakeUuidColumnNotNullable { + private static final String TABLE_NAME = "rules_parameters"; + + public MakeRulesParametersUuidColumnNotNullable(Database db) { + super(db, TABLE_NAME); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/PopulateRulesParametersUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/PopulateRulesParametersUuid.java new file mode 100644 index 00000000000..a32640322b3 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/PopulateRulesParametersUuid.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesparameters; + +import java.sql.SQLException; +import org.sonar.core.util.UuidFactory; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulateRulesParametersUuid extends DataChange { + + private final UuidFactory uuidFactory; + + public PopulateRulesParametersUuid(Database db, UuidFactory uuidFactory) { + super(db); + this.uuidFactory = uuidFactory; + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select id from rules_parameters where uuid is null"); + massUpdate.update("update rules_parameters set uuid = ? where id = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, uuidFactory.create()); + update.setLong(2, row.getLong(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/AddRulesParameterUuidColumnToActiveRuleParameters.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/AddRulesParameterUuidColumnToActiveRuleParameters.java new file mode 100644 index 00000000000..30521c81fd9 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/AddRulesParameterUuidColumnToActiveRuleParameters.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesparameters.fk; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddRulesParameterUuidColumnToActiveRuleParameters extends DdlChange { + private static final String TABLE = "active_rule_parameters"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("rules_parameter_uuid") + .setIsNullable(true) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public AddRulesParameterUuidColumnToActiveRuleParameters(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddColumnsBuilder(getDialect(), TABLE) + .addColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/DropRulesParameterIdColumnOfActiveRuleParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/DropRulesParameterIdColumnOfActiveRuleParametersTable.java new file mode 100644 index 00000000000..08dc5d8d68a --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/DropRulesParameterIdColumnOfActiveRuleParametersTable.java @@ -0,0 +1,37 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesparameters.fk; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropRulesParameterIdColumnOfActiveRuleParametersTable extends DdlChange { + + public DropRulesParameterIdColumnOfActiveRuleParametersTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropColumnsBuilder(getDialect(), "active_rule_parameters", "rules_parameter_id").build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/MakeActiveRuleParametersRulesParameterUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/MakeActiveRuleParametersRulesParameterUuidColumnNotNullable.java new file mode 100644 index 00000000000..4de0d44e5b6 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/MakeActiveRuleParametersRulesParameterUuidColumnNotNullable.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesparameters.fk; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class MakeActiveRuleParametersRulesParameterUuidColumnNotNullable extends DdlChange { + private static final String TABLE = "active_rule_parameters"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("rules_parameter_uuid") + .setIsNullable(false) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public MakeActiveRuleParametersRulesParameterUuidColumnNotNullable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AlterColumnsBuilder(getDialect(), TABLE) + .updateColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/PopulateActiveRuleParametersRulesParameterUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/PopulateActiveRuleParametersRulesParameterUuid.java new file mode 100644 index 00000000000..def4c27d9d9 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/PopulateActiveRuleParametersRulesParameterUuid.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesparameters.fk; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulateActiveRuleParametersRulesParameterUuid extends DataChange { + + public PopulateActiveRuleParametersRulesParameterUuid(Database db) { + super(db); + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select arp.uuid, rp.uuid " + + "from active_rule_parameters arp " + + "join rules_parameters rp on arp.rules_parameter_id = rp.id " + + "where arp.rules_parameter_uuid is null"); + massUpdate.update("update active_rule_parameters set rules_parameter_uuid = ? where uuid = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, row.getString(2)); + update.setString(2, row.getString(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddPrimaryKeyOnUuidColumnOfRulesProfilesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddPrimaryKeyOnUuidColumnOfRulesProfilesTable.java new file mode 100644 index 00000000000..e0be6487c77 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddPrimaryKeyOnUuidColumnOfRulesProfilesTable.java @@ -0,0 +1,38 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesprofiles; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; + +public class AddPrimaryKeyOnUuidColumnOfRulesProfilesTable extends DdlChange { + + public AddPrimaryKeyOnUuidColumnOfRulesProfilesTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddPrimaryKeyBuilder("rules_profiles", "uuid").build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddUuidColumnToRulesProfilesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddUuidColumnToRulesProfilesTable.java new file mode 100644 index 00000000000..d0f1105ff5b --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddUuidColumnToRulesProfilesTable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesprofiles; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.AddUuidColumnToTable; + +public class AddUuidColumnToRulesProfilesTable extends AddUuidColumnToTable { + private static final String TABLE = "rules_profiles"; + + public AddUuidColumnToRulesProfilesTable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropIdColumnOfRulesProfilesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropIdColumnOfRulesProfilesTable.java new file mode 100644 index 00000000000..9ab63a25be3 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropIdColumnOfRulesProfilesTable.java @@ -0,0 +1,33 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesprofiles; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; + +public class DropIdColumnOfRulesProfilesTable extends DropIdColumn { + + private static final String TABLE_NAME = "rules_profiles"; + + public DropIdColumnOfRulesProfilesTable(Database db) { + super(db, TABLE_NAME); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropKeeColumnOfRulesProfilesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropKeeColumnOfRulesProfilesTable.java new file mode 100644 index 00000000000..49f31702bb0 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropKeeColumnOfRulesProfilesTable.java @@ -0,0 +1,41 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesprofiles; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropKeeColumnOfRulesProfilesTable extends DdlChange { + + private Database db; + + public DropKeeColumnOfRulesProfilesTable(Database db) { + super(db); + this.db = db; + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropColumnsBuilder(db.getDialect(), "rules_profiles", "kee").build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropPrimaryKeyOnIdColumnOfRulesProfilesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropPrimaryKeyOnIdColumnOfRulesProfilesTable.java new file mode 100644 index 00000000000..ecbece18360 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropPrimaryKeyOnIdColumnOfRulesProfilesTable.java @@ -0,0 +1,32 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesprofiles; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; + +public class DropPrimaryKeyOnIdColumnOfRulesProfilesTable extends DropPrimaryKeyOnIdColumn { + private static final String TABLE_NAME = "rules_profiles"; + + public DropPrimaryKeyOnIdColumnOfRulesProfilesTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { + super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropUniqueIndexOnKeeColumnOfRulesProfilesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropUniqueIndexOnKeeColumnOfRulesProfilesTable.java new file mode 100644 index 00000000000..ca55e835a2b --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropUniqueIndexOnKeeColumnOfRulesProfilesTable.java @@ -0,0 +1,52 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesprofiles; + +import java.sql.Connection; +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.DatabaseUtils; +import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropUniqueIndexOnKeeColumnOfRulesProfilesTable extends DdlChange { + private static final String TABLE_NAME = "rules_profiles"; + private static final String INDEX_NAME = "uniq_qprof_key"; + + public DropUniqueIndexOnKeeColumnOfRulesProfilesTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + if (indexExists()) { + context.execute(new DropIndexBuilder(getDialect()) + .setTable(TABLE_NAME) + .setName(INDEX_NAME) + .build()); + } + } + + private boolean indexExists() throws SQLException { + try (Connection connection = getDatabase().getDataSource().getConnection()) { + return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); + } + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/MakeRulesProfilesUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/MakeRulesProfilesUuidColumnNotNullable.java new file mode 100644 index 00000000000..b8ef0e02142 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/MakeRulesProfilesUuidColumnNotNullable.java @@ -0,0 +1,32 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesprofiles; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.MakeUuidColumnNotNullable; + +public class MakeRulesProfilesUuidColumnNotNullable extends MakeUuidColumnNotNullable { + private static final String TABLE_NAME = "rules_profiles"; + + public MakeRulesProfilesUuidColumnNotNullable(Database db) { + super(db, TABLE_NAME); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/PopulateRulesProfilesUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/PopulateRulesProfilesUuid.java new file mode 100644 index 00000000000..687fff44b70 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/PopulateRulesProfilesUuid.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesprofiles; + +import java.sql.SQLException; +import org.sonar.core.util.UuidFactory; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulateRulesProfilesUuid extends DataChange { + + private final UuidFactory uuidFactory; + + public PopulateRulesProfilesUuid(Database db, UuidFactory uuidFactory) { + super(db); + this.uuidFactory = uuidFactory; + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select id from rules_profiles where uuid is null"); + massUpdate.update("update rules_profiles set uuid = ? where id = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, uuidFactory.create()); + update.setLong(2, row.getLong(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/AddProfileUuidColumnToActiveRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/AddProfileUuidColumnToActiveRulesTable.java new file mode 100644 index 00000000000..8b3e709bd32 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/AddProfileUuidColumnToActiveRulesTable.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.activerules; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddProfileUuidColumnToActiveRulesTable extends DdlChange { + private static final String TABLE = "active_rules"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("profile_uuid") + .setIsNullable(true) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public AddProfileUuidColumnToActiveRulesTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddColumnsBuilder(getDialect(), TABLE) + .addColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/AddUniqueIndexOnProfileUuidColumnOfActiveRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/AddUniqueIndexOnProfileUuidColumnOfActiveRulesTable.java new file mode 100644 index 00000000000..8c856cd86e1 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/AddUniqueIndexOnProfileUuidColumnOfActiveRulesTable.java @@ -0,0 +1,67 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.activerules; + +import java.sql.Connection; +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.DatabaseUtils; +import org.sonar.server.platform.db.migration.def.IntegerColumnDef; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddUniqueIndexOnProfileUuidColumnOfActiveRulesTable extends DdlChange { + private static final String TABLE_NAME = "active_rules"; + private static final String INDEX_NAME = "uniq_profile_rule_ids"; + + public AddUniqueIndexOnProfileUuidColumnOfActiveRulesTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + if (!indexExists()) { + context.execute(new CreateIndexBuilder() + .setUnique(true) + .setTable(TABLE_NAME) + .setName(INDEX_NAME) + .addColumn(newVarcharColumnDefBuilder() + .setColumnName("profile_uuid") + .setIsNullable(false) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build()) + .addColumn(IntegerColumnDef.newIntegerColumnDefBuilder() + .setColumnName("rule_id") + .setIsNullable(false) + .build()) + .build()); + } + + } + + private boolean indexExists() throws SQLException { + try (Connection connection = getDatabase().getDataSource().getConnection()) { + return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); + } + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/DropProfileIdColumnOfActiveRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/DropProfileIdColumnOfActiveRulesTable.java new file mode 100644 index 00000000000..5ba5d716afd --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/DropProfileIdColumnOfActiveRulesTable.java @@ -0,0 +1,41 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.activerules; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropProfileIdColumnOfActiveRulesTable extends DdlChange { + + private Database db; + + public DropProfileIdColumnOfActiveRulesTable(Database db) { + super(db); + this.db = db; + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropColumnsBuilder(db.getDialect(), "active_rules", "profile_id").build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/DropUniqueIndexOnProfileIdColumnOfActiveRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/DropUniqueIndexOnProfileIdColumnOfActiveRulesTable.java new file mode 100644 index 00000000000..7241cfe4b19 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/DropUniqueIndexOnProfileIdColumnOfActiveRulesTable.java @@ -0,0 +1,52 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.activerules; + +import java.sql.Connection; +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.DatabaseUtils; +import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropUniqueIndexOnProfileIdColumnOfActiveRulesTable extends DdlChange { + private static final String TABLE_NAME = "active_rules"; + private static final String INDEX_NAME = "uniq_profile_rule_ids"; + + public DropUniqueIndexOnProfileIdColumnOfActiveRulesTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + if (indexExists()) { + context.execute(new DropIndexBuilder(getDialect()) + .setTable(TABLE_NAME) + .setName(INDEX_NAME) + .build()); + } + } + + private boolean indexExists() throws SQLException { + try (Connection connection = getDatabase().getDataSource().getConnection()) { + return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); + } + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/MakeActiveRulesProfileUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/MakeActiveRulesProfileUuidColumnNotNullable.java new file mode 100644 index 00000000000..51991d61753 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/MakeActiveRulesProfileUuidColumnNotNullable.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.activerules; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class MakeActiveRulesProfileUuidColumnNotNullable extends DdlChange { + private static final String TABLE = "active_rules"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("profile_uuid") + .setIsNullable(false) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public MakeActiveRulesProfileUuidColumnNotNullable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AlterColumnsBuilder(getDialect(), TABLE) + .updateColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/PopulateActiveRulesProfileUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/PopulateActiveRulesProfileUuid.java new file mode 100644 index 00000000000..40696efa8c3 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/PopulateActiveRulesProfileUuid.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.activerules; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulateActiveRulesProfileUuid extends DataChange { + + public PopulateActiveRulesProfileUuid(Database db) { + super(db); + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select ar.uuid, rp.uuid " + + "from active_rules ar " + + "join rules_profiles rp on ar.profile_id = rp.id " + + "where ar.profile_uuid is null"); + massUpdate.update("update active_rules set profile_uuid = ? where uuid = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, row.getString(2)); + update.setString(2, row.getString(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/orgqprofiles/PopulateOrgQProfilesRulesProfileUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/orgqprofiles/PopulateOrgQProfilesRulesProfileUuid.java new file mode 100644 index 00000000000..badf2374df8 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/orgqprofiles/PopulateOrgQProfilesRulesProfileUuid.java @@ -0,0 +1,48 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.orgqprofiles; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulateOrgQProfilesRulesProfileUuid extends DataChange { + + public PopulateOrgQProfilesRulesProfileUuid(Database db) { + super(db); + } + + @Override + protected void execute(DataChange.Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select oqp.uuid, rp.uuid " + + "from org_qprofiles oqp " + + "join rules_profiles rp on oqp.rules_profile_uuid = rp.kee"); + massUpdate.update("update org_qprofiles set rules_profile_uuid = ? where uuid = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, row.getString(2)); + update.setString(2, row.getString(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/qprofilechanges/PopulateQProfileChangesRulesProfileUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/qprofilechanges/PopulateQProfileChangesRulesProfileUuid.java new file mode 100644 index 00000000000..73c95186441 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/qprofilechanges/PopulateQProfileChangesRulesProfileUuid.java @@ -0,0 +1,48 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.qprofilechanges; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulateQProfileChangesRulesProfileUuid extends DataChange { + + public PopulateQProfileChangesRulesProfileUuid(Database db) { + super(db); + } + + @Override + protected void execute(DataChange.Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select qpc.kee, rp.uuid " + + "from qprofile_changes qpc " + + "join rules_profiles rp on qpc.rules_profile_uuid = rp.kee"); + massUpdate.update("update qprofile_changes set rules_profile_uuid = ? where kee = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, row.getString(2)); + update.setString(2, row.getString(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/snapshots/issues/AddPrimaryKeyOnUuidColumnOfSnapshotsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/snapshots/issues/AddPrimaryKeyOnUuidColumnOfSnapshotsTable.java new file mode 100644 index 00000000000..f6654ab66ee --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/snapshots/issues/AddPrimaryKeyOnUuidColumnOfSnapshotsTable.java @@ -0,0 +1,38 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.snapshots.issues; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; + +public class AddPrimaryKeyOnUuidColumnOfSnapshotsTable extends DdlChange { + + public AddPrimaryKeyOnUuidColumnOfSnapshotsTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddPrimaryKeyBuilder("snapshots", "uuid").build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/snapshots/issues/DropIdColumnOfSnapshotsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/snapshots/issues/DropIdColumnOfSnapshotsTable.java new file mode 100644 index 00000000000..2956692b74d --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/snapshots/issues/DropIdColumnOfSnapshotsTable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.snapshots.issues; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; + +public class DropIdColumnOfSnapshotsTable extends DropIdColumn { + private static final String TABLE = "snapshots"; + + public DropIdColumnOfSnapshotsTable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/snapshots/issues/DropPrimaryKeyOnIdColumnOfSnapshotsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/snapshots/issues/DropPrimaryKeyOnIdColumnOfSnapshotsTable.java new file mode 100644 index 00000000000..c79ad62a279 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/snapshots/issues/DropPrimaryKeyOnIdColumnOfSnapshotsTable.java @@ -0,0 +1,41 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.snapshots.issues; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; + +public class DropPrimaryKeyOnIdColumnOfSnapshotsTable extends DdlChange { + + private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator; + + public DropPrimaryKeyOnIdColumnOfSnapshotsTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { + super(db); + this.dropPrimaryKeySqlGenerator = dropPrimaryKeySqlGenerator; + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(dropPrimaryKeySqlGenerator.generate("snapshots", "id", true)); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/AddPrimaryKeyOnUuidColumnOfUserRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/AddPrimaryKeyOnUuidColumnOfUserRolesTable.java new file mode 100644 index 00000000000..098d8282453 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/AddPrimaryKeyOnUuidColumnOfUserRolesTable.java @@ -0,0 +1,38 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.userroles; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; + +public class AddPrimaryKeyOnUuidColumnOfUserRolesTable extends DdlChange { + + public AddPrimaryKeyOnUuidColumnOfUserRolesTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddPrimaryKeyBuilder("user_roles", "uuid").build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/AddUuidColumnToUserRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/AddUuidColumnToUserRolesTable.java new file mode 100644 index 00000000000..e6ec69db90f --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/AddUuidColumnToUserRolesTable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.userroles; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.AddUuidColumnToTable; + +public class AddUuidColumnToUserRolesTable extends AddUuidColumnToTable { + private static final String TABLE = "user_roles"; + + public AddUuidColumnToUserRolesTable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/DropIdColumnOfUserRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/DropIdColumnOfUserRolesTable.java new file mode 100644 index 00000000000..d8eb8ad4da8 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/DropIdColumnOfUserRolesTable.java @@ -0,0 +1,29 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.userroles; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; + +public class DropIdColumnOfUserRolesTable extends DropIdColumn { + public DropIdColumnOfUserRolesTable(Database db) { + super(db, "user_roles"); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/DropPrimaryKeyOnIdColumnOfUserRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/DropPrimaryKeyOnIdColumnOfUserRolesTable.java new file mode 100644 index 00000000000..3bf847a3070 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/DropPrimaryKeyOnIdColumnOfUserRolesTable.java @@ -0,0 +1,32 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.userroles; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; + +public class DropPrimaryKeyOnIdColumnOfUserRolesTable extends DropPrimaryKeyOnIdColumn { + private static final String TABLE_NAME = "user_roles"; + + public DropPrimaryKeyOnIdColumnOfUserRolesTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { + super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/MakeUserRolesUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/MakeUserRolesUuidColumnNotNullable.java new file mode 100644 index 00000000000..99b08f0b664 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/MakeUserRolesUuidColumnNotNullable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.userroles; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.MakeUuidColumnNotNullable; + +public class MakeUserRolesUuidColumnNotNullable extends MakeUuidColumnNotNullable { + private static final String TABLE = "user_roles"; + + public MakeUserRolesUuidColumnNotNullable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/PopulateUserRolesUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/PopulateUserRolesUuid.java new file mode 100644 index 00000000000..ecf7a4090d4 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/PopulateUserRolesUuid.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.userroles; + +import java.sql.SQLException; +import org.sonar.core.util.UuidFactory; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulateUserRolesUuid extends DataChange { + + private final UuidFactory uuidFactory; + + public PopulateUserRolesUuid(Database db, UuidFactory uuidFactory) { + super(db); + this.uuidFactory = uuidFactory; + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select id from user_roles where uuid is null order by id asc"); + massUpdate.update("update user_roles set uuid = ? where id = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, uuidFactory.create()); + update.setLong(2, row.getLong(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/AddPrimaryKeyOnUuidColumnOfUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/AddPrimaryKeyOnUuidColumnOfUsersTable.java new file mode 100644 index 00000000000..94dd321dae9 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/AddPrimaryKeyOnUuidColumnOfUsersTable.java @@ -0,0 +1,38 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; + +public class AddPrimaryKeyOnUuidColumnOfUsersTable extends DdlChange { + + public AddPrimaryKeyOnUuidColumnOfUsersTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddPrimaryKeyBuilder("users", "uuid").build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/DropIdColumnOfUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/DropIdColumnOfUsersTable.java new file mode 100644 index 00000000000..019889eb81c --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/DropIdColumnOfUsersTable.java @@ -0,0 +1,32 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; + +public class DropIdColumnOfUsersTable extends DropIdColumn { + + private static final String TABLE_NAME = "users"; + + public DropIdColumnOfUsersTable(Database db) { + super(db, TABLE_NAME); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/DropPrimaryKeyOnIdColumnOfUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/DropPrimaryKeyOnIdColumnOfUsersTable.java new file mode 100644 index 00000000000..923745c3c95 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/DropPrimaryKeyOnIdColumnOfUsersTable.java @@ -0,0 +1,33 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; + +public class DropPrimaryKeyOnIdColumnOfUsersTable extends DropPrimaryKeyOnIdColumn { + + private static final String TABLE_NAME = "users"; + + public DropPrimaryKeyOnIdColumnOfUsersTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { + super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/DropUniqueIndexOnUuidColumnOfUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/DropUniqueIndexOnUuidColumnOfUsersTable.java new file mode 100644 index 00000000000..0e5ba8d20c2 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/DropUniqueIndexOnUuidColumnOfUsersTable.java @@ -0,0 +1,53 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users; + +import java.sql.Connection; +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.DatabaseUtils; +import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropUniqueIndexOnUuidColumnOfUsersTable extends DdlChange { + + private static final String TABLE_NAME = "users"; + private static final String INDEX_NAME = "users_uuid"; + + public DropUniqueIndexOnUuidColumnOfUsersTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + if (indexExists()) { + context.execute(new DropIndexBuilder(getDialect()) + .setTable(TABLE_NAME) + .setName(INDEX_NAME) + .build()); + } + } + + private boolean indexExists() throws SQLException { + try (Connection connection = getDatabase().getDataSource().getConnection()) { + return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); + } + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddIndexOnUserUuidOfGroupsUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddIndexOnUserUuidOfGroupsUsersTable.java new file mode 100644 index 00000000000..dbbc4ece49a --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddIndexOnUserUuidOfGroupsUsersTable.java @@ -0,0 +1,60 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers; + +import java.sql.Connection; +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.DatabaseUtils; +import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_SIZE; +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddIndexOnUserUuidOfGroupsUsersTable extends DdlChange { + private static final String TABLE_NAME = "groups_users"; + private static final String INDEX_NAME = "index_groups_users_user_uuid"; + + public AddIndexOnUserUuidOfGroupsUsersTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + if (!indexExists()) { + context.execute(new CreateIndexBuilder() + .setUnique(false) + .setTable(TABLE_NAME) + .setName(INDEX_NAME) + .addColumn(newVarcharColumnDefBuilder() + .setColumnName("user_uuid") + .setLimit(UUID_SIZE) + .build()) + .build()); + } + } + + private boolean indexExists() throws SQLException { + try (Connection connection = getDatabase().getDataSource().getConnection()) { + return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); + } + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTable.java new file mode 100644 index 00000000000..0c9179c5dc6 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTable.java @@ -0,0 +1,64 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers; + +import java.sql.Connection; +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.DatabaseUtils; +import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_SIZE; +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTable extends DdlChange { + private static final String TABLE_NAME = "groups_users"; + private static final String INDEX_NAME = "groups_users_unique"; + + public AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + if (!indexExists()) { + context.execute(new CreateIndexBuilder() + .setTable(TABLE_NAME) + .setName(INDEX_NAME) + .setUnique(true) + .addColumn(newVarcharColumnDefBuilder() + .setColumnName("user_uuid") + .setLimit(UUID_SIZE) + .build()) + .addColumn(newVarcharColumnDefBuilder() + .setColumnName("group_uuid") + .setLimit(UUID_SIZE) + .build()) + .build()); + } + } + + private boolean indexExists() throws SQLException { + try (Connection connection = getDatabase().getDataSource().getConnection()) { + return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); + } + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddUserUuidColumnToGroupsUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddUserUuidColumnToGroupsUsers.java new file mode 100644 index 00000000000..152240ec6ee --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddUserUuidColumnToGroupsUsers.java @@ -0,0 +1,29 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.users.fk.util.AddUserUuidColumnToTable; + +public class AddUserUuidColumnToGroupsUsers extends AddUserUuidColumnToTable { + public AddUserUuidColumnToGroupsUsers(Database db) { + super(db, "groups_users"); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropIndexOnUserIdOfGroupsUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropIndexOnUserIdOfGroupsUsersTable.java new file mode 100644 index 00000000000..4df0d1b7de6 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropIndexOnUserIdOfGroupsUsersTable.java @@ -0,0 +1,52 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers; + +import java.sql.Connection; +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.DatabaseUtils; +import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropIndexOnUserIdOfGroupsUsersTable extends DdlChange { + private static final String TABLE_NAME = "groups_users"; + private static final String INDEX_NAME = "index_groups_users_on_user_id"; + + public DropIndexOnUserIdOfGroupsUsersTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + if (indexExists()) { + context.execute(new DropIndexBuilder(getDialect()) + .setTable(TABLE_NAME) + .setName(INDEX_NAME) + .build()); + } + } + + private boolean indexExists() throws SQLException { + try (Connection connection = getDatabase().getDataSource().getConnection()) { + return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); + } + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTable.java new file mode 100644 index 00000000000..7afb9cd4d51 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTable.java @@ -0,0 +1,52 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers; + +import java.sql.Connection; +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.DatabaseUtils; +import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTable extends DdlChange { + private static final String TABLE_NAME = "groups_users"; + private static final String INDEX_NAME = "groups_users_unique"; + + public DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + if (indexExists()) { + context.execute(new DropIndexBuilder(getDialect()) + .setTable(TABLE_NAME) + .setName(INDEX_NAME) + .build()); + } + } + + private boolean indexExists() throws SQLException { + try (Connection connection = getDatabase().getDataSource().getConnection()) { + return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); + } + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropUserIdColumnOfGroupsUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropUserIdColumnOfGroupsUsersTable.java new file mode 100644 index 00000000000..1d4c93f19d3 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropUserIdColumnOfGroupsUsersTable.java @@ -0,0 +1,37 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropUserIdColumnOfGroupsUsersTable extends DdlChange { + public DropUserIdColumnOfGroupsUsersTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropColumnsBuilder(getDialect(), "groups_users", "user_id").build()); + } +} + diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/MakeGroupsUsersUserUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/MakeGroupsUsersUserUuidColumnNotNullable.java new file mode 100644 index 00000000000..2cf5d9a0692 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/MakeGroupsUsersUserUuidColumnNotNullable.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class MakeGroupsUsersUserUuidColumnNotNullable extends DdlChange { + private static final String TABLE_NAME = "groups_users"; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("user_uuid") + .setIsNullable(false) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public MakeGroupsUsersUserUuidColumnNotNullable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AlterColumnsBuilder(getDialect(), TABLE_NAME) + .updateColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/PopulateGroupsUsersUserUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/PopulateGroupsUsersUserUuid.java new file mode 100644 index 00000000000..48ef8e8f113 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/PopulateGroupsUsersUserUuid.java @@ -0,0 +1,53 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulateGroupsUsersUserUuid extends DataChange { + + public PopulateGroupsUsersUserUuid(Database db) { + super(db); + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select gu.group_uuid, gu.user_id, u.uuid " + + "from groups_users gu " + + "join users u on gu.user_id = u.id where gu.user_uuid is null"); + + massUpdate.update("update groups_users set user_uuid = ? where group_uuid = ? and user_id = ?"); + + massUpdate.execute((row, update) -> { + String groupUuid = row.getString(1); + long userId = row.getLong(2); + String userUuid = row.getString(3); + update.setString(1, userUuid); + update.setString(2, groupUuid); + update.setLong(3, userId); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddIndexOnUserUuidOfOrganizationMembersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddIndexOnUserUuidOfOrganizationMembersTable.java new file mode 100644 index 00000000000..21fb387e9e5 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddIndexOnUserUuidOfOrganizationMembersTable.java @@ -0,0 +1,60 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers; + +import java.sql.Connection; +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.DatabaseUtils; +import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_SIZE; +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddIndexOnUserUuidOfOrganizationMembersTable extends DdlChange { + private static final String TABLE_NAME = "organization_members"; + private static final String INDEX_NAME = "org_members_user_uuid"; + + public AddIndexOnUserUuidOfOrganizationMembersTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + if (!indexExists()) { + context.execute(new CreateIndexBuilder() + .setUnique(false) + .setTable(TABLE_NAME) + .setName(INDEX_NAME) + .addColumn(newVarcharColumnDefBuilder() + .setColumnName("user_uuid") + .setLimit(UUID_SIZE) + .build()) + .build()); + } + } + + private boolean indexExists() throws SQLException { + try (Connection connection = getDatabase().getDataSource().getConnection()) { + return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); + } + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTable.java new file mode 100644 index 00000000000..20bc5d8f6c6 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTable.java @@ -0,0 +1,38 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; + +public class AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTable extends DdlChange { + + public AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddPrimaryKeyBuilder("organization_members", "user_uuid", "organization_uuid").build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddUserUuidColumnToOrganizationMembers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddUserUuidColumnToOrganizationMembers.java new file mode 100644 index 00000000000..b93e07c24a8 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddUserUuidColumnToOrganizationMembers.java @@ -0,0 +1,29 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.users.fk.util.AddUserUuidColumnToTable; + +public class AddUserUuidColumnToOrganizationMembers extends AddUserUuidColumnToTable { + public AddUserUuidColumnToOrganizationMembers(Database db) { + super(db, "organization_members"); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropIndexOnUserIdOfOrganizationMembersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropIndexOnUserIdOfOrganizationMembersTable.java new file mode 100644 index 00000000000..90b8196a1b7 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropIndexOnUserIdOfOrganizationMembersTable.java @@ -0,0 +1,52 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers; + +import java.sql.Connection; +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.DatabaseUtils; +import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropIndexOnUserIdOfOrganizationMembersTable extends DdlChange { + private static final String TABLE_NAME = "organization_members"; + private static final String INDEX_NAME = "ix_org_members_on_user_id"; + + public DropIndexOnUserIdOfOrganizationMembersTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + if (indexExists()) { + context.execute(new DropIndexBuilder(getDialect()) + .setTable(TABLE_NAME) + .setName(INDEX_NAME) + .build()); + } + } + + private boolean indexExists() throws SQLException { + try (Connection connection = getDatabase().getDataSource().getConnection()) { + return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); + } + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTable.java new file mode 100644 index 00000000000..0a8f74b2548 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTable.java @@ -0,0 +1,41 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; + +public class DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTable extends DdlChange { + private static final String TABLE_NAME = "organization_members"; + + private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator; + + public DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { + super(db); + this.dropPrimaryKeySqlGenerator = dropPrimaryKeySqlGenerator; + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(dropPrimaryKeySqlGenerator.generate(TABLE_NAME, "user_id", false)); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropUserIdColumnOfOrganizationMembersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropUserIdColumnOfOrganizationMembersTable.java new file mode 100644 index 00000000000..c0e8163cfba --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropUserIdColumnOfOrganizationMembersTable.java @@ -0,0 +1,36 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropUserIdColumnOfOrganizationMembersTable extends DdlChange { + public DropUserIdColumnOfOrganizationMembersTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropColumnsBuilder(getDialect(), "organization_members", "user_id").build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/MakeOrganizationMembersUserUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/MakeOrganizationMembersUserUuidColumnNotNullable.java new file mode 100644 index 00000000000..f0fe540a244 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/MakeOrganizationMembersUserUuidColumnNotNullable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.users.fk.util.MakeUserUuidColumnNotNullable; + +public class MakeOrganizationMembersUserUuidColumnNotNullable extends MakeUserUuidColumnNotNullable { + private static final String TABLE_NAME = "organization_members"; + + public MakeOrganizationMembersUserUuidColumnNotNullable(Database db) { + super(db, TABLE_NAME); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/PopulateOrganizationMembersUserUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/PopulateOrganizationMembersUserUuid.java new file mode 100644 index 00000000000..536693a24de --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/PopulateOrganizationMembersUserUuid.java @@ -0,0 +1,54 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulateOrganizationMembersUserUuid extends DataChange { + + public PopulateOrganizationMembersUserUuid(Database db) { + super(db); + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select om.user_id, om.organization_uuid, u.uuid " + + "from organization_members om " + + "join users u on om.user_id = u.id where om.user_uuid is null"); + + massUpdate.update("update organization_members set user_uuid = ? where organization_uuid = ? and user_id = ?"); + + massUpdate.execute((row, update, index) -> { + long userId = row.getLong(1); + String organizationUuid = row.getString(2); + String userUuid = row.getString(3); + + update.setString(1, userUuid); + update.setString(2, organizationUuid); + update.setLong(3, userId); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/AddUserUuidColumnToPermTemplatesUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/AddUserUuidColumnToPermTemplatesUsers.java new file mode 100644 index 00000000000..9df9678a44e --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/AddUserUuidColumnToPermTemplatesUsers.java @@ -0,0 +1,30 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.permtemplatesusers; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.users.fk.util.AddUserUuidColumnToTable; + +public class AddUserUuidColumnToPermTemplatesUsers extends AddUserUuidColumnToTable { + + public AddUserUuidColumnToPermTemplatesUsers(Database db) { + super(db, "perm_templates_users"); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/DropUserIdColumnOfPermTemplatesUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/DropUserIdColumnOfPermTemplatesUsersTable.java new file mode 100644 index 00000000000..615779c47cf --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/DropUserIdColumnOfPermTemplatesUsersTable.java @@ -0,0 +1,36 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.permtemplatesusers; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropUserIdColumnOfPermTemplatesUsersTable extends DdlChange { + public DropUserIdColumnOfPermTemplatesUsersTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropColumnsBuilder(getDialect(), "perm_templates_users", "user_id").build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/MakePermTemplatesUsersUserUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/MakePermTemplatesUsersUserUuidColumnNotNullable.java new file mode 100644 index 00000000000..53e6d63e7d6 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/MakePermTemplatesUsersUserUuidColumnNotNullable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.permtemplatesusers; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.users.fk.util.MakeUserUuidColumnNotNullable; + +public class MakePermTemplatesUsersUserUuidColumnNotNullable extends MakeUserUuidColumnNotNullable { + private static final String TABLE_NAME = "perm_templates_users"; + + public MakePermTemplatesUsersUserUuidColumnNotNullable(Database db) { + super(db, TABLE_NAME); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/PopulatePermTemplatesUsersUserUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/PopulatePermTemplatesUsersUserUuid.java new file mode 100644 index 00000000000..79a02a42d56 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/PopulatePermTemplatesUsersUserUuid.java @@ -0,0 +1,52 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.permtemplatesusers; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulatePermTemplatesUsersUserUuid extends DataChange { + + public PopulatePermTemplatesUsersUserUuid(Database db) { + super(db); + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select ptu.uuid, u.uuid " + + "from perm_templates_users ptu " + + "join users u on ptu.user_id = u.id where ptu.user_uuid is null"); + + massUpdate.update("update perm_templates_users set user_uuid = ? where uuid = ?"); + + massUpdate.execute((row, update, index) -> { + String permTemplatesUuid = row.getString(1); + String userUuid = row.getString(2); + + update.setString(1, userUuid); + update.setString(2, permTemplatesUuid); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/AddUserUuidColumnToPropertiesUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/AddUserUuidColumnToPropertiesUsers.java new file mode 100644 index 00000000000..df3cc2ed1f1 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/AddUserUuidColumnToPropertiesUsers.java @@ -0,0 +1,30 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.properties; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.users.fk.util.AddUserUuidColumnToTable; + +public class AddUserUuidColumnToPropertiesUsers extends AddUserUuidColumnToTable { + + public AddUserUuidColumnToPropertiesUsers(Database db) { + super(db, "properties"); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/DropUserIdColumnOfPropertiesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/DropUserIdColumnOfPropertiesTable.java new file mode 100644 index 00000000000..115b04e184f --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/DropUserIdColumnOfPropertiesTable.java @@ -0,0 +1,36 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.properties; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropUserIdColumnOfPropertiesTable extends DdlChange { + public DropUserIdColumnOfPropertiesTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropColumnsBuilder(getDialect(), "properties", "user_id").build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/PopulatePropertiesUserUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/PopulatePropertiesUserUuid.java new file mode 100644 index 00000000000..6ac4b74af49 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/PopulatePropertiesUserUuid.java @@ -0,0 +1,52 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.properties; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulatePropertiesUserUuid extends DataChange { + + public PopulatePropertiesUserUuid(Database db) { + super(db); + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select p.uuid, u.uuid " + + "from properties p " + + "join users u on p.user_id = u.id where p.user_uuid is null"); + + massUpdate.update("update properties set user_uuid = ? where uuid = ?"); + + massUpdate.execute((row, update, index) -> { + String propertiesUuid = row.getString(1); + String userUuid = row.getString(2); + + update.setString(1, userUuid); + update.setString(2, propertiesUuid); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTable.java new file mode 100644 index 00000000000..38eb2e8f973 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTable.java @@ -0,0 +1,64 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.qprofileeditusers; + +import java.sql.Connection; +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.DatabaseUtils; +import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_SIZE; +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTable extends DdlChange { + private static final String TABLE_NAME = "qprofile_edit_users"; + private static final String INDEX_NAME = "qprofile_edit_users_unique"; + + public AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + if (!indexExists()) { + context.execute(new CreateIndexBuilder() + .setUnique(true) + .setTable(TABLE_NAME) + .setName(INDEX_NAME) + .addColumn(newVarcharColumnDefBuilder() + .setColumnName("user_uuid") + .setLimit(UUID_SIZE) + .build()) + .addColumn(newVarcharColumnDefBuilder() + .setColumnName("qprofile_uuid") + .setLimit(UUID_SIZE) + .build()) + .build()); + } + } + + private boolean indexExists() throws SQLException { + try (Connection connection = getDatabase().getDataSource().getConnection()) { + return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); + } + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/AddUserUuidColumnToQProfileEditUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/AddUserUuidColumnToQProfileEditUsers.java new file mode 100644 index 00000000000..73956509391 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/AddUserUuidColumnToQProfileEditUsers.java @@ -0,0 +1,30 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.qprofileeditusers; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.users.fk.util.AddUserUuidColumnToTable; + +public class AddUserUuidColumnToQProfileEditUsers extends AddUserUuidColumnToTable { + + public AddUserUuidColumnToQProfileEditUsers(Database db) { + super(db, "qprofile_edit_users"); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTable.java new file mode 100644 index 00000000000..eafca322d16 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTable.java @@ -0,0 +1,52 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.qprofileeditusers; + +import java.sql.Connection; +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.DatabaseUtils; +import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTable extends DdlChange { + private static final String TABLE_NAME = "qprofile_edit_users"; + private static final String INDEX_NAME = "qprofile_edit_users_unique"; + + public DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + if (indexExists()) { + context.execute(new DropIndexBuilder(getDialect()) + .setTable(TABLE_NAME) + .setName(INDEX_NAME) + .build()); + } + } + + private boolean indexExists() throws SQLException { + try (Connection connection = getDatabase().getDataSource().getConnection()) { + return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); + } + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/DropUserIdColumnOfQProfileEditUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/DropUserIdColumnOfQProfileEditUsersTable.java new file mode 100644 index 00000000000..a94e427b564 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/DropUserIdColumnOfQProfileEditUsersTable.java @@ -0,0 +1,36 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.qprofileeditusers; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropUserIdColumnOfQProfileEditUsersTable extends DdlChange { + public DropUserIdColumnOfQProfileEditUsersTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropColumnsBuilder(getDialect(), "qprofile_edit_users", "user_id").build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/MakeQProfileEditUsersUserUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/MakeQProfileEditUsersUserUuidColumnNotNullable.java new file mode 100644 index 00000000000..4d687ce2210 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/MakeQProfileEditUsersUserUuidColumnNotNullable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.qprofileeditusers; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.users.fk.util.MakeUserUuidColumnNotNullable; + +public class MakeQProfileEditUsersUserUuidColumnNotNullable extends MakeUserUuidColumnNotNullable { + private static final String TABLE_NAME = "qprofile_edit_users"; + + public MakeQProfileEditUsersUserUuidColumnNotNullable(Database db) { + super(db, TABLE_NAME); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/PopulateQProfileEditUsersUserUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/PopulateQProfileEditUsersUserUuid.java new file mode 100644 index 00000000000..c45e42db93a --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/PopulateQProfileEditUsersUserUuid.java @@ -0,0 +1,52 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.qprofileeditusers; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulateQProfileEditUsersUserUuid extends DataChange { + + public PopulateQProfileEditUsersUserUuid(Database db) { + super(db); + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select qeu.uuid, u.uuid " + + "from qprofile_edit_users qeu " + + "join users u on qeu.user_id = u.id where qeu.user_uuid is null"); + + massUpdate.update("update qprofile_edit_users set user_uuid = ? where uuid = ?"); + + massUpdate.execute((row, update, index) -> { + String permTemplatesUuid = row.getString(1); + String userUuid = row.getString(2); + + update.setString(1, userUuid); + update.setString(2, permTemplatesUuid); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/AddIndexOnUserUuidOfUserRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/AddIndexOnUserUuidOfUserRolesTable.java new file mode 100644 index 00000000000..1ec8a5e88d7 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/AddIndexOnUserUuidOfUserRolesTable.java @@ -0,0 +1,60 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.userroles; + +import java.sql.Connection; +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.DatabaseUtils; +import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_SIZE; +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddIndexOnUserUuidOfUserRolesTable extends DdlChange { + private static final String TABLE_NAME = "user_roles"; + private static final String INDEX_NAME = "user_roles_user"; + + public AddIndexOnUserUuidOfUserRolesTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + if (!indexExists()) { + context.execute(new CreateIndexBuilder() + .setUnique(false) + .setTable(TABLE_NAME) + .setName(INDEX_NAME) + .addColumn(newVarcharColumnDefBuilder() + .setColumnName("user_uuid") + .setLimit(UUID_SIZE) + .build()) + .build()); + } + } + + private boolean indexExists() throws SQLException { + try (Connection connection = getDatabase().getDataSource().getConnection()) { + return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); + } + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/AddUserUuidColumnToUserRoles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/AddUserUuidColumnToUserRoles.java new file mode 100644 index 00000000000..c6de402bbf9 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/AddUserUuidColumnToUserRoles.java @@ -0,0 +1,30 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.userroles; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.users.fk.util.AddUserUuidColumnToTable; + +public class AddUserUuidColumnToUserRoles extends AddUserUuidColumnToTable { + + public AddUserUuidColumnToUserRoles(Database db) { + super(db, "user_roles"); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/DropIndexOnUserIdOfUserRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/DropIndexOnUserIdOfUserRolesTable.java new file mode 100644 index 00000000000..a8ad989b8f0 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/DropIndexOnUserIdOfUserRolesTable.java @@ -0,0 +1,52 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.userroles; + +import java.sql.Connection; +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.DatabaseUtils; +import org.sonar.server.platform.db.migration.sql.DropIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropIndexOnUserIdOfUserRolesTable extends DdlChange { + private static final String TABLE_NAME = "user_roles"; + private static final String INDEX_NAME = "user_roles_user"; + + public DropIndexOnUserIdOfUserRolesTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + if (indexExists()) { + context.execute(new DropIndexBuilder(getDialect()) + .setTable(TABLE_NAME) + .setName(INDEX_NAME) + .build()); + } + } + + private boolean indexExists() throws SQLException { + try (Connection connection = getDatabase().getDataSource().getConnection()) { + return DatabaseUtils.indexExists(TABLE_NAME, INDEX_NAME, connection); + } + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/DropUserIdColumnOfUserRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/DropUserIdColumnOfUserRolesTable.java new file mode 100644 index 00000000000..ee57201b794 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/DropUserIdColumnOfUserRolesTable.java @@ -0,0 +1,36 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.userroles; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropUserIdColumnOfUserRolesTable extends DdlChange { + public DropUserIdColumnOfUserRolesTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropColumnsBuilder(getDialect(), "user_roles", "user_id").build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/PopulateUserRolesUserUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/PopulateUserRolesUserUuid.java new file mode 100644 index 00000000000..ba3e284279e --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/PopulateUserRolesUserUuid.java @@ -0,0 +1,52 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.userroles; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulateUserRolesUserUuid extends DataChange { + + public PopulateUserRolesUserUuid(Database db) { + super(db); + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select ur.uuid, u.uuid " + + "from user_roles ur " + + "join users u on ur.user_id = u.id where ur.user_uuid is null"); + + massUpdate.update("update user_roles set user_uuid = ? where uuid = ?"); + + massUpdate.execute((row, update, index) -> { + String userRolesUuid = row.getString(1); + String userUuid = row.getString(2); + + update.setString(1, userUuid); + update.setString(2, userRolesUuid); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/util/AddUserUuidColumnToTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/util/AddUserUuidColumnToTable.java new file mode 100644 index 00000000000..bee2024acbc --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/util/AddUserUuidColumnToTable.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.util; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddUserUuidColumnToTable extends DdlChange { + private final String tableName; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("user_uuid") + .setIsNullable(true) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public AddUserUuidColumnToTable(Database db, String tableName) { + super(db); + this.tableName = tableName; + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddColumnsBuilder(getDialect(), tableName) + .addColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/util/MakeUserUuidColumnNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/util/MakeUserUuidColumnNotNullable.java new file mode 100644 index 00000000000..1189e5e88b3 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/util/MakeUserUuidColumnNotNullable.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.util; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class MakeUserUuidColumnNotNullable extends DdlChange { + private final String tableName; + + private static final VarcharColumnDef uuidColumnDefinition = newVarcharColumnDefBuilder() + .setColumnName("user_uuid") + .setIsNullable(false) + .setDefaultValue(null) + .setLimit(VarcharColumnDef.UUID_SIZE) + .build(); + + public MakeUserUuidColumnNotNullable(Database db, String tableName) { + super(db); + this.tableName = tableName; + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AlterColumnsBuilder(getDialect(), tableName) + .updateColumn(uuidColumnDefinition) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/AddPrimaryKeyOnUuidColumnOfUserTokensTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/AddPrimaryKeyOnUuidColumnOfUserTokensTable.java new file mode 100644 index 00000000000..114aaaef179 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/AddPrimaryKeyOnUuidColumnOfUserTokensTable.java @@ -0,0 +1,38 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.usertokens; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; + +public class AddPrimaryKeyOnUuidColumnOfUserTokensTable extends DdlChange { + + public AddPrimaryKeyOnUuidColumnOfUserTokensTable(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddPrimaryKeyBuilder("user_tokens", "uuid").build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/AddUuidColumnToUserTokens.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/AddUuidColumnToUserTokens.java new file mode 100644 index 00000000000..a74a7ff5bf8 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/AddUuidColumnToUserTokens.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.usertokens; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.AddUuidColumnToTable; + +public class AddUuidColumnToUserTokens extends AddUuidColumnToTable { + private static final String TABLE = "user_tokens"; + + public AddUuidColumnToUserTokens(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/DropIdColumnOfUserTokensTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/DropIdColumnOfUserTokensTable.java new file mode 100644 index 00000000000..2bc3ea8fa6a --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/DropIdColumnOfUserTokensTable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.usertokens; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropIdColumn; + +public class DropIdColumnOfUserTokensTable extends DropIdColumn { + private static final String TABLE = "user_tokens"; + + public DropIdColumnOfUserTokensTable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/DropPrimaryKeyOnIdColumnOfUserTokensTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/DropPrimaryKeyOnIdColumnOfUserTokensTable.java new file mode 100644 index 00000000000..ef09bb82587 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/DropPrimaryKeyOnIdColumnOfUserTokensTable.java @@ -0,0 +1,32 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.usertokens; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; + +public class DropPrimaryKeyOnIdColumnOfUserTokensTable extends DropPrimaryKeyOnIdColumn { + private static final String TABLE_NAME = "user_tokens"; + + public DropPrimaryKeyOnIdColumnOfUserTokensTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { + super(db, dropPrimaryKeySqlGenerator, TABLE_NAME); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/MakeUserTokensUuidNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/MakeUserTokensUuidNotNullable.java new file mode 100644 index 00000000000..c785d2cb823 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/MakeUserTokensUuidNotNullable.java @@ -0,0 +1,31 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.usertokens; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.version.v84.common.MakeUuidColumnNotNullable; + +public class MakeUserTokensUuidNotNullable extends MakeUuidColumnNotNullable { + private static final String TABLE = "user_tokens"; + + public MakeUserTokensUuidNotNullable(Database db) { + super(db, TABLE); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/PopulateUserTokensUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/PopulateUserTokensUuid.java new file mode 100644 index 00000000000..0cb73f14d91 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/PopulateUserTokensUuid.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.usertokens; + +import java.sql.SQLException; +import org.sonar.core.util.UuidFactory; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulateUserTokensUuid extends DataChange { + + private final UuidFactory uuidFactory; + + public PopulateUserTokensUuid(Database db, UuidFactory uuidFactory) { + super(db); + this.uuidFactory = uuidFactory; + } + + @Override + protected void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select id from user_tokens where uuid is null order by id asc"); + massUpdate.update("update user_tokens set uuid = ? where id = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, uuidFactory.create()); + update.setLong(2, row.getLong(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/util/AddPrimaryKeyBuilder.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/util/AddPrimaryKeyBuilder.java new file mode 100644 index 00000000000..8772a2a1ec3 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/util/AddPrimaryKeyBuilder.java @@ -0,0 +1,46 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.util; + +import com.google.common.collect.Lists; +import java.util.List; + +import static com.google.common.base.Preconditions.checkState; +import static java.lang.String.format; +import static org.sonar.server.platform.db.migration.def.Validations.validateTableName; +import static org.sonar.server.platform.db.migration.sql.CreateTableBuilder.PRIMARY_KEY_PREFIX; + +public class AddPrimaryKeyBuilder { + + private final String tableName; + private final List primaryKey; + + public AddPrimaryKeyBuilder(String tableName, String column, String... moreColumns) { + this.tableName = validateTableName(tableName); + this.primaryKey = Lists.asList(column, moreColumns); + } + + public String build() { + checkState(primaryKey != null, "Primary key is missing"); + return format("ALTER TABLE %s ADD CONSTRAINT %s%s PRIMARY KEY (%s)", tableName, PRIMARY_KEY_PREFIX, tableName, + String.join(",", this.primaryKey)); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/util/DropPrimaryKeySqlGenerator.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/util/DropPrimaryKeySqlGenerator.java new file mode 100644 index 00000000000..51424addd83 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/util/DropPrimaryKeySqlGenerator.java @@ -0,0 +1,99 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.sonar.server.platform.db.migration.version.v84.util; + +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import org.sonar.db.Database; +import org.sonar.db.dialect.Dialect; +import org.sonar.db.dialect.H2; +import org.sonar.db.dialect.MsSql; +import org.sonar.db.dialect.Oracle; +import org.sonar.db.dialect.PostgreSql; + +import static java.lang.String.format; +import static java.util.Arrays.asList; +import static java.util.Collections.singletonList; + +public class DropPrimaryKeySqlGenerator { + private static final String GENERIC_DROP_CONSTRAINT_STATEMENT = "ALTER TABLE %s DROP CONSTRAINT %s"; + + private final Database db; + private SqlHelper sqlHelper; + + public DropPrimaryKeySqlGenerator(Database db, SqlHelper sqlHelper) { + this.db = db; + this.sqlHelper = sqlHelper; + } + + public List generate(String tableName, String columnName, boolean isAutoGenerated) throws SQLException { + Dialect dialect = db.getDialect(); + switch (dialect.getId()) { + case PostgreSql.ID: + return generateForPostgresSql(tableName, columnName, sqlHelper.getPostgresSqlConstraint(tableName)); + case MsSql.ID: + return generateForMsSql(tableName, sqlHelper.getMssqlConstraint(tableName)); + case Oracle.ID: + return generateForOracle(tableName, sqlHelper.getOracleConstraint(tableName), isAutoGenerated); + case H2.ID: + return generateForH2(tableName, columnName, sqlHelper.getH2Constraint(tableName)); + default: + throw new IllegalStateException(format("Unsupported database '%s'", dialect.getId())); + } + } + + private List generateForPostgresSql(String tableName, String column, String constraintName) throws SQLException { + List statements = new ArrayList<>(); + statements.add(format("ALTER TABLE %s ALTER COLUMN %s DROP DEFAULT", tableName, column)); + + String sequence = sqlHelper.getPostgresSqlSequence(tableName, column); + if (sequence != null) { + statements.add(format("DROP SEQUENCE %s", sequence)); + } + + statements.add(format(GENERIC_DROP_CONSTRAINT_STATEMENT, tableName, constraintName)); + + return statements; + } + + private static List generateForOracle(String tableName, String constraintName, boolean isAutoGenerated) { + List statements = new ArrayList<>(); + if (isAutoGenerated) { + statements.add(format("DROP TRIGGER %s_IDT", tableName)); + statements.add(format("DROP SEQUENCE %s_SEQ", tableName)); + } + + statements.add(format(GENERIC_DROP_CONSTRAINT_STATEMENT, tableName, constraintName)); + return statements; + } + + private static List generateForMsSql(String tableName, String constraintName) { + return singletonList(format(GENERIC_DROP_CONSTRAINT_STATEMENT, tableName, constraintName)); + } + + private static List generateForH2(String tableName, String column, String constraintName) { + return asList( + format(GENERIC_DROP_CONSTRAINT_STATEMENT, tableName, constraintName), + format("ALTER TABLE %s ALTER COLUMN %s INTEGER NOT NULL", tableName, column)); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/util/SqlHelper.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/util/SqlHelper.java new file mode 100644 index 00000000000..5c726879a73 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/util/SqlHelper.java @@ -0,0 +1,116 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.util; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Locale; +import org.sonar.db.Database; + +import static java.lang.String.format; + +public class SqlHelper { + + private final Database db; + + public SqlHelper(Database db) { + this.db = db; + } + + String getH2Constraint(String tableName) throws SQLException { + try (Connection connection = db.getDataSource().getConnection(); + PreparedStatement pstmt = connection + .prepareStatement(format("SELECT constraint_name " + + "FROM information_schema.constraints " + + "WHERE table_name = '%s' and constraint_type = 'PRIMARY KEY'", tableName.toUpperCase(Locale.ENGLISH))); + ResultSet rs = pstmt.executeQuery()) { + if (rs.next()) { + return rs.getString(1); + } + throw contraintNotFoundException(tableName); + } + } + + String getPostgresSqlConstraint(String tableName) throws SQLException { + try (Connection connection = db.getDataSource().getConnection(); + PreparedStatement pstmt = connection + .prepareStatement(format("SELECT conname " + + "FROM pg_constraint " + + "WHERE conrelid = " + + " (SELECT oid " + + " FROM pg_class " + + " WHERE relname LIKE '%s')", tableName)); + ResultSet rs = pstmt.executeQuery()) { + if (rs.next()) { + return rs.getString(1); + } + throw contraintNotFoundException(tableName); + } + } + + String getPostgresSqlSequence(String tableName, String columnName) throws SQLException { + try (Connection connection = db.getDataSource().getConnection(); + PreparedStatement pstmt = connection + .prepareStatement(format("SELECT pg_get_serial_sequence('%s', '%s')", tableName, columnName)); + ResultSet rs = pstmt.executeQuery()) { + if (rs.next()) { + return rs.getString(1); + } + throw new IllegalStateException(format("Cannot find sequence for table '%s' on column '%s'", tableName, columnName)); + } + } + + String getOracleConstraint(String tableName) throws SQLException { + try (Connection connection = db.getDataSource().getConnection(); + PreparedStatement pstmt = connection + .prepareStatement(format("SELECT constraint_name " + + "FROM user_constraints " + + "WHERE table_name = UPPER('%s') " + + "AND constraint_type='P'", tableName)); + ResultSet rs = pstmt.executeQuery()) { + if (rs.next()) { + return rs.getString(1); + } + throw contraintNotFoundException(tableName); + } + } + + String getMssqlConstraint(String tableName) throws SQLException { + try (Connection connection = db.getDataSource().getConnection(); + PreparedStatement pstmt = connection + .prepareStatement(format("SELECT name " + + "FROM sys.key_constraints " + + "WHERE type = 'PK' " + + "AND OBJECT_NAME(parent_object_id) = '%s'", tableName)); + ResultSet rs = pstmt.executeQuery()) { + if (rs.next()) { + return rs.getString(1); + } + throw contraintNotFoundException(tableName); + } + } + + private static IllegalStateException contraintNotFoundException(String tableName) { + return new IllegalStateException(format("Cannot find constraint for table '%s'", tableName)); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/DbVersion83Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/DbVersion83Test.java index e298cf83538..55d36072a29 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/DbVersion83Test.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/DbVersion83Test.java @@ -21,6 +21,7 @@ package org.sonar.server.platform.db.migration.version.v83; import org.junit.Test; import org.sonar.server.platform.db.migration.version.DbVersion; +import org.sonar.server.platform.db.migration.version.v84.DbVersion84; import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMigrationNotEmpty; import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMinimumMigrationNumber; diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/DropIdFromComponentsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/DropIdFromComponentsTableTest.java index fa6119e41a5..86ae9b4812c 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/DropIdFromComponentsTableTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/DropIdFromComponentsTableTest.java @@ -24,8 +24,8 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v83.util.SqlHelper; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; +import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; import static java.sql.Types.INTEGER; import static org.sonar.server.platform.db.migration.version.v83.DropIdFromComponentsTable.COLUMN_NAME; diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTableTest.java deleted file mode 100644 index 984ec7ba716..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.activeruleparameters; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("active_rule_parameters", "pk_active_rule_parameters", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/AddUuidColumnToActiveRuleParametersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/AddUuidColumnToActiveRuleParametersTest.java deleted file mode 100644 index 3ac39c0556c..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/AddUuidColumnToActiveRuleParametersTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.activeruleparameters; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUuidColumnToActiveRuleParametersTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToActiveRuleParametersTest.class, "schema.sql"); - - private DdlChange underTest = new AddUuidColumnToActiveRuleParametersTable(db.database()); - - @Before - public void setup() { - insertActiveRuleParameter(1L); - insertActiveRuleParameter(2L); - insertActiveRuleParameter(3L); - } - - @Test - public void add_uuid_column_to_active_rule_parameters() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("active_rule_parameters", "uuid", Types.VARCHAR, 40, true); - - assertThat(db.countSql("select count(id) from active_rule_parameters")) - .isEqualTo(3); - } - - private void insertActiveRuleParameter(Long id) { - db.executeInsert("active_rule_parameters", - "id", id, - "active_rule_id", id + 2, - "rules_parameter_id", id + 3); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/DropIdColumnOfActiveRuleParametersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/DropIdColumnOfActiveRuleParametersTableTest.java deleted file mode 100644 index 2f567d09ddb..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/DropIdColumnOfActiveRuleParametersTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.activeruleparameters; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfActiveRuleParametersTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfActiveRuleParametersTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIdColumnOfActiveRuleParametersTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("active_rule_parameters", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/DropPrimaryKeyOnIdColumnOfActiveRuleParametersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/DropPrimaryKeyOnIdColumnOfActiveRuleParametersTableTest.java deleted file mode 100644 index fa8b978aad1..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/DropPrimaryKeyOnIdColumnOfActiveRuleParametersTableTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.activeruleparameters; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v83.util.SqlHelper; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropPrimaryKeyOnIdColumnOfActiveRuleParametersTableTest { - - private static final String TABLE_NAME = "active_rule_parameters"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfActiveRuleParametersTableTest.class, "schema.sql"); - - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); - - private MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfActiveRuleParametersTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/MakeActiveRuleParametersUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/MakeActiveRuleParametersUuidColumnNotNullableTest.java deleted file mode 100644 index 79307cd4e2a..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/MakeActiveRuleParametersUuidColumnNotNullableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.activeruleparameters; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeActiveRuleParametersUuidColumnNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeActiveRuleParametersUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeActiveRuleParametersUuidColumnNotNullable(db.database()); - - @Test - public void created_at_and_uuid_columns_are_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("active_rule_parameters", "uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/PopulateActiveRuleParametersUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/PopulateActiveRuleParametersUuidTest.java deleted file mode 100644 index a6a4aeb001a..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/PopulateActiveRuleParametersUuidTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.activeruleparameters; - -import java.sql.SQLException; -import java.util.Objects; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateActiveRuleParametersUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateActiveRuleParametersUuidTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulateActiveRuleParametersUuid(db.database(), uuidFactory); - - @Test - public void populate_uuids() throws SQLException { - insertActiveRuleParameter(1L); - insertActiveRuleParameter(2L); - insertActiveRuleParameter(3L); - - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertActiveRuleParameter(1L); - insertActiveRuleParameter(2L); - insertActiveRuleParameter(3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - private void verifyUuidsAreNotNull() { - assertThat(db.select("select uuid from active_rule_parameters") - .stream() - .map(row -> row.get("UUID")) - .filter(Objects::isNull) - .collect(Collectors.toList())).isEmpty(); - } - - private void insertActiveRuleParameter(Long id) { - db.executeInsert("active_rule_parameters", - "id", id, - "active_rule_id", id + 2, - "rules_parameter_id", id + 3); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/AddActiveRuleUuidColumnToActiveRuleParametersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/AddActiveRuleUuidColumnToActiveRuleParametersTest.java deleted file mode 100644 index 2dbec7b5139..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/AddActiveRuleUuidColumnToActiveRuleParametersTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.activerules; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddActiveRuleUuidColumnToActiveRuleParametersTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddActiveRuleUuidColumnToActiveRuleParametersTest.class, "schema.sql"); - private DdlChange underTest = new AddActiveRuleUuidColumnToActiveRuleParameters(db.database()); - - @Before - public void setup() { - insertActiveRuleParameter(1L); - insertActiveRuleParameter(2L); - insertActiveRuleParameter(3L); - } - - @Test - public void add_active_rule_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("active_rule_parameters", "active_rule_uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable("active_rule_parameters")) - .isEqualTo(3); - } - - private void insertActiveRuleParameter(Long id) { - db.executeInsert("active_rule_parameters", - "uuid", "uuid" + id, - "rules_parameter_id", id, - "value", "value" + id, - "active_rule_id", id + 1); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/AddIndexOnActiveRuleUuidOfActiveRuleParametersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/AddIndexOnActiveRuleUuidOfActiveRuleParametersTableTest.java deleted file mode 100644 index 50d2a426913..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/AddIndexOnActiveRuleUuidOfActiveRuleParametersTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.activerules; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class AddIndexOnActiveRuleUuidOfActiveRuleParametersTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddIndexOnActiveRuleUuidOfActiveRuleParametersTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddIndexOnActiveRuleUuidOfActiveRuleParametersTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertIndex("active_rule_parameters", "arp_active_rule_uuid", "active_rule_uuid"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertIndex("active_rule_parameters", "arp_active_rule_uuid", "active_rule_uuid"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/AddPrimaryKeyOnUuidColumnOfActiveRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/AddPrimaryKeyOnUuidColumnOfActiveRulesTableTest.java deleted file mode 100644 index 4901ea16618..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/AddPrimaryKeyOnUuidColumnOfActiveRulesTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.activerules; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfActiveRulesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfActiveRulesTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddPrimaryKeyOnUuidColumnOfActiveRulesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("active_rules", "pk_active_rules", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/AddUuidColumnToActiveRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/AddUuidColumnToActiveRulesTableTest.java deleted file mode 100644 index 79911e5a627..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/AddUuidColumnToActiveRulesTableTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.activerules; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUuidColumnToActiveRulesTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToActiveRulesTableTest.class, "schema.sql"); - private DdlChange underTest = new AddUuidColumnToActiveRulesTable(db.database()); - - @Before - public void setup() { - insertActiveRule(1L); - insertActiveRule(2L); - insertActiveRule(3L); - } - - @Test - public void add_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("active_rules", "uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable("active_rules")) - .isEqualTo(3); - } - - private void insertActiveRule(Long id) { - db.executeInsert("active_rules", - "id", id, - "profile_id", id + 1, - "rule_id", id + 2, - "failure_level", id + 3); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/DropActiveRuleIdColumnOfActiveRuleParametersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/DropActiveRuleIdColumnOfActiveRuleParametersTableTest.java deleted file mode 100644 index 4976d78570e..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/DropActiveRuleIdColumnOfActiveRuleParametersTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.activerules; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropActiveRuleIdColumnOfActiveRuleParametersTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropActiveRuleIdColumnOfActiveRuleParametersTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropActiveRuleIdColumnOfActiveRuleParametersTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertColumnDefinition("active_rule_parameters", "active_rule_id", Types.INTEGER, null, false); - underTest.execute(); - db.assertColumnDoesNotExist("active_rule_parameters", "active_rule_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/DropIdColumnOfActiveRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/DropIdColumnOfActiveRulesTableTest.java deleted file mode 100644 index 10c82a5d282..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/DropIdColumnOfActiveRulesTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.activerules; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfActiveRulesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfActiveRulesTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropIdColumnOfActiveRulesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("active_rules", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/DropIndexOnActiveRuleIdOfActiveRuleParametersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/DropIndexOnActiveRuleIdOfActiveRuleParametersTableTest.java deleted file mode 100644 index 76597d2ae32..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/DropIndexOnActiveRuleIdOfActiveRuleParametersTableTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.activerules; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropIndexOnActiveRuleIdOfActiveRuleParametersTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIndexOnActiveRuleIdOfActiveRuleParametersTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIndexOnActiveRuleIdOfActiveRuleParametersTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertTableExists("active_rule_parameters"); - db.assertIndex("active_rule_parameters", "ix_arp_on_active_rule_id", "active_rule_id"); - - underTest.execute(); - - db.assertIndexDoesNotExist("active_rule_parameters", "ix_arp_on_active_rule_id"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertIndexDoesNotExist("active_rule_parameters", "ix_arp_on_active_rule_id"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/DropPrimaryKeyOnIdColumnOfActiveRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/DropPrimaryKeyOnIdColumnOfActiveRulesTableTest.java deleted file mode 100644 index 728f6967b74..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/DropPrimaryKeyOnIdColumnOfActiveRulesTableTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.server.platform.db.migration.version.v83.activerules; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v83.util.SqlHelper; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropPrimaryKeyOnIdColumnOfActiveRulesTableTest { - - private static final String TABLE_NAME = "active_rules"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfActiveRulesTableTest.class, "schema.sql"); - - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); - - private DdlChange underTest = new DropPrimaryKeyOnIdColumnOfActiveRulesTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/MakeActiveRuleParametersActiveRuleUuidNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/MakeActiveRuleParametersActiveRuleUuidNotNullableTest.java deleted file mode 100644 index ba881fb9cae..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/MakeActiveRuleParametersActiveRuleUuidNotNullableTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.activerules; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeActiveRuleParametersActiveRuleUuidNotNullableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeActiveRuleParametersActiveRuleUuidNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeActiveRuleParametersActiveRuleUuidNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("active_rule_parameters", "active_rule_uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/MakeActiveRulesUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/MakeActiveRulesUuidColumnNotNullableTest.java deleted file mode 100644 index a428387138e..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/MakeActiveRulesUuidColumnNotNullableTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.activerules; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeActiveRulesUuidColumnNotNullableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeActiveRulesUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeActiveRulesUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_nullable() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("active_rules", "uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/PopulateActiveRuleParametersActiveRuleUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/PopulateActiveRuleParametersActiveRuleUuidTest.java deleted file mode 100644 index 246c0ebb8d6..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/PopulateActiveRuleParametersActiveRuleUuidTest.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.activerules; - -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class PopulateActiveRuleParametersActiveRuleUuidTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateActiveRuleParametersActiveRuleUuidTest.class, "schema.sql"); - - private DataChange underTest = new PopulateActiveRuleParametersActiveRuleUuid(db.database()); - - @Test - public void populate_uuids() throws SQLException { - insertActiveRule(1L); - insertActiveRule(2L); - insertActiveRule(3L); - - insertActiveRuleParameter(4L, 1L); - insertActiveRuleParameter(5L, 2L); - insertActiveRuleParameter(6L, 3L); - - underTest.execute(); - - assertThatTableContains( - tuple("uuid4", 1L, "uuid1", "value4"), - tuple("uuid5", 2L, "uuid2", "value5"), - tuple("uuid6", 3L, "uuid3", "value6") - ); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertActiveRule(1L); - insertActiveRule(2L); - insertActiveRule(3L); - - insertActiveRuleParameter(4L, 1L); - insertActiveRuleParameter(5L, 2L); - insertActiveRuleParameter(6L, 3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - assertThatTableContains( - tuple("uuid4", 1L, "uuid1", "value4"), - tuple("uuid5", 2L, "uuid2", "value5"), - tuple("uuid6", 3L, "uuid3", "value6") - ); - } - - private void assertThatTableContains(Tuple... tuples) { - List> select = db.select("select uuid, active_rule_id, active_rule_uuid, value from active_rule_parameters"); - assertThat(select).extracting(m -> m.get("UUID"), m -> m.get("ACTIVE_RULE_ID"), m -> m.get("ACTIVE_RULE_UUID"), m -> m.get("VALUE")) - .containsExactlyInAnyOrder(tuples); - } - - private void insertActiveRule(Long id) { - db.executeInsert("active_rules", - "uuid", "uuid" + id, - "id", id, - "profile_id", id + 1, - "rule_id", id + 2, - "failure_level", id + 3); - } - - private void insertActiveRuleParameter(Long id, Long activeRuleId) { - db.executeInsert("active_rule_parameters", - "uuid", "uuid" + id, - "rules_parameter_id", id, - "value", "value" + id, - "active_rule_id", activeRuleId); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/PopulateActiveRulesUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/PopulateActiveRulesUuidTest.java deleted file mode 100644 index f8504e8c25a..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/activerules/PopulateActiveRulesUuidTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.activerules; - -import java.sql.SQLException; -import java.util.Objects; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateActiveRulesUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateActiveRulesUuidTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulateActiveRulesUuid(db.database(), uuidFactory); - - @Test - public void populate_uuids() throws SQLException { - insertActiveRule(1L); - insertActiveRule(2L); - insertActiveRule(3L); - - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertActiveRule(1L); - insertActiveRule(2L); - insertActiveRule(3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - private void verifyUuidsAreNotNull() { - assertThat(db.select("select uuid from active_rules") - .stream() - .map(row -> row.get("UUID")) - .filter(Objects::isNull) - .collect(Collectors.toList())).isEmpty(); - } - - private void insertActiveRule(Long id) { - db.executeInsert("active_rules", - "id", id, - "profile_id", id + 1, - "rule_id", id + 2, - "failure_level", id + 3); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTableTest.java deleted file mode 100644 index 543a5034e13..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTableTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.ceactivity; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfCeActivityTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfCeActivityTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddPrimaryKeyOnUuidColumnOfCeActivityTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("ce_activity", "pk_ce_activity", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/ceactivity/DropIdColumnOfCeActivityTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/ceactivity/DropIdColumnOfCeActivityTableTest.java deleted file mode 100644 index 51ffa9f2e7b..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/ceactivity/DropIdColumnOfCeActivityTableTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.ceactivity; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfCeActivityTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfCeActivityTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIdColumnOfCeActivityTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("ce_activity", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTableTest.java deleted file mode 100644 index dee767ffbe1..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTableTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.ceactivity; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v83.util.SqlHelper; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropPrimaryKeyOnIdColumnOfCeActivityTableTest { - - private static final String TABLE_NAME = "ce_activity"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfCeActivityTableTest.class, "schema.sql"); - - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); - - private MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfCeActivityTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/cequeue/AddPrimaryKeyOnUuidColumnOfCeQueueTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/cequeue/AddPrimaryKeyOnUuidColumnOfCeQueueTableTest.java deleted file mode 100644 index f0833b7a32b..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/cequeue/AddPrimaryKeyOnUuidColumnOfCeQueueTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.cequeue; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfCeQueueTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfCeQueueTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddPrimaryKeyOnUuidColumnOfCeQueueTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("ce_queue", "pk_ce_queue", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/cequeue/DropIdColumnOfCeQueueTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/cequeue/DropIdColumnOfCeQueueTableTest.java deleted file mode 100644 index ca48e9b833f..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/cequeue/DropIdColumnOfCeQueueTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.cequeue; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfCeQueueTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfCeQueueTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIdColumnOfCeQueueTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("ce_queue", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/cequeue/DropPrimaryKeyOnIdColumnOfCeQueueTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/cequeue/DropPrimaryKeyOnIdColumnOfCeQueueTableTest.java deleted file mode 100644 index 525f83c6612..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/cequeue/DropPrimaryKeyOnIdColumnOfCeQueueTableTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.server.platform.db.migration.version.v83.cequeue; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v83.util.SqlHelper; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropPrimaryKeyOnIdColumnOfCeQueueTableTest { - - private static final String TABLE_NAME = "ce_queue"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfCeQueueTableTest.class, "schema.sql"); - - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); - - private MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfCeQueueTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/cequeue/DropUniqueIndexOnUuidColumnOfCeQueueTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/cequeue/DropUniqueIndexOnUuidColumnOfCeQueueTableTest.java deleted file mode 100644 index 8c5aba9f593..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/cequeue/DropUniqueIndexOnUuidColumnOfCeQueueTableTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.cequeue; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropUniqueIndexOnUuidColumnOfCeQueueTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropUniqueIndexOnUuidColumnOfCeQueueTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropUniqueIndexOnUuidColumnOfCeQueueTable(db.database()); - - @Test - public void execute_drop_index() throws SQLException { - db.assertUniqueIndex("ce_queue", "ce_queue_uuid", "uuid"); - - underTest.execute(); - - db.assertIndexDoesNotExist("ce_queue", "ce_queue_uuid"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTableTest.java deleted file mode 100644 index ee7c4bfac5a..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.duplicationsindex; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("duplications_index", "pk_duplications_index", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/AddUuidToDuplicationsIndexTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/AddUuidToDuplicationsIndexTableTest.java deleted file mode 100644 index 2cb23b81956..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/AddUuidToDuplicationsIndexTableTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.duplicationsindex; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUuidToDuplicationsIndexTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidToDuplicationsIndexTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddUuidToDuplicationsIndexTable(db.database()); - - private UuidFactoryFast uuidFactory = UuidFactoryFast.getInstance(); - - @Before - public void setup() { - insertDuplicationsIndex(1L); - insertDuplicationsIndex(2L); - insertDuplicationsIndex(3L); - } - - @Test - public void add_uuid_column_to_duplications_index() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("duplications_index", "uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable("duplications_index")) - .isEqualTo(3); - } - - private void insertDuplicationsIndex(Long id) { - db.executeInsert("duplications_index", - "id", id, - "hash", uuidFactory.create(), - "index_in_file", id + 1, - "start_line", id + 2, - "end_line", id + 3, - "component_uuid", uuidFactory.create(), - "analysis_uuid", uuidFactory.create()); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/DropIdColumnOfDuplicationsIndexTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/DropIdColumnOfDuplicationsIndexTableTest.java deleted file mode 100644 index dbff05aa390..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/DropIdColumnOfDuplicationsIndexTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.duplicationsindex; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfDuplicationsIndexTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfDuplicationsIndexTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIdColumnOfDuplicationsIndexTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("duplications_index", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/DropPrimaryKeyOnIdColumnOfDuplicationsIndexTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/DropPrimaryKeyOnIdColumnOfDuplicationsIndexTableTest.java deleted file mode 100644 index 8bc11e1d181..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/DropPrimaryKeyOnIdColumnOfDuplicationsIndexTableTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.duplicationsindex; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v83.util.SqlHelper; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropPrimaryKeyOnIdColumnOfDuplicationsIndexTableTest { - - private static final String TABLE_NAME = "duplications_index"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfDuplicationsIndexTableTest.class, "schema.sql"); - - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); - - private MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfDuplicationsIndexTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/MakeDuplicationsIndexUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/MakeDuplicationsIndexUuidColumnNotNullableTest.java deleted file mode 100644 index 522166c71a6..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/MakeDuplicationsIndexUuidColumnNotNullableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.duplicationsindex; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeDuplicationsIndexUuidColumnNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeDuplicationsIndexUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeDuplicationsIndexUuidColumnNotNullable(db.database()); - - @Test - public void created_at_and_uuid_columns_are_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("duplications_index", "uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/PopulateDuplicationsIndexUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/PopulateDuplicationsIndexUuidTest.java deleted file mode 100644 index df4baa1c460..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/PopulateDuplicationsIndexUuidTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.duplicationsindex; - -import java.sql.SQLException; -import java.util.Objects; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateDuplicationsIndexUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateDuplicationsIndexUuidTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulateDuplicationsIndexUuid(db.database(), uuidFactory); - - @Test - public void populate_uuids() throws SQLException { - insertDuplicationsIndex(1L); - insertDuplicationsIndex(2L); - insertDuplicationsIndex(3L); - - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertDuplicationsIndex(1L); - insertDuplicationsIndex(2L); - insertDuplicationsIndex(3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - private void verifyUuidsAreNotNull() { - assertThat(db.select("select uuid from duplications_index") - .stream() - .map(row -> row.get("UUID")) - .filter(Objects::isNull) - .collect(Collectors.toList())).isEmpty(); - } - - private void insertDuplicationsIndex(Long id) { - db.executeInsert("duplications_index", - "id", id, - "hash", uuidFactory.create(), - "index_in_file", id + 1, - "start_line", id + 2, - "end_line", id + 3, - "component_uuid", uuidFactory.create(), - "analysis_uuid", uuidFactory.create()); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/events/AddPrimaryKeyOnUuidColumnOfEventsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/events/AddPrimaryKeyOnUuidColumnOfEventsTableTest.java deleted file mode 100644 index a7d546f9842..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/events/AddPrimaryKeyOnUuidColumnOfEventsTableTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.events; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfEventsTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfEventsTableTest.class, "schema.sql"); - - private AddPrimaryKeyOnUuidColumnOfEventsTable underTest = new AddPrimaryKeyOnUuidColumnOfEventsTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("events", "pk_events", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/events/DropIdColumnOfEventsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/events/DropIdColumnOfEventsTableTest.java deleted file mode 100644 index 220f09c2aa9..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/events/DropIdColumnOfEventsTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.events; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfEventsTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfEventsTableTest.class, "schema.sql"); - - private DropIdColumnOfEventsTable underTest = new DropIdColumnOfEventsTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("events", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/events/DropPrimaryKeyOnIdColumnOfEventsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/events/DropPrimaryKeyOnIdColumnOfEventsTableTest.java deleted file mode 100644 index 2ad8922b8a6..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/events/DropPrimaryKeyOnIdColumnOfEventsTableTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.server.platform.db.migration.version.v83.events; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v83.util.SqlHelper; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropPrimaryKeyOnIdColumnOfEventsTableTest { - - private static final String TABLE_NAME = "events"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfEventsTableTest.class, "schema.sql"); - - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); - - private DropPrimaryKeyOnIdColumnOfEventsTable underTest = new DropPrimaryKeyOnIdColumnOfEventsTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/filesources/AddPrimaryKeyOnUuidColumnOfFileSourcesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/filesources/AddPrimaryKeyOnUuidColumnOfFileSourcesTableTest.java deleted file mode 100644 index d74453a6c9e..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/filesources/AddPrimaryKeyOnUuidColumnOfFileSourcesTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.filesources; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfFileSourcesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfFileSourcesTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddPrimaryKeyOnUuidColumnOfFileSourcesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("file_sources", "pk_file_sources", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/filesources/AddUuidColumnToFileSourcesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/filesources/AddUuidColumnToFileSourcesTableTest.java deleted file mode 100644 index d8739496423..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/filesources/AddUuidColumnToFileSourcesTableTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.filesources; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUuidColumnToFileSourcesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToFileSourcesTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddUuidColumnToFileSourcesTable(db.database()); - - private UuidFactoryFast uuidFactory = UuidFactoryFast.getInstance(); - - @Before - public void setup() { - insertFileSources(1L); - insertFileSources(2L); - insertFileSources(3L); - } - - @Test - public void add_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("file_sources", "uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable("file_sources")) - .isEqualTo(3); - } - - private void insertFileSources(Long id) { - db.executeInsert("file_sources", - "id", id, - "project_uuid", uuidFactory.create(), - "file_uuid", uuidFactory.create(), - "line_count", id + 1, - "created_at", id + 2, - "updated_at", id + 3); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/filesources/DropIdColumnOfFileSourcesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/filesources/DropIdColumnOfFileSourcesTableTest.java deleted file mode 100644 index b0132fb007b..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/filesources/DropIdColumnOfFileSourcesTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.filesources; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfFileSourcesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfFileSourcesTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropIdColumnOfFileSourcesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("file_sources", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/filesources/DropPrimaryKeyOnIdColumnOfFileSourcesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/filesources/DropPrimaryKeyOnIdColumnOfFileSourcesTableTest.java deleted file mode 100644 index 7fcf0f3c7d3..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/filesources/DropPrimaryKeyOnIdColumnOfFileSourcesTableTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.server.platform.db.migration.version.v83.filesources; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v83.util.SqlHelper; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropPrimaryKeyOnIdColumnOfFileSourcesTableTest { - - private static final String TABLE_NAME = "file_sources"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfFileSourcesTableTest.class, "schema.sql"); - - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); - - private DdlChange underTest = new DropPrimaryKeyOnIdColumnOfFileSourcesTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/filesources/MakeFileSourcesUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/filesources/MakeFileSourcesUuidColumnNotNullableTest.java deleted file mode 100644 index 111984bc7f1..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/filesources/MakeFileSourcesUuidColumnNotNullableTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.filesources; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeFileSourcesUuidColumnNotNullableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeFileSourcesUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeFileSourcesUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_nullable() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("file_sources", "uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/filesources/PopulateFileSourcesUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/filesources/PopulateFileSourcesUuidTest.java deleted file mode 100644 index 24c48e42de0..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/filesources/PopulateFileSourcesUuidTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.filesources; - -import java.sql.SQLException; -import java.util.Objects; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateFileSourcesUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateFileSourcesUuidTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulateFileSourcesUuid(db.database(), uuidFactory); - - @Test - public void populate_uuids() throws SQLException { - insertFileSources(1L); - insertFileSources(2L); - insertFileSources(3L); - - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertFileSources(1L); - insertFileSources(2L); - insertFileSources(3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - private void verifyUuidsAreNotNull() { - assertThat(db.select("select uuid from file_sources") - .stream() - .map(row -> row.get("UUID")) - .filter(Objects::isNull) - .collect(Collectors.toList())).isEmpty(); - } - - private void insertFileSources(Long id) { - db.executeInsert("file_sources", - "id", id, - "project_uuid", uuidFactory.create(), - "file_uuid", uuidFactory.create(), - "line_count", id + 1, - "created_at", id + 2, - "updated_at", id + 3); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/grouproles/AddPrimaryKeyOnUuidColumnOfGroupRolesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/grouproles/AddPrimaryKeyOnUuidColumnOfGroupRolesTableTest.java deleted file mode 100644 index 420d3401f03..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/grouproles/AddPrimaryKeyOnUuidColumnOfGroupRolesTableTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.grouproles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfGroupRolesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfGroupRolesTableTest.class, "schema.sql"); - - private AddPrimaryKeyOnUuidColumnOfGroupRolesTable underTest = new AddPrimaryKeyOnUuidColumnOfGroupRolesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("group_roles", "pk_group_roles", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/grouproles/AddUuidColumnToGroupRolesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/grouproles/AddUuidColumnToGroupRolesTableTest.java deleted file mode 100644 index b0841a2ab15..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/grouproles/AddUuidColumnToGroupRolesTableTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.grouproles; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUuidColumnToGroupRolesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToGroupRolesTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddUuidColumnToGroupRolesTable(db.database()); - - private UuidFactoryFast uuidFactory = UuidFactoryFast.getInstance(); - - @Before - public void setup() { - insertGroupRoles(1L); - insertGroupRoles(2L); - insertGroupRoles(3L); - } - - @Test - public void add_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("group_roles", "uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable("group_roles")) - .isEqualTo(3); - } - - private void insertGroupRoles(Long id) { - db.executeInsert("group_roles", - "id", id, - "organization_uuid", uuidFactory.create(), - "group_id", id + 1, - "role", id + 2, - "component_uuid", uuidFactory.create()); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/grouproles/DropIdColumnOfGroupRolesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/grouproles/DropIdColumnOfGroupRolesTableTest.java deleted file mode 100644 index 5ad2078afc0..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/grouproles/DropIdColumnOfGroupRolesTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.grouproles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfGroupRolesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfGroupRolesTableTest.class, "schema.sql"); - - private DropIdColumnOfGroupRolesTable underTest = new DropIdColumnOfGroupRolesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("group_roles", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/grouproles/DropPrimaryKeyOnIdColumnOfGroupRolesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/grouproles/DropPrimaryKeyOnIdColumnOfGroupRolesTableTest.java deleted file mode 100644 index 35333a4b651..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/grouproles/DropPrimaryKeyOnIdColumnOfGroupRolesTableTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.server.platform.db.migration.version.v83.grouproles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v83.util.SqlHelper; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropPrimaryKeyOnIdColumnOfGroupRolesTableTest { - - private static final String TABLE_NAME = "group_roles"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfGroupRolesTableTest.class, "schema.sql"); - - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); - - private DropPrimaryKeyOnIdColumnOfGroupRolesTable underTest = new DropPrimaryKeyOnIdColumnOfGroupRolesTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/grouproles/MakeGroupRolesUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/grouproles/MakeGroupRolesUuidColumnNotNullableTest.java deleted file mode 100644 index 86f82e8470e..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/grouproles/MakeGroupRolesUuidColumnNotNullableTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.grouproles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeGroupRolesUuidColumnNotNullableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeGroupRolesUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeGroupRolesUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_nullable() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("group_roles", "uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/grouproles/PopulateGroupRolesUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/grouproles/PopulateGroupRolesUuidTest.java deleted file mode 100644 index de1b72765ba..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/grouproles/PopulateGroupRolesUuidTest.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.grouproles; - -import java.sql.SQLException; -import java.util.Objects; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateGroupRolesUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateGroupRolesUuidTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulateGroupRolesUuid(db.database(), uuidFactory); - - @Test - public void populate_uuids() throws SQLException { - insertGroupRoles(1L); - insertGroupRoles(2L); - insertGroupRoles(3L); - - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertGroupRoles(1L); - insertGroupRoles(2L); - insertGroupRoles(3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - private void verifyUuidsAreNotNull() { - assertThat(db.select("select uuid from group_roles") - .stream() - .map(row -> row.get("UUID")) - .filter(Objects::isNull) - .collect(Collectors.toList())).isEmpty(); - } - - private void insertGroupRoles(Long id) { - db.executeInsert("group_roles", - "id", id, - "uuid", uuidFactory.create(), - "organization_uuid", uuidFactory.create(), - "group_id", id + 1, - "role", id + 2, - "component_uuid", uuidFactory.create()); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/AddPrimaryKeyOnUuidColumnOfGroupsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/AddPrimaryKeyOnUuidColumnOfGroupsTableTest.java deleted file mode 100644 index 59580c6e136..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/AddPrimaryKeyOnUuidColumnOfGroupsTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfGroupsTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfGroupsTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddPrimaryKeyOnUuidColumnOfGroupsTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("groups", "pk_groups", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/AddUuidColumnToGroupsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/AddUuidColumnToGroupsTableTest.java deleted file mode 100644 index faba17b1d66..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/AddUuidColumnToGroupsTableTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUuidColumnToGroupsTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToGroupsTableTest.class, "schema.sql"); - private DdlChange underTest = new AddUuidColumnToGroupsTable(db.database()); - - @Before - public void setup() { - insertGroups(1L); - insertGroups(2L); - insertGroups(3L); - } - - @Test - public void add_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("groups", "uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable("groups")) - .isEqualTo(3); - } - - private void insertGroups(Long id) { - db.executeInsert("groups", - "id", id, - "organization_uuid", "org" + id, - "name", "name" + id); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/DropIdColumnOfGroupsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/DropIdColumnOfGroupsTableTest.java deleted file mode 100644 index 99b7379f9c5..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/DropIdColumnOfGroupsTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfGroupsTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfGroupsTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropIdColumnOfGroupsTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("groups", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/DropPrimaryKeyOnIdColumnOfGroupsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/DropPrimaryKeyOnIdColumnOfGroupsTableTest.java deleted file mode 100644 index 9526f9f5261..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/DropPrimaryKeyOnIdColumnOfGroupsTableTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.server.platform.db.migration.version.v83.groups; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v83.util.SqlHelper; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropPrimaryKeyOnIdColumnOfGroupsTableTest { - - private static final String TABLE_NAME = "groups"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfGroupsTableTest.class, "schema.sql"); - - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); - - private DdlChange underTest = new DropPrimaryKeyOnIdColumnOfGroupsTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/MakeGroupsUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/MakeGroupsUuidColumnNotNullableTest.java deleted file mode 100644 index 7f381630b7f..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/MakeGroupsUuidColumnNotNullableTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeGroupsUuidColumnNotNullableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeGroupsUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeGroupsUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_nullable() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("groups", "uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/PopulateGroupsUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/PopulateGroupsUuidTest.java deleted file mode 100644 index 5d0839adc6f..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/PopulateGroupsUuidTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups; - -import java.sql.SQLException; -import java.util.Objects; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateGroupsUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateGroupsUuidTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulateGroupsUuid(db.database(), uuidFactory); - - @Test - public void populate_uuids() throws SQLException { - insertGroups(1L); - insertGroups(2L); - insertGroups(3L); - - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertGroups(1L); - insertGroups(2L); - insertGroups(3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - private void verifyUuidsAreNotNull() { - assertThat(db.select("select uuid from groups") - .stream() - .map(row -> row.get("UUID")) - .filter(Objects::isNull) - .collect(Collectors.toList())).isEmpty(); - } - - private void insertGroups(Long id) { - db.executeInsert("groups", - "id", id, - "organization_uuid", "org" + id, - "name", "name" + id); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/AddGroupUuidColumnToGroupRolesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/AddGroupUuidColumnToGroupRolesTest.java deleted file mode 100644 index ededdb1e326..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/AddGroupUuidColumnToGroupRolesTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.grouproles; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddGroupUuidColumnToGroupRolesTest { - private static final String TABLE_NAME = "group_roles"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddGroupUuidColumnToGroupRolesTest.class, "schema.sql"); - private DdlChange underTest = new AddGroupUuidColumnToGroupRoles(db.database()); - - @Before - public void setup() { - insertGroupRole(1L); - insertGroupRole(2L); - insertGroupRole(3L); - } - - @Test - public void add_active_rule_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition(TABLE_NAME, "group_uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable(TABLE_NAME)) - .isEqualTo(3); - } - - private void insertGroupRole(Long id) { - db.executeInsert(TABLE_NAME, - "uuid", "uuid" + id, - "group_id", id + 1, - "role", "role" + id, - "organization_uuid", "org" + id - ); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/AddIndexOnGroupUuidOfGroupRolesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/AddIndexOnGroupUuidOfGroupRolesTableTest.java deleted file mode 100644 index 56c0530bb5a..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/AddIndexOnGroupUuidOfGroupRolesTableTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.grouproles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class AddIndexOnGroupUuidOfGroupRolesTableTest { - private static final String TABLE_NAME = "group_roles"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddIndexOnGroupUuidOfGroupRolesTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddIndexOnGroupUuidOfGroupRolesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertUniqueIndex(TABLE_NAME, "uniq_group_roles", "organization_uuid", "group_uuid", - "component_uuid", "role"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertUniqueIndex(TABLE_NAME, "uniq_group_roles", "organization_uuid", "group_uuid", - "component_uuid", "role"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/DropGroupIdColumnOfGroupRolesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/DropGroupIdColumnOfGroupRolesTableTest.java deleted file mode 100644 index e2131596aee..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/DropGroupIdColumnOfGroupRolesTableTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.grouproles; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropGroupIdColumnOfGroupRolesTableTest { - private static final String TABLE_NAME = "group_roles"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropGroupIdColumnOfGroupRolesTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropGroupIdColumnOfGroupRolesTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertColumnDefinition(TABLE_NAME, "group_id", Types.INTEGER, null, true); - underTest.execute(); - db.assertColumnDoesNotExist(TABLE_NAME, "group_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/DropIndexOnGroupIdOfGroupRolesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/DropIndexOnGroupIdOfGroupRolesTableTest.java deleted file mode 100644 index fa93afa0118..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/DropIndexOnGroupIdOfGroupRolesTableTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.grouproles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropIndexOnGroupIdOfGroupRolesTableTest { - private static final String TABLE_NAME = "group_roles"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIndexOnGroupIdOfGroupRolesTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIndexOnGroupIdOfGroupRolesTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertTableExists(TABLE_NAME); - db.assertUniqueIndex(TABLE_NAME, "uniq_group_roles", "organization_uuid", "group_id", - "component_uuid", "role"); - - underTest.execute(); - - db.assertIndexDoesNotExist(TABLE_NAME, "uniq_group_roles"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertIndexDoesNotExist(TABLE_NAME, "uniq_group_roles"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/PopulateGroupRolesGroupUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/PopulateGroupRolesGroupUuidTest.java deleted file mode 100644 index 6511f7c1bb6..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/PopulateGroupRolesGroupUuidTest.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.grouproles; - -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class PopulateGroupRolesGroupUuidTest { - private static final String TABLE_NAME = "group_roles"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateGroupRolesGroupUuidTest.class, "schema.sql"); - - private DataChange underTest = new PopulateGroupRolesGroupUuid(db.database()); - - @Test - public void populate_uuids() throws SQLException { - insertGroup(1L); - insertGroup(2L); - insertGroup(3L); - - insertGroupRole(4L, 1L); - insertGroupRole(5L, 2L); - insertGroupRole(6L, 3L); - - underTest.execute(); - - assertThatTableContains( - tuple("uuid4", 1L, "uuid1"), - tuple("uuid5", 2L, "uuid2"), - tuple("uuid6", 3L, "uuid3") - ); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertGroup(1L); - insertGroup(2L); - insertGroup(3L); - - insertGroupRole(4L, 1L); - insertGroupRole(5L, 2L); - insertGroupRole(6L, 3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - assertThatTableContains( - tuple("uuid4", 1L, "uuid1"), - tuple("uuid5", 2L, "uuid2"), - tuple("uuid6", 3L, "uuid3") - ); - } - - private void assertThatTableContains(Tuple... tuples) { - List> select = db.select("select uuid, group_id, group_uuid from " + TABLE_NAME); - assertThat(select).extracting(m -> m.get("UUID"), m -> m.get("GROUP_ID"), m -> m.get("GROUP_UUID")) - .containsExactlyInAnyOrder(tuples); - } - - private void insertGroup(Long id) { - db.executeInsert("groups", - "id", id, - "uuid", "uuid" + id, - "organization_uuid", "org" + id, - "name", "name" + id); - } - - private void insertGroupRole(Long id, Long groupId) { - db.executeInsert(TABLE_NAME, - "uuid", "uuid" + id, - "group_id", groupId, - "role", "role" + id, - "organization_uuid", "org" + id - ); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/AddGroupUuidColumnToGroupsUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/AddGroupUuidColumnToGroupsUsersTest.java deleted file mode 100644 index 2a1fe79311c..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/AddGroupUuidColumnToGroupsUsersTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.groupsusers; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddGroupUuidColumnToGroupsUsersTest { - private static final String TABLE_NAME = "groups_users"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddGroupUuidColumnToGroupsUsersTest.class, "schema.sql"); - private DdlChange underTest = new AddGroupUuidColumnToGroupsUsers(db.database()); - - @Before - public void setup() { - insertGroupsUser(1L); - insertGroupsUser(2L); - insertGroupsUser(3L); - } - - @Test - public void add_active_rule_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition(TABLE_NAME, "group_uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable(TABLE_NAME)) - .isEqualTo(3); - } - - private void insertGroupsUser(Long id) { - db.executeInsert(TABLE_NAME, - "user_id", id, - "group_id", id + 1 - ); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/AddIndexOnGroupUuidOfGroupsUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/AddIndexOnGroupUuidOfGroupsUsersTableTest.java deleted file mode 100644 index 329ea7e1765..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/AddIndexOnGroupUuidOfGroupsUsersTableTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.groupsusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class AddIndexOnGroupUuidOfGroupsUsersTableTest { - private static final String TABLE_NAME = "groups_users"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddIndexOnGroupUuidOfGroupsUsersTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddIndexOnGroupUuidOfGroupsUsersTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertIndex(TABLE_NAME, "index_groups_users_group_uuid", "group_uuid"); - db.assertUniqueIndex(TABLE_NAME, "groups_users_unique", "group_uuid", "user_id"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertIndex(TABLE_NAME, "index_groups_users_group_uuid", "group_uuid"); - db.assertUniqueIndex(TABLE_NAME, "groups_users_unique", "group_uuid", "user_id"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/DropGroupIdColumnOfGroupsUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/DropGroupIdColumnOfGroupsUsersTableTest.java deleted file mode 100644 index 9311b335825..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/DropGroupIdColumnOfGroupsUsersTableTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.groupsusers; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropGroupIdColumnOfGroupsUsersTableTest { - private static final String TABLE_NAME = "groups_users"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropGroupIdColumnOfGroupsUsersTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropGroupIdColumnOfGroupsUsersTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertColumnDefinition(TABLE_NAME, "group_id", Types.BIGINT, null, true); - underTest.execute(); - db.assertColumnDoesNotExist(TABLE_NAME, "group_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/DropIndexOnGroupIdOfGroupsUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/DropIndexOnGroupIdOfGroupsUsersTableTest.java deleted file mode 100644 index 825d4132213..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/DropIndexOnGroupIdOfGroupsUsersTableTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.groupsusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropIndexOnGroupIdOfGroupsUsersTableTest { - private static final String TABLE_NAME = "groups_users"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIndexOnGroupIdOfGroupsUsersTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIndexOnGroupIdOfGroupsUsersTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertTableExists(TABLE_NAME); - db.assertIndex(TABLE_NAME, "index_groups_users_on_group_id", "group_id"); - db.assertUniqueIndex(TABLE_NAME, "groups_users_unique", "group_id", "user_id"); - - underTest.execute(); - - db.assertIndexDoesNotExist(TABLE_NAME, "index_groups_users_on_group_id"); - db.assertIndexDoesNotExist(TABLE_NAME, "groups_users_unique"); - - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertIndexDoesNotExist(TABLE_NAME, "index_groups_users_on_group_id"); - db.assertIndexDoesNotExist(TABLE_NAME, "groups_users_unique"); - - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/MakeGroupsUsersGroupUuidNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/MakeGroupsUsersGroupUuidNotNullableTest.java deleted file mode 100644 index 3afcc2bd638..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/MakeGroupsUsersGroupUuidNotNullableTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.groupsusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeGroupsUsersGroupUuidNotNullableTest { - private static final String TABLE_NAME = "groups_users"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeGroupsUsersGroupUuidNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeGroupsUsersGroupUuidNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition(TABLE_NAME, "group_uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/PopulateGroupsUsersGroupUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/PopulateGroupsUsersGroupUuidTest.java deleted file mode 100644 index 9196b14f2e5..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/PopulateGroupsUsersGroupUuidTest.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.groupsusers; - -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class PopulateGroupsUsersGroupUuidTest { - private static final String TABLE_NAME = "groups_users"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateGroupsUsersGroupUuidTest.class, "schema.sql"); - - private DataChange underTest = new PopulateGroupsUsersGroupUuid(db.database()); - - @Test - public void populate_uuids() throws SQLException { - insertGroup(1L); - insertGroup(2L); - insertGroup(3L); - - insertGroupsUser(4L, 1L); - insertGroupsUser(5L, 2L); - insertGroupsUser(6L, 3L); - - underTest.execute(); - - assertThatTableContains( - tuple(1L, "uuid1"), - tuple(2L, "uuid2"), - tuple(3L, "uuid3") - ); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertGroup(1L); - insertGroup(2L); - insertGroup(3L); - - insertGroupsUser(4L, 1L); - insertGroupsUser(5L, 2L); - insertGroupsUser(6L, 3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - assertThatTableContains( - tuple( 1L, "uuid1"), - tuple(2L, "uuid2"), - tuple(3L, "uuid3") - ); - } - - private void assertThatTableContains(Tuple... tuples) { - List> select = db.select("select group_id, group_uuid from " + TABLE_NAME); - assertThat(select).extracting( m -> m.get("GROUP_ID"), m -> m.get("GROUP_UUID")) - .containsExactlyInAnyOrder(tuples); - } - - private void insertGroup(Long id) { - db.executeInsert("groups", - "id", id, - "uuid", "uuid" + id, - "organization_uuid", "org" + id); - } - - private void insertGroupsUser(Long id, Long group) { - db.executeInsert(TABLE_NAME, - "user_id", id, - "group_id", group - ); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/organizations/AddDefaultGroupUuidColumnToOrganizationsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/organizations/AddDefaultGroupUuidColumnToOrganizationsTest.java deleted file mode 100644 index a054c1f88bf..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/organizations/AddDefaultGroupUuidColumnToOrganizationsTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.organizations; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddDefaultGroupUuidColumnToOrganizationsTest { - private static final String TABLE_NAME = "organizations"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddDefaultGroupUuidColumnToOrganizationsTest.class, "schema.sql"); - private DdlChange underTest = new AddDefaultGroupUuidColumnToOrganizations(db.database()); - - @Before - public void setup() { - insertOrganization(1L); - insertOrganization(2L); - insertOrganization(3L); - } - - @Test - public void add_active_rule_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition(TABLE_NAME, "default_group_uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable(TABLE_NAME)) - .isEqualTo(3); - } - - private void insertOrganization(Long id) { - db.executeInsert(TABLE_NAME, - "uuid", "uuid" + id, - "kee", "kee" + id, - "name", "name" + id, - "default_quality_gate_uuid", "default_quality_gate_uuid" + id, - "new_project_private", true, - "subscription", "subscription" + id, - "created_at", id + 1, - "updated_at", id + 2 - ); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/organizations/DropDefaultGroupIdColumnOfOrganizationsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/organizations/DropDefaultGroupIdColumnOfOrganizationsTableTest.java deleted file mode 100644 index 223df954b44..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/organizations/DropDefaultGroupIdColumnOfOrganizationsTableTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.organizations; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropDefaultGroupIdColumnOfOrganizationsTableTest { - private static final String TABLE_NAME = "organizations"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropDefaultGroupIdColumnOfOrganizationsTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropDefaultGroupIdColumnOfOrganizationsTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertColumnDefinition(TABLE_NAME, "default_group_id", Types.INTEGER, null, true); - underTest.execute(); - db.assertColumnDoesNotExist(TABLE_NAME, "default_group_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/organizations/PopulateOrganizationsDefaultGroupUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/organizations/PopulateOrganizationsDefaultGroupUuidTest.java deleted file mode 100644 index ec40df3d29d..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/organizations/PopulateOrganizationsDefaultGroupUuidTest.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.organizations; - -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class PopulateOrganizationsDefaultGroupUuidTest { - private static final String TABLE_NAME = "organizations"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateOrganizationsDefaultGroupUuidTest.class, "schema.sql"); - - private DataChange underTest = new PopulateOrganizationsDefaultGroupUuid(db.database()); - - @Test - public void populate_uuids() throws SQLException { - insertGroup(1L); - insertGroup(2L); - insertGroup(3L); - - insertOrganization(4L, 1L); - insertOrganization(5L, 2L); - insertOrganization(6L, 3L); - - underTest.execute(); - - assertThatTableContains( - tuple("uuid4", 1L, "uuid1"), - tuple("uuid5", 2L, "uuid2"), - tuple("uuid6", 3L, "uuid3") - ); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertGroup(1L); - insertGroup(2L); - insertGroup(3L); - - insertOrganization(4L, 1L); - insertOrganization(5L, 2L); - insertOrganization(6L, 3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - assertThatTableContains( - tuple("uuid4", 1L, "uuid1"), - tuple("uuid5", 2L, "uuid2"), - tuple("uuid6", 3L, "uuid3") - ); - } - - private void assertThatTableContains(Tuple... tuples) { - List> select = db.select("select uuid, default_group_id, default_group_uuid from " + TABLE_NAME); - assertThat(select).extracting(m -> m.get("UUID"), m -> m.get("DEFAULT_GROUP_ID"), m -> m.get("DEFAULT_GROUP_UUID")) - .containsExactlyInAnyOrder(tuples); - } - - private void insertGroup(Long id) { - db.executeInsert("groups", - "id", id, - "uuid", "uuid" + id, - "organization_uuid", "org" + id); - } - - private void insertOrganization(Long id, Long groupId) { - db.executeInsert(TABLE_NAME, - "uuid", "uuid" + id, - "kee", "kee" + id, - "name", "name" + id, - "default_group_id", groupId, - "default_quality_gate_uuid", "default_quality_gate_uuid" + id, - "new_project_private", true, - "subscription", "subscription" + id, - "created_at", id + 1, - "updated_at", id + 2 - ); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/permtemplatesgroups/AddGroupUuidColumnToPermTemplatesGroupsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/permtemplatesgroups/AddGroupUuidColumnToPermTemplatesGroupsTest.java deleted file mode 100644 index 58864e4498f..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/permtemplatesgroups/AddGroupUuidColumnToPermTemplatesGroupsTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.permtemplatesgroups; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddGroupUuidColumnToPermTemplatesGroupsTest { - private static final String TABLE_NAME = "perm_templates_groups"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddGroupUuidColumnToPermTemplatesGroupsTest.class, "schema.sql"); - private DdlChange underTest = new AddGroupUuidColumnToPermTemplatesGroups(db.database()); - - @Before - public void setup() { - insertPermTemplatesGroup(1L); - insertPermTemplatesGroup(2L); - insertPermTemplatesGroup(3L); - } - - @Test - public void add_active_rule_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition(TABLE_NAME, "group_uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable(TABLE_NAME)) - .isEqualTo(3); - } - - private void insertPermTemplatesGroup(Long id) { - db.executeInsert(TABLE_NAME, - "uuid", "uuid" + id, - "group_id", id + 1, - "permission_reference", "permission_reference" + id, - "template_id", id + 2 - ); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/permtemplatesgroups/DropGroupIdColumnOfPermTemplatesGroupsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/permtemplatesgroups/DropGroupIdColumnOfPermTemplatesGroupsTableTest.java deleted file mode 100644 index 72b4996b314..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/permtemplatesgroups/DropGroupIdColumnOfPermTemplatesGroupsTableTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.permtemplatesgroups; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropGroupIdColumnOfPermTemplatesGroupsTableTest { - private static final String TABLE_NAME = "perm_templates_groups"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropGroupIdColumnOfPermTemplatesGroupsTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropGroupIdColumnOfPermTemplatesGroupsTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertColumnDefinition(TABLE_NAME, "group_id", Types.INTEGER, null, true); - underTest.execute(); - db.assertColumnDoesNotExist(TABLE_NAME, "group_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/permtemplatesgroups/PopulatePermTemplatesGroupsGroupUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/permtemplatesgroups/PopulatePermTemplatesGroupsGroupUuidTest.java deleted file mode 100644 index 2991b9f8044..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/permtemplatesgroups/PopulatePermTemplatesGroupsGroupUuidTest.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.permtemplatesgroups; - -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class PopulatePermTemplatesGroupsGroupUuidTest { - private static final String TABLE_NAME = "perm_templates_groups"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulatePermTemplatesGroupsGroupUuidTest.class, "schema.sql"); - - private DataChange underTest = new PopulatePermTemplatesGroupsGroupUuid(db.database()); - - @Test - public void populate_uuids() throws SQLException { - insertGroup(1L); - insertGroup(2L); - insertGroup(3L); - - insertPermTemplatesGroup(4L, 1L); - insertPermTemplatesGroup(5L, 2L); - insertPermTemplatesGroup(6L, 3L); - - underTest.execute(); - - assertThatTableContains( - tuple("uuid4", 1L, "uuid1"), - tuple("uuid5", 2L, "uuid2"), - tuple("uuid6", 3L, "uuid3") - ); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertGroup(1L); - insertGroup(2L); - insertGroup(3L); - - insertPermTemplatesGroup(4L, 1L); - insertPermTemplatesGroup(5L, 2L); - insertPermTemplatesGroup(6L, 3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - assertThatTableContains( - tuple("uuid4", 1L, "uuid1"), - tuple("uuid5", 2L, "uuid2"), - tuple("uuid6", 3L, "uuid3") - ); - } - - private void assertThatTableContains(Tuple... tuples) { - List> select = db.select("select uuid, group_id, group_uuid from " + TABLE_NAME); - assertThat(select).extracting(m -> m.get("UUID"), m -> m.get("GROUP_ID"), m -> m.get("GROUP_UUID")) - .containsExactlyInAnyOrder(tuples); - } - - private void insertGroup(Long id) { - db.executeInsert("groups", - "id", id, - "uuid", "uuid" + id, - "organization_uuid", "org" + id); - } - - private void insertPermTemplatesGroup(Long id, Long groupId) { - db.executeInsert(TABLE_NAME, - "uuid", "uuid" + id, - "group_id", groupId, - "permission_reference", "permission_reference" + id, - "template_id", id + 2 - ); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/AddGroupUuidColumnToQProfileEditGroupsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/AddGroupUuidColumnToQProfileEditGroupsTest.java deleted file mode 100644 index 9c1e09cf940..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/AddGroupUuidColumnToQProfileEditGroupsTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.qprofileeditgroups; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddGroupUuidColumnToQProfileEditGroupsTest { - private static final String TABLE_NAME = "qprofile_edit_groups"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddGroupUuidColumnToQProfileEditGroupsTest.class, "schema.sql"); - private DdlChange underTest = new AddGroupUuidColumnToQProfileEditGroups(db.database()); - - @Before - public void setup() { - insertQProfileEditGroup(1L); - insertQProfileEditGroup(2L); - insertQProfileEditGroup(3L); - } - - @Test - public void add_active_rule_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition(TABLE_NAME, "group_uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable(TABLE_NAME)) - .isEqualTo(3); - } - - private void insertQProfileEditGroup(Long id) { - db.executeInsert(TABLE_NAME, - "uuid", "uuid" + id, - "group_id", id + 1, - "qprofile_uuid", "qprofile_uuid" + id, - "created_at", id + 3); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/AddIndexOnGroupUuidOfQProfileEditGroupsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/AddIndexOnGroupUuidOfQProfileEditGroupsTableTest.java deleted file mode 100644 index f389702a1f5..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/AddIndexOnGroupUuidOfQProfileEditGroupsTableTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.qprofileeditgroups; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class AddIndexOnGroupUuidOfQProfileEditGroupsTableTest { - private static final String TABLE_NAME = "qprofile_edit_groups"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddIndexOnGroupUuidOfQProfileEditGroupsTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddIndexOnGroupUuidOfQProfileEditGroupsTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertUniqueIndex(TABLE_NAME, "qprofile_edit_groups_unique", "group_uuid", "qprofile_uuid"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertUniqueIndex(TABLE_NAME, "qprofile_edit_groups_unique", "group_uuid", "qprofile_uuid"); - - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/DropGroupIdColumnOfQProfileEditGroupsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/DropGroupIdColumnOfQProfileEditGroupsTableTest.java deleted file mode 100644 index b9e955e4ebd..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/DropGroupIdColumnOfQProfileEditGroupsTableTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.qprofileeditgroups; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropGroupIdColumnOfQProfileEditGroupsTableTest { - private static final String TABLE_NAME = "qprofile_edit_groups"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropGroupIdColumnOfQProfileEditGroupsTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropGroupIdColumnOfQProfileEditGroupsTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertColumnDefinition(TABLE_NAME, "group_id", Types.INTEGER, null, false); - underTest.execute(); - db.assertColumnDoesNotExist(TABLE_NAME, "group_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/DropIndexOnGroupIdOfQProfileEditGroupsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/DropIndexOnGroupIdOfQProfileEditGroupsTableTest.java deleted file mode 100644 index b51674cee11..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/DropIndexOnGroupIdOfQProfileEditGroupsTableTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.qprofileeditgroups; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropIndexOnGroupIdOfQProfileEditGroupsTableTest { - private static final String TABLE_NAME = "qprofile_edit_groups"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIndexOnGroupIdOfQProfileEditGroupsTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIndexOnGroupIdOfQProfileEditGroupsTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertTableExists(TABLE_NAME); - db.assertUniqueIndex(TABLE_NAME, "qprofile_edit_groups_unique", "group_id", "qprofile_uuid"); - - - underTest.execute(); - - db.assertIndexDoesNotExist(TABLE_NAME, "qprofile_edit_groups_unique"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertIndexDoesNotExist(TABLE_NAME, "qprofile_edit_groups_unique"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/MakeQProfileEditGroupsGroupUuidNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/MakeQProfileEditGroupsGroupUuidNotNullableTest.java deleted file mode 100644 index 2387bce3311..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/MakeQProfileEditGroupsGroupUuidNotNullableTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.qprofileeditgroups; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeQProfileEditGroupsGroupUuidNotNullableTest { - private static final String TABLE_NAME = "qprofile_edit_groups"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeQProfileEditGroupsGroupUuidNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeQProfileEditGroupsGroupUuidNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition(TABLE_NAME, "group_uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/PopulateQProfileEditGroupsGroupUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/PopulateQProfileEditGroupsGroupUuidTest.java deleted file mode 100644 index d0aa1b04141..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/PopulateQProfileEditGroupsGroupUuidTest.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.groups.qprofileeditgroups; - -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class PopulateQProfileEditGroupsGroupUuidTest { - private static final String TABLE_NAME = "qprofile_edit_groups"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateQProfileEditGroupsGroupUuidTest.class, "schema.sql"); - - private DataChange underTest = new PopulateQProfileEditGroupsGroupUuid(db.database()); - - @Test - public void populate_uuids() throws SQLException { - insertGroup(1L); - insertGroup(2L); - insertGroup(3L); - - insertQProfileEditGroup(4L, 1L); - insertQProfileEditGroup(5L, 2L); - insertQProfileEditGroup(6L, 3L); - - underTest.execute(); - - assertThatTableContains( - tuple("uuid4", 1L, "uuid1"), - tuple("uuid5", 2L, "uuid2"), - tuple("uuid6", 3L, "uuid3") - ); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertGroup(1L); - insertGroup(2L); - insertGroup(3L); - - insertQProfileEditGroup(4L, 1L); - insertQProfileEditGroup(5L, 2L); - insertQProfileEditGroup(6L, 3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - assertThatTableContains( - tuple("uuid4", 1L, "uuid1"), - tuple("uuid5", 2L, "uuid2"), - tuple("uuid6", 3L, "uuid3") - ); - } - - private void assertThatTableContains(Tuple... tuples) { - List> select = db.select("select uuid, group_id, group_uuid from " + TABLE_NAME); - assertThat(select).extracting(m -> m.get("UUID"), m -> m.get("GROUP_ID"), m -> m.get("GROUP_UUID")) - .containsExactlyInAnyOrder(tuples); - } - - private void insertGroup(Long id) { - db.executeInsert("groups", - "id", id, - "uuid", "uuid" + id, - "organization_uuid", "org" + id); - } - - private void insertQProfileEditGroup(Long id, Long groupId) { - db.executeInsert(TABLE_NAME, - "uuid", "uuid" + id, - "group_id", groupId, - "qprofile_uuid", "qprofile_uuid" + id, - "created_at", id + 3); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/AddPrimaryKeyOnUuidColumnOfIssueChangesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/AddPrimaryKeyOnUuidColumnOfIssueChangesTableTest.java deleted file mode 100644 index 6f733c6cfbc..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/AddPrimaryKeyOnUuidColumnOfIssueChangesTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.issuechanges; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfIssueChangesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfIssueChangesTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddPrimaryKeyOnUuidColumnOfIssueChangesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("issue_changes", "pk_issue_changes", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/AddUuidColumnToIssueChangesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/AddUuidColumnToIssueChangesTableTest.java deleted file mode 100644 index 6e8741cce97..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/AddUuidColumnToIssueChangesTableTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.issuechanges; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUuidColumnToIssueChangesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToIssueChangesTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddUuidColumnToIssueChangesTable(db.database()); - - private UuidFactoryFast uuidFactory = UuidFactoryFast.getInstance(); - - @Before - public void setup() { - insertIssueChange(1L); - insertIssueChange(2L); - insertIssueChange(3L); - } - - @Test - public void add_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("issue_changes", "uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable("issue_changes")) - .isEqualTo(3); - } - - private void insertIssueChange(Long id) { - db.executeInsert("issue_changes", - "id", id, - "issue_key", uuidFactory.create()); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/DropIdColumnOfIssueChangesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/DropIdColumnOfIssueChangesTableTest.java deleted file mode 100644 index 38682adb85c..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/DropIdColumnOfIssueChangesTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.issuechanges; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfIssueChangesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfIssueChangesTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropIdColumnOfIssueChangesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("issue_changes", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/DropPrimaryKeyOnIdColumnOfIssueChangesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/DropPrimaryKeyOnIdColumnOfIssueChangesTableTest.java deleted file mode 100644 index deb3cb0082a..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/DropPrimaryKeyOnIdColumnOfIssueChangesTableTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.server.platform.db.migration.version.v83.issuechanges; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v83.util.SqlHelper; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropPrimaryKeyOnIdColumnOfIssueChangesTableTest { - - private static final String TABLE_NAME = "issue_changes"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfIssueChangesTableTest.class, "schema.sql"); - - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); - - private DropPrimaryKeyOnIdColumnOfIssueChangesTable underTest = new DropPrimaryKeyOnIdColumnOfIssueChangesTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/MakeIssueChangesUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/MakeIssueChangesUuidColumnNotNullableTest.java deleted file mode 100644 index 02d5ab797ff..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/MakeIssueChangesUuidColumnNotNullableTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.issuechanges; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeIssueChangesUuidColumnNotNullableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeIssueChangesUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeIssueChangesUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_nullable() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("issue_changes", "uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/PopulateIssueChangesUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/PopulateIssueChangesUuidTest.java deleted file mode 100644 index 20f43d82910..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issuechanges/PopulateIssueChangesUuidTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.issuechanges; - -import java.sql.SQLException; -import java.util.Objects; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateIssueChangesUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateIssueChangesUuidTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulateIssueChangesUuid(db.database(), uuidFactory); - - @Test - public void populate_uuids() throws SQLException { - insertIssueChange(1L); - insertIssueChange(2L); - insertIssueChange(3L); - - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertIssueChange(1L); - insertIssueChange(2L); - insertIssueChange(3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - private void verifyUuidsAreNotNull() { - assertThat(db.select("select uuid from issue_changes") - .stream() - .map(row -> row.get("UUID")) - .filter(Objects::isNull) - .collect(Collectors.toList())).isEmpty(); - } - - private void insertIssueChange(Long id) { - db.executeInsert("issue_changes", - "id", id, - "uuid", uuidFactory.create(), - "issue_key", uuidFactory.create()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issues/AddPrimaryKeyOnKeeColumnOfIssuesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issues/AddPrimaryKeyOnKeeColumnOfIssuesTableTest.java deleted file mode 100644 index 64a7512bdac..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issues/AddPrimaryKeyOnKeeColumnOfIssuesTableTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.issues; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnKeeColumnOfIssuesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnKeeColumnOfIssuesTableTest.class, "schema.sql"); - - private AddPrimaryKeyOnKeeColumnOfIssuesTable underTest = new AddPrimaryKeyOnKeeColumnOfIssuesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("issues", "pk_issues", "kee"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issues/DropIdColumnOfIssuesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issues/DropIdColumnOfIssuesTableTest.java deleted file mode 100644 index 877e66ffaae..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issues/DropIdColumnOfIssuesTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.issues; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfIssuesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfIssuesTableTest.class, "schema.sql"); - - private DropIdColumnOfIssuesTable underTest = new DropIdColumnOfIssuesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("issues", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issues/DropPrimaryKeyOnIdColumnOfIssuesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issues/DropPrimaryKeyOnIdColumnOfIssuesTableTest.java deleted file mode 100644 index ec52bab62d5..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issues/DropPrimaryKeyOnIdColumnOfIssuesTableTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.server.platform.db.migration.version.v83.issues; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v83.util.SqlHelper; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropPrimaryKeyOnIdColumnOfIssuesTableTest { - - private static final String TABLE_NAME = "issues"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfIssuesTableTest.class, "schema.sql"); - - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); - - private DropPrimaryKeyOnIdColumnOfIssuesTable underTest = new DropPrimaryKeyOnIdColumnOfIssuesTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/AddPrimaryKeyOnUuidColumnOfManualMeasureTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/AddPrimaryKeyOnUuidColumnOfManualMeasureTableTest.java deleted file mode 100644 index bd38f6012aa..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/AddPrimaryKeyOnUuidColumnOfManualMeasureTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.manualmeasures; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfManualMeasureTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfManualMeasureTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddPrimaryKeyOnUuidColumnOfManualMeasuresTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("manual_measures", "pk_manual_measures", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/AddUuidToManualMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/AddUuidToManualMeasuresTest.java deleted file mode 100644 index 39a555b1515..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/AddUuidToManualMeasuresTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.manualmeasures; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUuidToManualMeasuresTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidToManualMeasuresTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - - private DdlChange underTest = new AddUuidColumnToManualMeasures(db.database()); - - @Before - public void setup() { - insertManualMeasure(1L); - insertManualMeasure(2L); - insertManualMeasure(3L); - } - - @Test - public void add_uuid_column_to_manual_measures() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("manual_measures", "uuid", Types.VARCHAR, 40, true); - - assertThat(db.countSql("select count(id) from manual_measures")) - .isEqualTo(3); - } - - private void insertManualMeasure(Long id) { - db.executeInsert("manual_measures", - "id", id, - "metric_id", id + 100, - "component_uuid", uuidFactory.create()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/DropIdColumnOfManualMeasuresTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/DropIdColumnOfManualMeasuresTableTest.java deleted file mode 100644 index f800f953b72..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/DropIdColumnOfManualMeasuresTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.manualmeasures; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfManualMeasuresTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfManualMeasuresTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIdColumnOfManualMeasuresTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("manual_measures", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/DropPrimaryKeyOnIdColumnOfManualMeasuresTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/DropPrimaryKeyOnIdColumnOfManualMeasuresTableTest.java deleted file mode 100644 index 719b5ecff13..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/DropPrimaryKeyOnIdColumnOfManualMeasuresTableTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.manualmeasures; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v83.util.SqlHelper; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropPrimaryKeyOnIdColumnOfManualMeasuresTableTest { - - private static final String TABLE_NAME = "manual_measures"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfManualMeasuresTableTest.class, "schema.sql"); - - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); - - private MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfManualMeasuresTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/MakeManualMeasuresUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/MakeManualMeasuresUuidColumnNotNullableTest.java deleted file mode 100644 index 7e605ce8db5..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/MakeManualMeasuresUuidColumnNotNullableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.manualmeasures; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeManualMeasuresUuidColumnNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeManualMeasuresUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeManualMeasuresUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("manual_measures", "uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/PopulateManualMeasuresUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/PopulateManualMeasuresUuidTest.java deleted file mode 100644 index 83d8fb27f73..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/manualmeasures/PopulateManualMeasuresUuidTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.manualmeasures; - -import java.sql.SQLException; -import java.util.Objects; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateManualMeasuresUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateManualMeasuresUuidTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulateManualMeasureUuid(db.database(), uuidFactory); - - @Test - public void populate_uuids_and_created_at() throws SQLException { - insertManualMeasure(1L); - insertManualMeasure(2L); - insertManualMeasure(3L); - - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertManualMeasure(1L); - insertManualMeasure(2L); - insertManualMeasure(3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - private void verifyUuidsAreNotNull() { - assertThat(db.select("select uuid from manual_measures") - .stream() - .map(row -> row.get("UUID")) - .filter(Objects::isNull) - .collect(Collectors.toList())).isEmpty(); - } - - private void insertManualMeasure(Long id) { - db.executeInsert("manual_measures", - "id", id, - "metric_id", id + 100, - "component_uuid", uuidFactory.create()); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/AddPrimaryKeyOnUuidColumnOfMetricsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/AddPrimaryKeyOnUuidColumnOfMetricsTableTest.java deleted file mode 100644 index e8f60edb48f..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/AddPrimaryKeyOnUuidColumnOfMetricsTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfMetricsTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfMetricsTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddPrimaryKeyOnUuidColumnOfMetricsTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("metrics", "pk_metrics", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/AddUuidColumnToMetricsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/AddUuidColumnToMetricsTableTest.java deleted file mode 100644 index a2478609fd2..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/AddUuidColumnToMetricsTableTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUuidColumnToMetricsTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToMetricsTableTest.class, "schema.sql"); - private DdlChange underTest = new AddUuidColumnToMetricsTable(db.database()); - - @Before - public void setup() { - insertMetric(1L); - insertMetric(2L); - insertMetric(3L); - } - - @Test - public void add_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("metrics", "uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable("metrics")) - .isEqualTo(3); - } - - private void insertMetric(Long id) { - db.executeInsert("metrics", - "id", id, - "name", "name" + id); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/DropIdColumnOfMetricsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/DropIdColumnOfMetricsTableTest.java deleted file mode 100644 index 36a53eb5c78..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/DropIdColumnOfMetricsTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfMetricsTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfMetricsTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropIdColumnOfMetricsTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("metrics", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/DropPrimaryKeyOnIdColumnOfMetricsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/DropPrimaryKeyOnIdColumnOfMetricsTableTest.java deleted file mode 100644 index d3c1fc90e9c..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/DropPrimaryKeyOnIdColumnOfMetricsTableTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.server.platform.db.migration.version.v83.metrics; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v83.util.SqlHelper; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropPrimaryKeyOnIdColumnOfMetricsTableTest { - - private static final String TABLE_NAME = "metrics"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfMetricsTableTest.class, "schema.sql"); - - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); - - private DdlChange underTest = new DropPrimaryKeyOnIdColumnOfMetricsTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/MakeMetricsUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/MakeMetricsUuidColumnNotNullableTest.java deleted file mode 100644 index 72d7bc59961..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/MakeMetricsUuidColumnNotNullableTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeMetricsUuidColumnNotNullableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeMetricsUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeMetricsUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_nullable() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("metrics", "uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/PopulateMetricsUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/PopulateMetricsUuidTest.java deleted file mode 100644 index a34fc00c4dd..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/PopulateMetricsUuidTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics; - -import java.sql.SQLException; -import java.util.Objects; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateMetricsUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateMetricsUuidTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulateMetricsUuid(db.database(), uuidFactory); - - @Test - public void populate_uuids() throws SQLException { - insertMetric(1L); - insertMetric(2L); - insertMetric(3L); - - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertMetric(1L); - insertMetric(2L); - insertMetric(3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - private void verifyUuidsAreNotNull() { - assertThat(db.select("select uuid from metrics") - .stream() - .map(row -> row.get("UUID")) - .filter(Objects::isNull) - .collect(Collectors.toList())).isEmpty(); - } - - private void insertMetric(Long id) { - db.executeInsert("metrics", - "id", id, - "name", "name" + id); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/AddIndexOnMetricUuidOfLiveMeasuresTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/AddIndexOnMetricUuidOfLiveMeasuresTableTest.java deleted file mode 100644 index 9e4bf1d2566..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/AddIndexOnMetricUuidOfLiveMeasuresTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics.livemeasures; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class AddIndexOnMetricUuidOfLiveMeasuresTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddIndexOnMetricUuidOfLiveMeasuresTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddIndexOnMetricUuidOfLiveMeasuresTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertUniqueIndex("live_measures", "live_measures_component", "component_uuid", "metric_uuid"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertUniqueIndex("live_measures", "live_measures_component", "component_uuid", "metric_uuid"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/AddMetricUuidColumnToLiveMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/AddMetricUuidColumnToLiveMeasuresTest.java deleted file mode 100644 index 765421240c2..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/AddMetricUuidColumnToLiveMeasuresTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics.livemeasures; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddMetricUuidColumnToLiveMeasuresTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddMetricUuidColumnToLiveMeasuresTest.class, "schema.sql"); - private DdlChange underTest = new AddMetricUuidColumnToLiveMeasures(db.database()); - - @Before - public void setup() { - insertLiveMeasure(1L); - insertLiveMeasure(2L); - insertLiveMeasure(3L); - } - - @Test - public void add_active_rule_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("live_measures", "metric_uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable("live_measures")) - .isEqualTo(3); - } - - private void insertLiveMeasure(Long id) { - db.executeInsert("live_measures", - "uuid", "uuid" + id, - "metric_id", id + 1, - "component_uuid", "component" + id, - "project_uuid", "project" + id + 2, - "created_at", id + 3, - "updated_at", id + 4 - ); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/DropIndexOnMetricIdOfLiveMeasuresTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/DropIndexOnMetricIdOfLiveMeasuresTableTest.java deleted file mode 100644 index f65a0732b83..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/DropIndexOnMetricIdOfLiveMeasuresTableTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics.livemeasures; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropIndexOnMetricIdOfLiveMeasuresTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIndexOnMetricIdOfLiveMeasuresTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIndexOnMetricIdOfLiveMeasuresTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertTableExists("live_measures"); - db.assertUniqueIndex("live_measures", "live_measures_component", "component_uuid", "metric_id"); - - underTest.execute(); - - db.assertIndexDoesNotExist("live_measures", "live_measures_component"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertIndexDoesNotExist("live_measures", "live_measures_component"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/DropMetricIdColumnOfLiveMeasuresTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/DropMetricIdColumnOfLiveMeasuresTableTest.java deleted file mode 100644 index f6d7b506d99..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/DropMetricIdColumnOfLiveMeasuresTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics.livemeasures; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropMetricIdColumnOfLiveMeasuresTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropMetricIdColumnOfLiveMeasuresTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropMetricIdColumnOfLiveMeasuresTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertColumnDefinition("live_measures", "metric_id", Types.INTEGER, null, false); - underTest.execute(); - db.assertColumnDoesNotExist("live_measures", "metric_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/MakeLiveMeasuresMetricUuidNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/MakeLiveMeasuresMetricUuidNotNullableTest.java deleted file mode 100644 index 38c45d9f490..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/MakeLiveMeasuresMetricUuidNotNullableTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics.livemeasures; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeLiveMeasuresMetricUuidNotNullableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeLiveMeasuresMetricUuidNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeLiveMeasuresMetricUuidNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("live_measures", "metric_uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/PopulateLiveMeasuresMetricUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/PopulateLiveMeasuresMetricUuidTest.java deleted file mode 100644 index 48012348d8d..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/PopulateLiveMeasuresMetricUuidTest.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics.livemeasures; - -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class PopulateLiveMeasuresMetricUuidTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateLiveMeasuresMetricUuidTest.class, "schema.sql"); - - private DataChange underTest = new PopulateLiveMeasuresMetricUuid(db.database()); - - @Test - public void populate_uuids() throws SQLException { - insertMetric(1L); - insertMetric(2L); - insertMetric(3L); - - insertLiveMeasure(4L, 1L); - insertLiveMeasure(5L, 2L); - insertLiveMeasure(6L, 3L); - - underTest.execute(); - - assertThatTableContains( - tuple("uuid4", 1L, "uuid1"), - tuple("uuid5", 2L, "uuid2"), - tuple("uuid6", 3L, "uuid3") - ); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertMetric(1L); - insertMetric(2L); - insertMetric(3L); - - insertLiveMeasure(4L, 1L); - insertLiveMeasure(5L, 2L); - insertLiveMeasure(6L, 3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - assertThatTableContains( - tuple("uuid4", 1L, "uuid1"), - tuple("uuid5", 2L, "uuid2"), - tuple("uuid6", 3L, "uuid3") - ); - } - - private void assertThatTableContains(Tuple... tuples) { - List> select = db.select("select uuid, metric_id, metric_uuid from live_measures"); - assertThat(select).extracting(m -> m.get("UUID"), m -> m.get("METRIC_ID"), m -> m.get("METRIC_UUID")) - .containsExactlyInAnyOrder(tuples); - } - - private void insertMetric(Long id) { - db.executeInsert("metrics", - "id", id, - "uuid", "uuid" + id, - "name", "name" + id); - } - - private void insertLiveMeasure(Long id, Long metricId) { - db.executeInsert("live_measures", - "uuid", "uuid" + id, - "metric_id", metricId, - "component_uuid", "component" + id, - "project_uuid", "project" + id + 2, - "created_at", id + 3, - "updated_at", id + 4); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/AddMetricUuidColumnToManualMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/AddMetricUuidColumnToManualMeasuresTest.java deleted file mode 100644 index 2942032eb78..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/AddMetricUuidColumnToManualMeasuresTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics.manualmeasures; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddMetricUuidColumnToManualMeasuresTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddMetricUuidColumnToManualMeasuresTest.class, "schema.sql"); - private DdlChange underTest = new AddMetricUuidColumnToManualMeasures(db.database()); - - @Before - public void setup() { - insertManualMeasure(1L); - insertManualMeasure(2L); - insertManualMeasure(3L); - } - - @Test - public void add_active_rule_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("manual_measures", "metric_uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable("manual_measures")) - .isEqualTo(3); - } - - private void insertManualMeasure(Long id) { - db.executeInsert("manual_measures", - "uuid", "uuid" + id, - "metric_id", id + 1, - "component_uuid", "component" + id); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/DropMetricIdColumnOfManualMeasuresTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/DropMetricIdColumnOfManualMeasuresTableTest.java deleted file mode 100644 index ffbf5d0072d..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/DropMetricIdColumnOfManualMeasuresTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics.manualmeasures; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropMetricIdColumnOfManualMeasuresTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropMetricIdColumnOfManualMeasuresTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropMetricIdColumnOfManualMeasuresTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertColumnDefinition("manual_measures", "metric_id", Types.INTEGER, null, false); - underTest.execute(); - db.assertColumnDoesNotExist("manual_measures", "metric_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/MakeManualMeasuresMetricUuidNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/MakeManualMeasuresMetricUuidNotNullableTest.java deleted file mode 100644 index f0c5a8869e8..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/MakeManualMeasuresMetricUuidNotNullableTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics.manualmeasures; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeManualMeasuresMetricUuidNotNullableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeManualMeasuresMetricUuidNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeManualMeasuresMetricUuidNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("manual_measures", "metric_uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/PopulateManualMeasuresMetricUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/PopulateManualMeasuresMetricUuidTest.java deleted file mode 100644 index 71106d58325..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/PopulateManualMeasuresMetricUuidTest.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics.manualmeasures; - -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class PopulateManualMeasuresMetricUuidTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateManualMeasuresMetricUuidTest.class, "schema.sql"); - - private DataChange underTest = new PopulateManualMeasuresMetricUuid(db.database()); - - @Test - public void populate_uuids() throws SQLException { - insertMetric(1L); - insertMetric(2L); - insertMetric(3L); - - insertManualMeasure(4L, 1L); - insertManualMeasure(5L, 2L); - insertManualMeasure(6L, 3L); - - underTest.execute(); - - assertThatTableContains( - tuple("uuid4", 1L, "uuid1"), - tuple("uuid5", 2L, "uuid2"), - tuple("uuid6", 3L, "uuid3") - ); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertMetric(1L); - insertMetric(2L); - insertMetric(3L); - - insertManualMeasure(4L, 1L); - insertManualMeasure(5L, 2L); - insertManualMeasure(6L, 3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - assertThatTableContains( - tuple("uuid4", 1L, "uuid1"), - tuple("uuid5", 2L, "uuid2"), - tuple("uuid6", 3L, "uuid3") - ); - } - - private void assertThatTableContains(Tuple... tuples) { - List> select = db.select("select uuid, metric_id, metric_uuid from manual_measures"); - assertThat(select).extracting(m -> m.get("UUID"), m -> m.get("METRIC_ID"), m -> m.get("METRIC_UUID")) - .containsExactlyInAnyOrder(tuples); - } - - private void insertMetric(Long id) { - db.executeInsert("metrics", - "id", id, - "uuid", "uuid" + id, - "name", "name" + id); - } - - private void insertManualMeasure(Long id, Long metricId) { - db.executeInsert("manual_measures", - "uuid", "uuid" + id, - "metric_id", metricId, - "component_uuid", "component" + id); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/AddIndexOnMetricUuidOfProjectMeasuresTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/AddIndexOnMetricUuidOfProjectMeasuresTableTest.java deleted file mode 100644 index 9d913261abe..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/AddIndexOnMetricUuidOfProjectMeasuresTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics.projectmeasures; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class AddIndexOnMetricUuidOfProjectMeasuresTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddIndexOnMetricUuidOfProjectMeasuresTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddIndexOnMetricUuidOfProjectMeasuresTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertIndex("project_measures", "measures_analysis_metric", "analysis_uuid", "metric_uuid"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertIndex("project_measures", "measures_analysis_metric", "analysis_uuid", "metric_uuid"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/AddMetricUuidColumnToProjectMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/AddMetricUuidColumnToProjectMeasuresTest.java deleted file mode 100644 index 88662b71471..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/AddMetricUuidColumnToProjectMeasuresTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics.projectmeasures; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddMetricUuidColumnToProjectMeasuresTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddMetricUuidColumnToProjectMeasuresTest.class, "schema.sql"); - private DdlChange underTest = new AddMetricUuidColumnToProjectMeasures(db.database()); - - @Before - public void setup() { - insertProjectMeasure(1L); - insertProjectMeasure(2L); - insertProjectMeasure(3L); - } - - @Test - public void add_active_rule_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("project_measures", "metric_uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable("project_measures")) - .isEqualTo(3); - } - - private void insertProjectMeasure(Long id) { - db.executeInsert("project_measures", - "uuid", "uuid" + id, - "metric_id", id + 1, - "component_uuid", "component" + id, - "analysis_uuid", "analysis" + id + 1); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/DropIndexOnMetricIdOfProjectMeasuresTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/DropIndexOnMetricIdOfProjectMeasuresTableTest.java deleted file mode 100644 index 59606f405d7..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/DropIndexOnMetricIdOfProjectMeasuresTableTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics.projectmeasures; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropIndexOnMetricIdOfProjectMeasuresTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIndexOnMetricIdOfProjectMeasuresTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIndexOnMetricIdOfProjectMeasuresTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertTableExists("project_measures"); - db.assertIndex("project_measures", "measures_analysis_metric", "analysis_uuid", "metric_id"); - - underTest.execute(); - - db.assertIndexDoesNotExist("project_measures", "measures_analysis_metric"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertIndexDoesNotExist("project_measures", "measures_analysis_metric"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/DropMetricIdColumnOfProjectMeasuresTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/DropMetricIdColumnOfProjectMeasuresTableTest.java deleted file mode 100644 index 43fcb3d4e7b..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/DropMetricIdColumnOfProjectMeasuresTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics.projectmeasures; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropMetricIdColumnOfProjectMeasuresTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropMetricIdColumnOfProjectMeasuresTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropMetricIdColumnOfProjectMeasuresTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertColumnDefinition("project_measures", "metric_id", Types.INTEGER, null, false); - underTest.execute(); - db.assertColumnDoesNotExist("project_measures", "metric_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/MakeProjectMeasuresMetricUuidNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/MakeProjectMeasuresMetricUuidNotNullableTest.java deleted file mode 100644 index 47e79aaaa6b..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/MakeProjectMeasuresMetricUuidNotNullableTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics.projectmeasures; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeProjectMeasuresMetricUuidNotNullableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeProjectMeasuresMetricUuidNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeProjectMeasuresMetricUuidNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("project_measures", "metric_uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/PopulateProjectMeasuresMetricUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/PopulateProjectMeasuresMetricUuidTest.java deleted file mode 100644 index a3f0d1b4994..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/PopulateProjectMeasuresMetricUuidTest.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics.projectmeasures; - -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class PopulateProjectMeasuresMetricUuidTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateProjectMeasuresMetricUuidTest.class, "schema.sql"); - - private DataChange underTest = new PopulateProjectMeasuresMetricUuid(db.database()); - - @Test - public void populate_uuids() throws SQLException { - insertMetric(1L); - insertMetric(2L); - insertMetric(3L); - - insertProjectMeasure(4L, 1L); - insertProjectMeasure(5L, 2L); - insertProjectMeasure(6L, 3L); - - underTest.execute(); - - assertThatTableContains( - tuple("uuid4", 1L, "uuid1"), - tuple("uuid5", 2L, "uuid2"), - tuple("uuid6", 3L, "uuid3") - ); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertMetric(1L); - insertMetric(2L); - insertMetric(3L); - - insertProjectMeasure(4L, 1L); - insertProjectMeasure(5L, 2L); - insertProjectMeasure(6L, 3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - assertThatTableContains( - tuple("uuid4", 1L, "uuid1"), - tuple("uuid5", 2L, "uuid2"), - tuple("uuid6", 3L, "uuid3") - ); - } - - private void assertThatTableContains(Tuple... tuples) { - List> select = db.select("select uuid, metric_id, metric_uuid from project_measures"); - assertThat(select).extracting(m -> m.get("UUID"), m -> m.get("METRIC_ID"), m -> m.get("METRIC_UUID")) - .containsExactlyInAnyOrder(tuples); - } - - private void insertMetric(Long id) { - db.executeInsert("metrics", - "id", id, - "uuid", "uuid" + id, - "name", "name" + id); - } - - private void insertProjectMeasure(Long id, Long metricId) { - db.executeInsert("project_measures", - "uuid", "uuid" + id, - "metric_id", metricId, - "component_uuid", "component" + id, - "analysis_uuid", "analysis" + id + 1); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/AddMetricUuidColumnToQualityGateConditionsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/AddMetricUuidColumnToQualityGateConditionsTest.java deleted file mode 100644 index 7f93012cdb5..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/AddMetricUuidColumnToQualityGateConditionsTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics.qualitygateconditions; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddMetricUuidColumnToQualityGateConditionsTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddMetricUuidColumnToQualityGateConditionsTest.class, "schema.sql"); - private DdlChange underTest = new AddMetricUuidColumnToQualityGateConditions(db.database()); - - @Before - public void setup() { - insertQualityGateConditions(1L); - insertQualityGateConditions(2L); - insertQualityGateConditions(3L); - } - - @Test - public void add_active_rule_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("quality_gate_conditions", "metric_uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable("quality_gate_conditions")) - .isEqualTo(3); - } - - private void insertQualityGateConditions(Long id) { - db.executeInsert("quality_gate_conditions", - "uuid", "uuid" + id, - "metric_id", id + 1); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/DropMetricIdColumnOfQualityGateConditionsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/DropMetricIdColumnOfQualityGateConditionsTableTest.java deleted file mode 100644 index b312dbe5479..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/DropMetricIdColumnOfQualityGateConditionsTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics.qualitygateconditions; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropMetricIdColumnOfQualityGateConditionsTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropMetricIdColumnOfQualityGateConditionsTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropMetricIdColumnOfQualityGateConditionsTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertColumnDefinition("quality_gate_conditions", "metric_id", Types.INTEGER, null, true); - underTest.execute(); - db.assertColumnDoesNotExist("quality_gate_conditions", "metric_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/MakeQualityGateConditionsMetricUuidNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/MakeQualityGateConditionsMetricUuidNotNullableTest.java deleted file mode 100644 index 75f4734cc67..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/MakeQualityGateConditionsMetricUuidNotNullableTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics.qualitygateconditions; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeQualityGateConditionsMetricUuidNotNullableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeQualityGateConditionsMetricUuidNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeQualityGateConditionsMetricUuidNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("quality_gate_conditions", "metric_uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/PopulateQualityGateConditionsMetricUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/PopulateQualityGateConditionsMetricUuidTest.java deleted file mode 100644 index ad312df9192..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/PopulateQualityGateConditionsMetricUuidTest.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.metrics.qualitygateconditions; - -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import org.assertj.core.groups.Tuple; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class PopulateQualityGateConditionsMetricUuidTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateQualityGateConditionsMetricUuidTest.class, "schema.sql"); - - private DataChange underTest = new PopulateQualityGateConditionsMetricUuid(db.database()); - - @Test - public void populate_uuids() throws SQLException { - insertMetric(1L); - insertMetric(2L); - insertMetric(3L); - - insertQualityGateConditions(4L, 1L); - insertQualityGateConditions(5L, 2L); - insertQualityGateConditions(6L, 3L); - - underTest.execute(); - - assertThatTableContains( - tuple("uuid4", 1L, "uuid1"), - tuple("uuid5", 2L, "uuid2"), - tuple("uuid6", 3L, "uuid3") - ); - } - - @Test - public void delete_entries_with_null_id() throws SQLException { - insertMetric(1L); - insertMetric(2L); - insertMetric(3L); - - insertQualityGateConditions(4L, null); - insertQualityGateConditions(5L, 2L); - insertQualityGateConditions(6L, 3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - assertThatTableContains( - tuple("uuid5", 2L, "uuid2"), - tuple("uuid6", 3L, "uuid3") - ); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertMetric(1L); - insertMetric(2L); - insertMetric(3L); - - insertQualityGateConditions(4L, 1L); - insertQualityGateConditions(5L, 2L); - insertQualityGateConditions(6L, 3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - assertThatTableContains( - tuple("uuid4", 1L, "uuid1"), - tuple("uuid5", 2L, "uuid2"), - tuple("uuid6", 3L, "uuid3") - ); - } - - private void assertThatTableContains(Tuple... tuples) { - List> select = db.select("select uuid, metric_id, metric_uuid from quality_gate_conditions"); - assertThat(select).extracting(m -> m.get("UUID"), m -> m.get("METRIC_ID"), m -> m.get("METRIC_UUID")) - .containsExactlyInAnyOrder(tuples); - } - - private void insertMetric(Long id) { - db.executeInsert("metrics", - "id", id, - "uuid", "uuid" + id, - "name", "name" + id); - } - - private void insertQualityGateConditions(Long id, Long metricId) { - db.executeInsert("quality_gate_conditions", - "uuid", "uuid" + id, - "metric_id", metricId); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/notifications/AddPrimaryKeyOnUuidColumnOfNotificationTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/notifications/AddPrimaryKeyOnUuidColumnOfNotificationTableTest.java deleted file mode 100644 index 4ea3fef2e8a..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/notifications/AddPrimaryKeyOnUuidColumnOfNotificationTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.notifications; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfNotificationTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfNotificationTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddPrimaryKeyOnUuidColumnOfNotificationTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("notifications", "pk_notifications", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/notifications/AddUuidAndCreatedAtColumnsToNotificationTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/notifications/AddUuidAndCreatedAtColumnsToNotificationTest.java deleted file mode 100644 index 621506885c4..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/notifications/AddUuidAndCreatedAtColumnsToNotificationTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.notifications; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.ObjectOutputStream; -import java.sql.SQLException; -import java.sql.Types; -import org.apache.commons.io.IOUtils; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.SonarException; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static java.sql.Types.BIGINT; -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUuidAndCreatedAtColumnsToNotificationTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidAndCreatedAtColumnsToNotificationTest.class, "schema.sql"); - - private DdlChange underTest = new AddUuidAndCreatedAtColumnsToNotification(db.database()); - - @Before - public void setup() { - insertNotification(1L, "data1"); - insertNotification(2L, "data2"); - insertNotification(3L, "data3"); - } - - @Test - public void add_uuid_and_created_at_columns_to_notification() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("notifications", "uuid", Types.VARCHAR, 40, true); - db.assertColumnDefinition("notifications", "created_at", BIGINT, null, true); - - assertThat(db.countSql("select count(id) from notifications")) - .isEqualTo(3); - } - - private void insertNotification(Long id, String data) { - - ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - try { - ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream); - objectOutputStream.writeObject(data); - objectOutputStream.close(); - byte[] byteArray = byteArrayOutputStream.toByteArray(); - - db.executeInsert("notifications", - "id", id, - "data", byteArray); - - } catch (IOException e) { - throw new SonarException("Unable to write notification", e); - - } finally { - IOUtils.closeQuietly(byteArrayOutputStream); - } - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/notifications/DropIdColumnOfNotificationTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/notifications/DropIdColumnOfNotificationTableTest.java deleted file mode 100644 index 957991efac6..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/notifications/DropIdColumnOfNotificationTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.notifications; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfNotificationTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfNotificationTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIdColumnOfNotificationTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("notifications", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/notifications/DropPrimaryKeyOnIdColumnOfNotificationTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/notifications/DropPrimaryKeyOnIdColumnOfNotificationTableTest.java deleted file mode 100644 index ffef46d7d8e..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/notifications/DropPrimaryKeyOnIdColumnOfNotificationTableTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.notifications; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v83.util.SqlHelper; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropPrimaryKeyOnIdColumnOfNotificationTableTest { - - private static final String TABLE_NAME = "notifications"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfNotificationTableTest.class, "schema.sql"); - - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); - - private MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfNotificationTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/notifications/MakeNotificationUuidAndCreatedAtColumnsNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/notifications/MakeNotificationUuidAndCreatedAtColumnsNotNullableTest.java deleted file mode 100644 index 87f1dc1a8f1..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/notifications/MakeNotificationUuidAndCreatedAtColumnsNotNullableTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.notifications; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.BIGINT; -import static java.sql.Types.VARCHAR; - -public class MakeNotificationUuidAndCreatedAtColumnsNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeNotificationUuidAndCreatedAtColumnsNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeNotificationUuidAndCreatedAtColumnsNotNullable(db.database()); - - @Test - public void created_at_and_uuid_columns_are_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("notifications", "uuid", VARCHAR, null, false); - db.assertColumnDefinition("notifications", "created_at", BIGINT, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/notifications/PopulateNotificationUuidAndCreatedAtTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/notifications/PopulateNotificationUuidAndCreatedAtTest.java deleted file mode 100644 index 6b3611fc1a1..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/notifications/PopulateNotificationUuidAndCreatedAtTest.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.notifications; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.ObjectOutputStream; -import java.sql.SQLException; -import java.util.Objects; -import java.util.stream.Collectors; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.System2; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class PopulateNotificationUuidAndCreatedAtTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateNotificationUuidAndCreatedAtTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private System2 system2 = mock(System2.class); - private DataChange underTest = new PopulateNotificationUuidAndCreatedAt(db.database(), uuidFactory, system2); - - @Before - public void before() { - // exactly one week before now + 1ms, so that ID are exactly equals to timestamp in the tests - when(system2.now()).thenReturn((1000 * 60 * 60 * 24 * 7) + 1L); - } - - @Test - public void populate_uuids_and_created_at() throws IOException, SQLException { - insertNotification(1L, "data1"); - insertNotification(2L, "data2"); - insertNotification(3L, "data3"); - - underTest.execute(); - - verifyUuidsAreNotNull(); - verifyCreatedAt(); - } - - @Test - public void migration_is_reentrant() throws IOException, SQLException { - insertNotification(1L, "data1"); - insertNotification(2L, "data2"); - insertNotification(3L, "data3"); - - underTest.execute(); - // re-entrant - underTest.execute(); - - verifyUuidsAreNotNull(); - verifyCreatedAt(); - } - - private void verifyUuidsAreNotNull() { - assertThat(db.select("select uuid from notifications") - .stream() - .map(row -> row.get("UUID")) - .filter(Objects::isNull) - .collect(Collectors.toList())).isEmpty(); - } - - private void verifyCreatedAt() { - assertThat(db.select("select id, created_at from notifications") - .stream() - .filter(row -> !row.get("CREATED_AT").equals(row.get("ID"))) - .collect(Collectors.toList())).isEmpty(); - - } - - private void insertNotification(Long id, String data) throws IOException { - ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream); - objectOutputStream.writeObject(data); - objectOutputStream.close(); - byte[] byteArray = byteArrayOutputStream.toByteArray(); - - db.executeInsert("notifications", - "id", id, - "data", byteArray); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTableTest.java deleted file mode 100644 index ddf647f900d..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTableTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permissiontemplates; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v83.projectmeasures.AddPrimaryKeyOnUuidColumnOfProjectMeasuresTable; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("permission_templates", "pk_permission_templates", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/AddUuidColumnToPermissionTemplatesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/AddUuidColumnToPermissionTemplatesTest.java deleted file mode 100644 index 74901abf4b2..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/AddUuidColumnToPermissionTemplatesTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permissiontemplates; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.projectmeasures.AddUuidColumnToProjectMeasures; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUuidColumnToPermissionTemplatesTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToPermissionTemplatesTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - - private DdlChange underTest = new AddUuidColumnToPermissionTemplates(db.database()); - - @Before - public void setup() { - insertPermissionTemplate(1L); - insertPermissionTemplate(2L); - insertPermissionTemplate(3L); - } - - @Test - public void add_uuid_column_to_permission_templates() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("permission_templates", "uuid", Types.VARCHAR, 40, true); - - assertThat(db.countSql("select count(id) from permission_templates")) - .isEqualTo(3); - } - - private void insertPermissionTemplate(Long id) { - db.executeInsert("permission_templates", - "id", id, - "organization_uuid", id + 100, - "name", uuidFactory.create(), - "kee", uuidFactory.create()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/DropIdColumnOfPermissionTemplatesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/DropIdColumnOfPermissionTemplatesTableTest.java deleted file mode 100644 index 1045b7f4ee1..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/DropIdColumnOfPermissionTemplatesTableTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permissiontemplates; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v83.projectmeasures.DropIdColumnOfProjectMeasuresTable; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfPermissionTemplatesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfPermissionTemplatesTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIdColumnOfPermissionTemplatesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("permission_templates", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/DropKeeColumnOfPermissionTemplatesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/DropKeeColumnOfPermissionTemplatesTableTest.java deleted file mode 100644 index 73a3b74bc8d..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/DropKeeColumnOfPermissionTemplatesTableTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permissiontemplates; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v83.projectmeasures.DropIdColumnOfProjectMeasuresTable; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropKeeColumnOfPermissionTemplatesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropKeeColumnOfPermissionTemplatesTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropKeeColumnOfPermissionTemplatesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("permission_templates", "kee"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/DropPrimaryKeyOnIdColumnOfPermissionTemplatesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/DropPrimaryKeyOnIdColumnOfPermissionTemplatesTableTest.java deleted file mode 100644 index 303924707f6..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/DropPrimaryKeyOnIdColumnOfPermissionTemplatesTableTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permissiontemplates; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v83.util.SqlHelper; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropPrimaryKeyOnIdColumnOfPermissionTemplatesTableTest { - - private static final String TABLE_NAME = "permission_templates"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfPermissionTemplatesTableTest.class, "schema.sql"); - - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); - - private MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfPermissionTemplatesTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/MakePermissionTemplateUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/MakePermissionTemplateUuidColumnNotNullableTest.java deleted file mode 100644 index 00e20bb7889..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/MakePermissionTemplateUuidColumnNotNullableTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permissiontemplates; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v83.projectmeasures.MakeProjectMeasuresUuidColumnNotNullable; - -import static java.sql.Types.VARCHAR; - -public class MakePermissionTemplateUuidColumnNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakePermissionTemplateUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakePermissionTemplateUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("permission_templates", "uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/PopulatePermissionTemplatesUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/PopulatePermissionTemplatesUuidTest.java deleted file mode 100644 index 67c7cc2adbb..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/PopulatePermissionTemplatesUuidTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permissiontemplates; - -import java.sql.SQLException; -import java.util.Objects; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulatePermissionTemplatesUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulatePermissionTemplatesUuidTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulatePermissionTemplatesUuid(db.database(), uuidFactory); - - @Test - public void populate_uuids() throws SQLException { - insertPermissionTemplate(1L); - insertPermissionTemplate(2L); - insertPermissionTemplate(3L); - insertPermissionTemplate(4L, "very_very_very_very_very_very_very_very_very_very_very_long_kee"); - - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertPermissionTemplate(1L); - insertPermissionTemplate(2L); - insertPermissionTemplate(3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - private void verifyUuidsAreNotNull() { - assertThat(db.select("select uuid from permission_templates") - .stream() - .map(row -> row.get("UUID")) - .filter(Objects::isNull) - .collect(Collectors.toList())).isEmpty(); - } - - private void insertPermissionTemplate(Long id) { - insertPermissionTemplate(id, uuidFactory.create()); - } - - private void insertPermissionTemplate(Long id, String kee) { - db.executeInsert("permission_templates", - "id", id, - "organization_uuid", id + 100, - "name", uuidFactory.create(), - "kee", kee); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/AddTemplateUuidColumnToPermTemplatesGroupsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/AddTemplateUuidColumnToPermTemplatesGroupsTest.java deleted file mode 100644 index 77a901585ce..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/AddTemplateUuidColumnToPermTemplatesGroupsTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permissiontemplates.fk.permtemplatesgroups; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddTemplateUuidColumnToPermTemplatesGroupsTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddTemplateUuidColumnToPermTemplatesGroupsTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - - private DdlChange underTest = new AddTemplateUuidColumnToPermTemplatesGroups(db.database()); - - @Before - public void setup() { - insertPermissionTemplateGroup("1", 4L); - insertPermissionTemplateGroup("2", 5L); - insertPermissionTemplateGroup("3", 6L); - } - - @Test - public void add_uuid_column_to_permission_templates() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("perm_templates_groups", "template_uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable("perm_templates_groups")) - .isEqualTo(3); - } - - private void insertPermissionTemplateGroup(String uuid, Long templateId) { - db.executeInsert("perm_templates_groups", - "uuid", uuid, - "template_id", templateId, - "permission_reference", uuidFactory.create()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/DropTemplateIdColumnOfPermTemplatesGroupsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/DropTemplateIdColumnOfPermTemplatesGroupsTableTest.java deleted file mode 100644 index c60adf8cebf..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/DropTemplateIdColumnOfPermTemplatesGroupsTableTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permissiontemplates.fk.permtemplatesgroups; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v83.permissiontemplates.DropIdColumnOfPermissionTemplatesTable; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropTemplateIdColumnOfPermTemplatesGroupsTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropTemplateIdColumnOfPermTemplatesGroupsTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropTemplateIdColumnOfPermTemplatesGroupsTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("perm_templates_groups", "template_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/MakePermTemplatesGroupsTemplateUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/MakePermTemplatesGroupsTemplateUuidColumnNotNullableTest.java deleted file mode 100644 index 4152d70ca7a..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/MakePermTemplatesGroupsTemplateUuidColumnNotNullableTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permissiontemplates.fk.permtemplatesgroups; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v83.permissiontemplates.MakePermissionTemplateUuidColumnNotNullable; - -import static java.sql.Types.VARCHAR; - -public class MakePermTemplatesGroupsTemplateUuidColumnNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakePermTemplatesGroupsTemplateUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakePermTemplatesGroupsTemplateUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("perm_templates_groups", "template_uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/PopulatePermTemplatesGroupsTemplateUuidColumnTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/PopulatePermTemplatesGroupsTemplateUuidColumnTest.java deleted file mode 100644 index fb03394bf6e..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/PopulatePermTemplatesGroupsTemplateUuidColumnTest.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permissiontemplates.fk.permtemplatesgroups; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulatePermTemplatesGroupsTemplateUuidColumnTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulatePermTemplatesGroupsTemplateUuidColumnTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulatePermTemplatesGroupsTemplateUuidColumn(db.database()); - - @Test - public void populate_uuids() throws SQLException { - long permissionTemplateId_1 = 1L; - String permissionTemplateUuid_1 = "uuid-1"; - insertPermissionTemplate(permissionTemplateId_1, permissionTemplateUuid_1); - - long permissionTemplateId_2 = 2L; - String permissionTemplateUuid_2 = "uuid-2"; - insertPermissionTemplate(permissionTemplateId_2, permissionTemplateUuid_2); - - long permissionTemplateId_3 = 3L; - String permissionTemplateUuid_3 = "uuid-3"; - insertPermissionTemplate(permissionTemplateId_3, permissionTemplateUuid_3); - - insertPermissionTemplateGroup("4", permissionTemplateId_1); - insertPermissionTemplateGroup("5", permissionTemplateId_2); - insertPermissionTemplateGroup("6", permissionTemplateId_3); - - underTest.execute(); - - assertThatPermissionTemplateGroupTemplateUuidIsEqualTo("4", permissionTemplateUuid_1); - assertThatPermissionTemplateGroupTemplateUuidIsEqualTo("5", permissionTemplateUuid_2); - assertThatPermissionTemplateGroupTemplateUuidIsEqualTo("6", permissionTemplateUuid_3); - } - - @Test - public void migration_is_reentrant() throws SQLException { - long permissionTemplateId_1 = 1L; - String permissionTemplateUuid_1 = "uuid-1"; - insertPermissionTemplate(permissionTemplateId_1, permissionTemplateUuid_1); - - long permissionTemplateId_2 = 2L; - String permissionTemplateUuid_2 = "uuid-2"; - insertPermissionTemplate(permissionTemplateId_2, permissionTemplateUuid_2); - - long permissionTemplateId_3 = 3L; - String permissionTemplateUuid_3 = "uuid-3"; - insertPermissionTemplate(permissionTemplateId_3, permissionTemplateUuid_3); - - insertPermissionTemplateGroup("4", permissionTemplateId_1); - insertPermissionTemplateGroup("5", permissionTemplateId_2); - insertPermissionTemplateGroup("6", permissionTemplateId_3); - - underTest.execute(); - // re-entrant - underTest.execute(); - - assertThatPermissionTemplateGroupTemplateUuidIsEqualTo("4", permissionTemplateUuid_1); - assertThatPermissionTemplateGroupTemplateUuidIsEqualTo("5", permissionTemplateUuid_2); - assertThatPermissionTemplateGroupTemplateUuidIsEqualTo("6", permissionTemplateUuid_3); - } - - private void assertThatPermissionTemplateGroupTemplateUuidIsEqualTo(String permissionTemplateGroupUuid, String expectedUuid) { - assertThat(db.select("select template_uuid from perm_templates_groups where uuid = '" + permissionTemplateGroupUuid + "'") - .stream() - .map(row -> row.get("TEMPLATE_UUID")) - .findFirst()) - .hasValue(expectedUuid); - } - - private void insertPermissionTemplateGroup(String uuid, Long templateId) { - db.executeInsert("perm_templates_groups", - "uuid", uuid, - "template_id", templateId, - "permission_reference", uuidFactory.create()); - } - - private void insertPermissionTemplate(Long id, String uuid) { - db.executeInsert("permission_templates", - "id", id, - "uuid", uuid, - "organization_uuid", id + 100, - "name", uuidFactory.create(), - "kee", uuidFactory.create()); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/AddTemplateUuidColumnToPermTemplatesUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/AddTemplateUuidColumnToPermTemplatesUsersTest.java deleted file mode 100644 index c7cf2aeeea0..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/AddTemplateUuidColumnToPermTemplatesUsersTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permissiontemplates.fk.permtemplatesusers; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.permissiontemplates.AddUuidColumnToPermissionTemplates; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddTemplateUuidColumnToPermTemplatesUsersTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddTemplateUuidColumnToPermTemplatesUsersTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - - private DdlChange underTest = new AddTemplateUuidColumnToPermTemplatesUsers(db.database()); - - @Before - public void setup() { - insertPermTemplatesUsers("1"); - insertPermTemplatesUsers("2"); - insertPermTemplatesUsers("3"); - } - - @Test - public void add_uuid_column_to_permission_templates() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("perm_templates_users", "template_uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable("perm_templates_users")) - .isEqualTo(3); - } - - private void insertPermTemplatesUsers(String uuid) { - db.executeInsert("perm_templates_users", - "uuid", uuid, - "user_id", 100, - "template_id", 200, - "permission_reference", uuidFactory.create()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/DropTemplateIdColumnOfPermTemplatesUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/DropTemplateIdColumnOfPermTemplatesUsersTableTest.java deleted file mode 100644 index 88a9f51b26c..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/DropTemplateIdColumnOfPermTemplatesUsersTableTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permissiontemplates.fk.permtemplatesusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v83.permissiontemplates.DropIdColumnOfPermissionTemplatesTable; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropTemplateIdColumnOfPermTemplatesUsersTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropTemplateIdColumnOfPermTemplatesUsersTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropTemplateIdColumnOfPermTemplatesUsersTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("perm_templates_users", "template_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/MakePermTemplatesUsersTemplateUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/MakePermTemplatesUsersTemplateUuidColumnNotNullableTest.java deleted file mode 100644 index 42e4b606a47..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/MakePermTemplatesUsersTemplateUuidColumnNotNullableTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permissiontemplates.fk.permtemplatesusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v83.permissiontemplates.MakePermissionTemplateUuidColumnNotNullable; - -import static java.sql.Types.VARCHAR; - -public class MakePermTemplatesUsersTemplateUuidColumnNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakePermTemplatesUsersTemplateUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakePermTemplatesUsersTemplateUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("perm_templates_users", "template_uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/PopulatePermTemplatesUsersTemplateUuidColumnTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/PopulatePermTemplatesUsersTemplateUuidColumnTest.java deleted file mode 100644 index 67db1cea693..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/PopulatePermTemplatesUsersTemplateUuidColumnTest.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permissiontemplates.fk.permtemplatesusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulatePermTemplatesUsersTemplateUuidColumnTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulatePermTemplatesUsersTemplateUuidColumnTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulatePermTemplatesUsersTemplateUuidColumn(db.database()); - - @Test - public void populate_uuids() throws SQLException { - long permissionTemplateId_1 = 1L; - String permissionTemplateUuid_1 = "uuid-1"; - insertPermissionTemplate(permissionTemplateId_1, permissionTemplateUuid_1); - - long permissionTemplateId_2 = 2L; - String permissionTemplateUuid_2 = "uuid-2"; - insertPermissionTemplate(permissionTemplateId_2, permissionTemplateUuid_2); - - long permissionTemplateId_3 = 3L; - String permissionTemplateUuid_3 = "uuid-3"; - insertPermissionTemplate(permissionTemplateId_3, permissionTemplateUuid_3); - - insertPermTemplatesUsers("4", permissionTemplateId_1); - insertPermTemplatesUsers("5", permissionTemplateId_2); - insertPermTemplatesUsers("6", permissionTemplateId_3); - - underTest.execute(); - - assertThatPermTemplatesUsersTemplateUuidIsEqualTo("4", permissionTemplateUuid_1); - assertThatPermTemplatesUsersTemplateUuidIsEqualTo("5", permissionTemplateUuid_2); - assertThatPermTemplatesUsersTemplateUuidIsEqualTo("6", permissionTemplateUuid_3); - } - - @Test - public void migration_is_reentrant() throws SQLException { - long permissionTemplateId_1 = 1L; - String permissionTemplateUuid_1 = "uuid-1"; - insertPermissionTemplate(permissionTemplateId_1, permissionTemplateUuid_1); - - long permissionTemplateId_2 = 2L; - String permissionTemplateUuid_2 = "uuid-2"; - insertPermissionTemplate(permissionTemplateId_2, permissionTemplateUuid_2); - - long permissionTemplateId_3 = 3L; - String permissionTemplateUuid_3 = "uuid-3"; - insertPermissionTemplate(permissionTemplateId_3, permissionTemplateUuid_3); - - insertPermTemplatesUsers("4", permissionTemplateId_1); - insertPermTemplatesUsers("5", permissionTemplateId_2); - insertPermTemplatesUsers("6", permissionTemplateId_3); - - underTest.execute(); - // re-entrant - underTest.execute(); - - assertThatPermTemplatesUsersTemplateUuidIsEqualTo("4", permissionTemplateUuid_1); - assertThatPermTemplatesUsersTemplateUuidIsEqualTo("5", permissionTemplateUuid_2); - assertThatPermTemplatesUsersTemplateUuidIsEqualTo("6", permissionTemplateUuid_3); - } - - private void assertThatPermTemplatesUsersTemplateUuidIsEqualTo(String permTemplatesUsersUuid, String expectedUuid) { - assertThat(db.select("select template_uuid from perm_templates_users where uuid = '" + permTemplatesUsersUuid + "'") - .stream() - .map(row -> row.get("TEMPLATE_UUID")) - .findFirst()) - .hasValue(expectedUuid); - } - - private void insertPermTemplatesUsers(String uuid, Long templateId) { - db.executeInsert("perm_templates_users", - "uuid", uuid, - "user_id", 100, - "template_id", templateId, - "permission_reference", uuidFactory.create()); - } - - private void insertPermissionTemplate(Long id, String uuid) { - db.executeInsert("permission_templates", - "id", id, - "uuid", uuid, - "organization_uuid", id + 100, - "name", uuidFactory.create(), - "kee", uuidFactory.create()); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/AddTemplateUuidColumnToPermTplCharacteristicsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/AddTemplateUuidColumnToPermTplCharacteristicsTest.java deleted file mode 100644 index f389c7886bc..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/AddTemplateUuidColumnToPermTplCharacteristicsTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permissiontemplates.fk.permtplcharacteristics; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddTemplateUuidColumnToPermTplCharacteristicsTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddTemplateUuidColumnToPermTplCharacteristicsTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - - private DdlChange underTest = new AddTemplateUuidColumnToPermTplCharacteristics(db.database()); - - @Before - public void setup() { - insertPermTplCharacteristics("1"); - insertPermTplCharacteristics("2"); - insertPermTplCharacteristics("3"); - } - - @Test - public void add_uuid_column_to_perm_tpl_characteristics() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("perm_tpl_characteristics", "template_uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable("perm_tpl_characteristics")) - .isEqualTo(3); - } - - private void insertPermTplCharacteristics(String uuid) { - db.executeInsert("perm_tpl_characteristics", - "uuid", uuid, - "template_id", 100, - "permission_key", uuidFactory.create(), - "with_project_creator", false, - "created_at", System.currentTimeMillis(), - "updated_at", System.currentTimeMillis()); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest.java deleted file mode 100644 index e1155babfdb..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permissiontemplates.fk.permtplcharacteristics; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropTemplateIdColumnOfPermTplCharacteristicsTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertUniqueIndex("perm_tpl_characteristics", "uniq_perm_tpl_charac", "template_uuid", "permission_key"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertUniqueIndex("perm_tpl_characteristics", "uniq_perm_tpl_charac", "template_uuid", "permission_key"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/DropTemplateIdColumnOfPermTplCharacteristicsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/DropTemplateIdColumnOfPermTplCharacteristicsTableTest.java deleted file mode 100644 index 8b36d51ab80..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/DropTemplateIdColumnOfPermTplCharacteristicsTableTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permissiontemplates.fk.permtplcharacteristics; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v83.permissiontemplates.DropIdColumnOfPermissionTemplatesTable; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropTemplateIdColumnOfPermTplCharacteristicsTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropTemplateIdColumnOfPermTplCharacteristicsTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropTemplateIdColumnOfPermTplCharacteristicsTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("perm_tpl_characteristics", "template_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest.java deleted file mode 100644 index 89936dde946..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permissiontemplates.fk.permtplcharacteristics; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropTemplateIdColumnOfPermTplCharacteristicsTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertIndexDoesNotExist("perm_tpl_characteristics", "uniq_perm_tpl_charac"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertIndexDoesNotExist("perm_tpl_characteristics", "uniq_perm_tpl_charac"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/MakePermTplCharacteristicsTemplateUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/MakePermTplCharacteristicsTemplateUuidColumnNotNullableTest.java deleted file mode 100644 index c8d4d959f51..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/MakePermTplCharacteristicsTemplateUuidColumnNotNullableTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permissiontemplates.fk.permtplcharacteristics; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v83.permissiontemplates.MakePermissionTemplateUuidColumnNotNullable; - -import static java.sql.Types.VARCHAR; - -public class MakePermTplCharacteristicsTemplateUuidColumnNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakePermTplCharacteristicsTemplateUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakePermTplCharacteristicsTemplateUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("perm_tpl_characteristics", "template_uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/PopulatePermTplCharacteristicsTemplateUuidColumnTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/PopulatePermTplCharacteristicsTemplateUuidColumnTest.java deleted file mode 100644 index abe474c9601..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/PopulatePermTplCharacteristicsTemplateUuidColumnTest.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permissiontemplates.fk.permtplcharacteristics; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulatePermTplCharacteristicsTemplateUuidColumnTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulatePermTplCharacteristicsTemplateUuidColumnTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulatePermTplCharacteristicsTemplateUuidColumn(db.database()); - - @Test - public void populate_uuids() throws SQLException { - long permissionTemplateId_1 = 1L; - String permissionTemplateUuid_1 = "uuid-1"; - insertPermissionTemplate(permissionTemplateId_1, permissionTemplateUuid_1); - - long permissionTemplateId_2 = 2L; - String permissionTemplateUuid_2 = "uuid-2"; - insertPermissionTemplate(permissionTemplateId_2, permissionTemplateUuid_2); - - long permissionTemplateId_3 = 3L; - String permissionTemplateUuid_3 = "uuid-3"; - insertPermissionTemplate(permissionTemplateId_3, permissionTemplateUuid_3); - - insertPermTplCharacteristics("4", permissionTemplateId_1); - insertPermTplCharacteristics("5", permissionTemplateId_2); - insertPermTplCharacteristics("6", permissionTemplateId_3); - - underTest.execute(); - - assertThatPermTplCharacteristicsTemplateUuidIsEqualTo("4", permissionTemplateUuid_1); - assertThatPermTplCharacteristicsTemplateUuidIsEqualTo("5", permissionTemplateUuid_2); - assertThatPermTplCharacteristicsTemplateUuidIsEqualTo("6", permissionTemplateUuid_3); - } - - @Test - public void migration_is_reentrant() throws SQLException { - long permissionTemplateId_1 = 1L; - String permissionTemplateUuid_1 = "uuid-1"; - insertPermissionTemplate(permissionTemplateId_1, permissionTemplateUuid_1); - - long permissionTemplateId_2 = 2L; - String permissionTemplateUuid_2 = "uuid-2"; - insertPermissionTemplate(permissionTemplateId_2, permissionTemplateUuid_2); - - long permissionTemplateId_3 = 3L; - String permissionTemplateUuid_3 = "uuid-3"; - insertPermissionTemplate(permissionTemplateId_3, permissionTemplateUuid_3); - - insertPermTplCharacteristics("4", permissionTemplateId_1); - insertPermTplCharacteristics("5", permissionTemplateId_2); - insertPermTplCharacteristics("6", permissionTemplateId_3); - - underTest.execute(); - // re-entrant - underTest.execute(); - - assertThatPermTplCharacteristicsTemplateUuidIsEqualTo("4", permissionTemplateUuid_1); - assertThatPermTplCharacteristicsTemplateUuidIsEqualTo("5", permissionTemplateUuid_2); - assertThatPermTplCharacteristicsTemplateUuidIsEqualTo("6", permissionTemplateUuid_3); - } - - private void assertThatPermTplCharacteristicsTemplateUuidIsEqualTo(String permTplCharacteristicsUuid, String expectedUuid) { - assertThat(db.select("select template_uuid from perm_tpl_characteristics where uuid = '" + permTplCharacteristicsUuid + "'") - .stream() - .map(row -> row.get("TEMPLATE_UUID")) - .findFirst()) - .hasValue(expectedUuid); - } - - private void insertPermTplCharacteristics(String uuid, long templateId) { - db.executeInsert("perm_tpl_characteristics", - "uuid", uuid, - "template_id", templateId, - "permission_key", uuidFactory.create(), - "with_project_creator", false, - "created_at", System.currentTimeMillis(), - "updated_at", System.currentTimeMillis()); - } - - private void insertPermissionTemplate(Long id, String uuid) { - db.executeInsert("permission_templates", - "id", id, - "uuid", uuid, - "organization_uuid", id + 100, - "name", uuidFactory.create(), - "kee", uuidFactory.create()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTableTest.java deleted file mode 100644 index f85823cf6fa..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permtemplatesgroups; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema( - AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("perm_templates_groups", "pk_perm_templates_groups", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/AddUuidColumnToPermTemplatesGroupsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/AddUuidColumnToPermTemplatesGroupsTableTest.java deleted file mode 100644 index 8b57eedd269..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/AddUuidColumnToPermTemplatesGroupsTableTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permtemplatesgroups; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUuidColumnToPermTemplatesGroupsTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToPermTemplatesGroupsTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddUuidColumnToPermTemplatesGroupsTable(db.database()); - - @Before - public void setup() { - insertPermTemplatesGroups(1L); - insertPermTemplatesGroups(2L); - insertPermTemplatesGroups(3L); - } - - @Test - public void add_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("perm_templates_groups", "uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable("perm_templates_groups")) - .isEqualTo(3); - } - - private void insertPermTemplatesGroups(Long id) { - db.executeInsert("perm_templates_groups", - "id", id, - "group_id", id + 1, - "template_id", id + 2, - "permission_reference", "ref" + id); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/DropIdColumnOfPermTemplatesGroupsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/DropIdColumnOfPermTemplatesGroupsTableTest.java deleted file mode 100644 index 6acaf675870..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/DropIdColumnOfPermTemplatesGroupsTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permtemplatesgroups; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfPermTemplatesGroupsTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfPermTemplatesGroupsTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropIdColumnOfPermTemplatesGroupsTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("perm_templates_groups", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTableTest.java deleted file mode 100644 index d7732d98d60..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTableTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.server.platform.db.migration.version.v83.permtemplatesgroups; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v83.util.SqlHelper; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTableTest { - - private static final String TABLE_NAME = "perm_templates_groups"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema( - DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTableTest.class, "schema.sql"); - - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); - - private DdlChange underTest = new DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/MakePermTemplatesGroupsUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/MakePermTemplatesGroupsUuidColumnNotNullableTest.java deleted file mode 100644 index b91e53744a1..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/MakePermTemplatesGroupsUuidColumnNotNullableTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permtemplatesgroups; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakePermTemplatesGroupsUuidColumnNotNullableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakePermTemplatesGroupsUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakePermTemplatesGroupsUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_nullable() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("perm_templates_groups", "uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/PopulatePermTemplatesGroupsUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/PopulatePermTemplatesGroupsUuidTest.java deleted file mode 100644 index d9b21363765..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/PopulatePermTemplatesGroupsUuidTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permtemplatesgroups; - -import java.sql.SQLException; -import java.util.Objects; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulatePermTemplatesGroupsUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulatePermTemplatesGroupsUuidTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulatePermTemplatesGroupsUuid(db.database(), uuidFactory); - - @Test - public void populate_uuids() throws SQLException { - insertPermTemplatesGroups(1L); - insertPermTemplatesGroups(2L); - insertPermTemplatesGroups(3L); - - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertPermTemplatesGroups(1L); - insertPermTemplatesGroups(2L); - insertPermTemplatesGroups(3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - private void verifyUuidsAreNotNull() { - assertThat(db.select("select uuid from perm_templates_groups") - .stream() - .map(row -> row.get("UUID")) - .filter(Objects::isNull) - .collect(Collectors.toList())).isEmpty(); - } - - private void insertPermTemplatesGroups(Long id) { - db.executeInsert("perm_templates_groups", - "id", id, - "group_id", id + 1, - "template_id", id + 2, - "permission_reference", "ref" + id); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTableTest.java deleted file mode 100644 index ff248edcc9c..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permtemplatesusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema( - AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("perm_templates_users", "pk_perm_templates_users", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/AddUuidColumnToPermTemplatesUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/AddUuidColumnToPermTemplatesUsersTableTest.java deleted file mode 100644 index 2f9472a0c74..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/AddUuidColumnToPermTemplatesUsersTableTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permtemplatesusers; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUuidColumnToPermTemplatesUsersTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToPermTemplatesUsersTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddUuidColumnToPermTemplatesUsersTable(db.database()); - - @Before - public void setup() { - insertPermTemplatesUsers(1L); - insertPermTemplatesUsers(2L); - insertPermTemplatesUsers(3L); - } - - @Test - public void add_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("perm_templates_users", "uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable("perm_templates_users")) - .isEqualTo(3); - } - - private void insertPermTemplatesUsers(Long id) { - db.executeInsert("perm_templates_users", - "id", id, - "user_id", id + 1, - "template_id", id + 2, - "permission_reference", "ref" + id); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/DropIdColumnOfPermTemplatesUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/DropIdColumnOfPermTemplatesUsersTableTest.java deleted file mode 100644 index 632991e4778..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/DropIdColumnOfPermTemplatesUsersTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permtemplatesusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfPermTemplatesUsersTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfPermTemplatesUsersTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropIdColumnOfPermTemplatesUsersTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("perm_templates_users", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTableTest.java deleted file mode 100644 index 709bc7b426f..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTableTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.server.platform.db.migration.version.v83.permtemplatesusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v83.util.SqlHelper; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTableTest { - - private static final String TABLE_NAME = "perm_templates_users"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema( - DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTableTest.class, "schema.sql"); - - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); - - private DdlChange underTest = new DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/MakePermTemplatesUsersUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/MakePermTemplatesUsersUuidColumnNotNullableTest.java deleted file mode 100644 index 030f1eb90ca..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/MakePermTemplatesUsersUuidColumnNotNullableTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permtemplatesusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakePermTemplatesUsersUuidColumnNotNullableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakePermTemplatesUsersUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakePermTemplatesUsersUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_nullable() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("perm_templates_users", "uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/PopulatePermTemplatesUsersUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/PopulatePermTemplatesUsersUuidTest.java deleted file mode 100644 index bb397042444..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/PopulatePermTemplatesUsersUuidTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permtemplatesusers; - -import java.sql.SQLException; -import java.util.Objects; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulatePermTemplatesUsersUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulatePermTemplatesUsersUuidTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulatePermTemplatesUsersUuid(db.database(), uuidFactory); - - @Test - public void populate_uuids() throws SQLException { - insertPermTemplatesUsers(1L); - insertPermTemplatesUsers(2L); - insertPermTemplatesUsers(3L); - - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertPermTemplatesUsers(1L); - insertPermTemplatesUsers(2L); - insertPermTemplatesUsers(3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - private void verifyUuidsAreNotNull() { - assertThat(db.select("select uuid from perm_templates_users") - .stream() - .map(row -> row.get("UUID")) - .filter(Objects::isNull) - .collect(Collectors.toList())).isEmpty(); - } - - private void insertPermTemplatesUsers(Long id) { - db.executeInsert("perm_templates_users", - "id", id, - "user_id", id + 1, - "template_id", id + 2, - "permission_reference", "ref" + id); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTableTest.java deleted file mode 100644 index 4ba51f9e12f..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permtplcharacteristics; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema( - AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("perm_tpl_characteristics", "pk_perm_tpl_characteristics", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/AddUuidColumnToPermTplCharacteristicsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/AddUuidColumnToPermTplCharacteristicsTableTest.java deleted file mode 100644 index 815e879240b..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/AddUuidColumnToPermTplCharacteristicsTableTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permtplcharacteristics; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUuidColumnToPermTplCharacteristicsTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToPermTplCharacteristicsTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddUuidColumnToPermTplCharacteristicsTable(db.database()); - - @Before - public void setup() { - insertPermTplCharacteristics(1L); - insertPermTplCharacteristics(2L); - insertPermTplCharacteristics(3L); - } - - @Test - public void add_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("perm_tpl_characteristics", "uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable("perm_tpl_characteristics")) - .isEqualTo(3); - } - - private void insertPermTplCharacteristics(Long id) { - db.executeInsert("perm_tpl_characteristics", - "id", id, - "template_id", id + 1, - "permission_key", "key" + id + 2, - "with_project_creator", true, - "created_at", id + 3, - "updated_at", id + 4); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/DropIdColumnOfPermTplCharacteristicsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/DropIdColumnOfPermTplCharacteristicsTableTest.java deleted file mode 100644 index 903e83ec9aa..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/DropIdColumnOfPermTplCharacteristicsTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permtplcharacteristics; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfPermTplCharacteristicsTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfPermTplCharacteristicsTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropIdColumnOfPermTplCharacteristicsTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("perm_tpl_characteristics", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTableTest.java deleted file mode 100644 index 8785a0545c3..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTableTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.server.platform.db.migration.version.v83.permtplcharacteristics; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v83.util.SqlHelper; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTableTest { - - private static final String TABLE_NAME = "perm_tpl_characteristics"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema( - DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTableTest.class, "schema.sql"); - - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); - - private DdlChange underTest = new DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/MakePermTplCharacteristicsUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/MakePermTplCharacteristicsUuidColumnNotNullableTest.java deleted file mode 100644 index 9f7b2fa9712..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/MakePermTplCharacteristicsUuidColumnNotNullableTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permtplcharacteristics; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakePermTplCharacteristicsUuidColumnNotNullableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakePermTplCharacteristicsUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakePermTplCharacteristicsUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_nullable() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("perm_tpl_characteristics", "uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/PopulatePermTplCharacteristicsUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/PopulatePermTplCharacteristicsUuidTest.java deleted file mode 100644 index cd68474fdcb..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/PopulatePermTplCharacteristicsUuidTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.permtplcharacteristics; - -import java.sql.SQLException; -import java.util.Objects; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulatePermTplCharacteristicsUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulatePermTplCharacteristicsUuidTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulatePermTplCharacteristicsUuid(db.database(), uuidFactory); - - @Test - public void populate_uuids() throws SQLException { - insertPermTplCharacteristics(1L); - insertPermTplCharacteristics(2L); - insertPermTplCharacteristics(3L); - - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertPermTplCharacteristics(1L); - insertPermTplCharacteristics(2L); - insertPermTplCharacteristics(3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - private void verifyUuidsAreNotNull() { - assertThat(db.select("select uuid from perm_tpl_characteristics") - .stream() - .map(row -> row.get("UUID")) - .filter(Objects::isNull) - .collect(Collectors.toList())).isEmpty(); - } - - private void insertPermTplCharacteristics(Long id) { - db.executeInsert("perm_tpl_characteristics", - "id", id, - "template_id", id + 1, - "permission_key", "key" + id + 2, - "with_project_creator", true, - "created_at", id + 3, - "updated_at", id + 4); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/AddPrimaryKeyOnUuidColumnOfProjectMeasureTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/AddPrimaryKeyOnUuidColumnOfProjectMeasureTableTest.java deleted file mode 100644 index c2d1490aca2..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/AddPrimaryKeyOnUuidColumnOfProjectMeasureTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.projectmeasures; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfProjectMeasureTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfProjectMeasureTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddPrimaryKeyOnUuidColumnOfProjectMeasuresTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("project_measures", "pk_project_measures", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/AddUuidToProjectMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/AddUuidToProjectMeasuresTest.java deleted file mode 100644 index 58089c40b6f..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/AddUuidToProjectMeasuresTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.projectmeasures; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUuidToProjectMeasuresTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidToProjectMeasuresTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - - private DdlChange underTest = new AddUuidColumnToProjectMeasures(db.database()); - - @Before - public void setup() { - insertProjectMeasure(1L); - insertProjectMeasure(2L); - insertProjectMeasure(3L); - } - - @Test - public void add_uuid_column_to_project_measures() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("project_measures", "uuid", Types.VARCHAR, 40, true); - - assertThat(db.countSql("select count(id) from project_measures")) - .isEqualTo(3); - } - - private void insertProjectMeasure(Long id) { - db.executeInsert("project_measures", - "id", id, - "metric_id", id + 100, - "analysis_uuid", uuidFactory.create(), - "component_uuid", uuidFactory.create()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/DropIdColumnOfProjectMeasuresTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/DropIdColumnOfProjectMeasuresTableTest.java deleted file mode 100644 index eb2dd713811..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/DropIdColumnOfProjectMeasuresTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.projectmeasures; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfProjectMeasuresTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfProjectMeasuresTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIdColumnOfProjectMeasuresTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("project_measures", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/DropPrimaryKeyOnIdColumnOfProjectMeasuresTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/DropPrimaryKeyOnIdColumnOfProjectMeasuresTableTest.java deleted file mode 100644 index f137f8a7ded..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/DropPrimaryKeyOnIdColumnOfProjectMeasuresTableTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.projectmeasures; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v83.util.SqlHelper; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropPrimaryKeyOnIdColumnOfProjectMeasuresTableTest { - - private static final String TABLE_NAME = "project_measures"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfProjectMeasuresTableTest.class, "schema.sql"); - - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); - - private MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfProjectMeasuresTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/MakeProjectMeasuresUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/MakeProjectMeasuresUuidColumnNotNullableTest.java deleted file mode 100644 index 36aa156fe34..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/MakeProjectMeasuresUuidColumnNotNullableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.projectmeasures; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeProjectMeasuresUuidColumnNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeProjectMeasuresUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeProjectMeasuresUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("project_measures", "uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/PopulateProjectMeasuresUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/PopulateProjectMeasuresUuidTest.java deleted file mode 100644 index 248da1c3d98..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectmeasures/PopulateProjectMeasuresUuidTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.projectmeasures; - -import java.sql.SQLException; -import java.util.Objects; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateProjectMeasuresUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateProjectMeasuresUuidTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulateProjectMeasureUuid(db.database(), uuidFactory); - - @Test - public void populate_uuids() throws SQLException { - insertProjectMeasure(1L); - insertProjectMeasure(2L); - insertProjectMeasure(3L); - - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertProjectMeasure(1L); - insertProjectMeasure(2L); - insertProjectMeasure(3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - private void verifyUuidsAreNotNull() { - assertThat(db.select("select uuid from project_measures") - .stream() - .map(row -> row.get("UUID")) - .filter(Objects::isNull) - .collect(Collectors.toList())).isEmpty(); - } - - private void insertProjectMeasure(Long id) { - db.executeInsert("project_measures", - "id", id, - "metric_id", id + 100, - "analysis_uuid", uuidFactory.create(), - "component_uuid", uuidFactory.create()); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTableTest.java deleted file mode 100644 index 89840944a21..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTableTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.projectqprofiles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfProjectQProfilesTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfProjectQProfilesTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddPrimaryKeyOnUuidColumnOfProjectQProfilesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("project_qprofiles", "pk_project_qprofiles", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/AddUuidColumnToProjectQProfilesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/AddUuidColumnToProjectQProfilesTableTest.java deleted file mode 100644 index e98ffc5440a..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/AddUuidColumnToProjectQProfilesTableTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.projectqprofiles; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUuidColumnToProjectQProfilesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToProjectQProfilesTableTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - - private DdlChange underTest = new AddUuidColumnToProjectQProfilesTable(db.database()); - - @Before - public void setup() { - insertProjectQProfile(1L); - insertProjectQProfile(2L); - insertProjectQProfile(3L); - } - - @Test - public void add_uuid_column_to_project_qprofiles() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("project_qprofiles", "uuid", Types.VARCHAR, 40, true); - - assertThat(db.countSql("select count(id) from project_qprofiles")) - .isEqualTo(3); - } - - private void insertProjectQProfile(Long id) { - db.executeInsert("project_qprofiles", - "id", id, - "project_uuid", uuidFactory.create(), - "profile_key", uuidFactory.create()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/DropIdColumnOfProjectQProfilesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/DropIdColumnOfProjectQProfilesTableTest.java deleted file mode 100644 index fcb3004575e..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/DropIdColumnOfProjectQProfilesTableTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.projectqprofiles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfProjectQProfilesTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfProjectQProfilesTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropIdColumnOfProjectQProfilesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("project_qprofiles", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest.java deleted file mode 100644 index 2158bc4790a..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.projectqprofiles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v83.util.SqlHelper; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest { - private static final String TABLE_NAME = "project_qprofiles"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest.class, "schema.sql"); - - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); - - private DdlChange underTest = new DropPrimaryKeyOnIdColumnOfProjectQProfilesTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/MakeProjectQProfilesUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/MakeProjectQProfilesUuidColumnNotNullableTest.java deleted file mode 100644 index 0d0be25ed27..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/MakeProjectQProfilesUuidColumnNotNullableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.projectqprofiles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeProjectQProfilesUuidColumnNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeProjectQProfilesUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeProjectQProfilesUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("project_qprofiles", "uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/PopulateProjectQProfilesUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/PopulateProjectQProfilesUuidTest.java deleted file mode 100644 index 24ce7466cd5..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/PopulateProjectQProfilesUuidTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.projectqprofiles; - -import java.sql.SQLException; -import java.util.Objects; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateProjectQProfilesUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateProjectQProfilesUuidTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulateProjectQProfilesUuid(db.database(), uuidFactory); - - @Test - public void populate_uuids() throws SQLException { - insertProjectQProfile(1L); - insertProjectQProfile(2L); - insertProjectQProfile(3L); - - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertProjectQProfile(1L); - insertProjectQProfile(2L); - insertProjectQProfile(3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - private void verifyUuidsAreNotNull() { - assertThat(db.select("select uuid from project_qprofiles") - .stream() - .map(row -> row.get("UUID")) - .filter(Objects::isNull) - .collect(Collectors.toList())).isEmpty(); - } - - private void insertProjectQProfile(Long id) { - db.executeInsert("project_qprofiles", - "id", id, - "project_uuid", uuidFactory.create(), - "profile_key", uuidFactory.create()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/properties/AddPrimaryKeyOnUuidColumnOfPropertiesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/properties/AddPrimaryKeyOnUuidColumnOfPropertiesTableTest.java deleted file mode 100644 index 9543a704c6f..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/properties/AddPrimaryKeyOnUuidColumnOfPropertiesTableTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.properties; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v83.notifications.AddPrimaryKeyOnUuidColumnOfNotificationTable; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfPropertiesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfPropertiesTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddPrimaryKeyOnUuidColumnOfPropertiesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("properties", "pk_properties", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/properties/AddUuidColumnToPropertiesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/properties/AddUuidColumnToPropertiesTest.java deleted file mode 100644 index d6229d0a4b1..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/properties/AddUuidColumnToPropertiesTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.properties; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUuidColumnToPropertiesTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToPropertiesTest.class, "schema.sql"); - - private DdlChange underTest = new AddUuidColumnToProperties(db.database()); - - @Before - public void setup() { - insertProperties(1L, "uuid1", "key1"); - insertProperties(2L, "uuid2", "key2"); - insertProperties(3L, "uuid3", "key3"); - } - - @Test - public void add_uuid_to_properties() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("properties", "uuid", Types.VARCHAR, 40, true); - - assertThat(db.countSql("select count(id) from properties")) - .isEqualTo(3); - } - - private void insertProperties(Long id, String uuid, String propKey) { - - db.executeInsert("properties", - "id", id, - "prop_key", propKey, - "is_empty", false, - "created_at", 0); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/properties/DropIdColumnOfPropertiesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/properties/DropIdColumnOfPropertiesTableTest.java deleted file mode 100644 index 8435eaf79b1..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/properties/DropIdColumnOfPropertiesTableTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.properties; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v83.notifications.DropIdColumnOfNotificationTable; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfPropertiesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfPropertiesTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIdColumnOfPropertiesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("properties", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/properties/DropPrimaryKeyOnIdColumnOfPropertiesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/properties/DropPrimaryKeyOnIdColumnOfPropertiesTableTest.java deleted file mode 100644 index e3affc2cc77..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/properties/DropPrimaryKeyOnIdColumnOfPropertiesTableTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.properties; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v83.util.SqlHelper; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropPrimaryKeyOnIdColumnOfPropertiesTableTest { - - private static final String TABLE_NAME = "properties"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfPropertiesTableTest.class, "schema.sql"); - - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); - - private MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfPropertiesTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/properties/MakeNotificationUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/properties/MakeNotificationUuidColumnNotNullableTest.java deleted file mode 100644 index 8e970e444b3..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/properties/MakeNotificationUuidColumnNotNullableTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.properties; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v83.notifications.MakeNotificationUuidAndCreatedAtColumnsNotNullable; - -import static java.sql.Types.BIGINT; -import static java.sql.Types.VARCHAR; - -public class MakeNotificationUuidColumnNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeNotificationUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakePropertiesUuidColumnNotNullable(db.database()); - - @Test - public void created_at_and_uuid_columns_are_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("properties", "uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/properties/PopulatePropertiesUuidAndCreatedAtTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/properties/PopulatePropertiesUuidAndCreatedAtTest.java deleted file mode 100644 index 339879ac534..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/properties/PopulatePropertiesUuidAndCreatedAtTest.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.properties; - -import java.sql.SQLException; -import java.util.Objects; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulatePropertiesUuidAndCreatedAtTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulatePropertiesUuidAndCreatedAtTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulatePropertiesUuid(db.database(), uuidFactory); - - @Test - public void populate_uuids() throws SQLException { - insertProperties(1L, "uuid1", "key1"); - insertProperties(2L, "uuid2", "key2"); - insertProperties(3L, "uuid3", "key3"); - - - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertProperties(1L, "uuid1", "key1"); - insertProperties(2L, "uuid2", "key2"); - insertProperties(3L, "uuid3", "key3"); - - underTest.execute(); - // re-entrant - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - private void verifyUuidsAreNotNull() { - assertThat(db.select("select uuid from properties") - .stream() - .map(row -> row.get("UUID")) - .filter(Objects::isNull) - .collect(Collectors.toList())).isEmpty(); - } - - private void insertProperties(Long id, String uuid, String propKey) { - - db.executeInsert("properties", - "id", id, - "prop_key", propKey, - "uuid", uuid, - "is_empty", false, - "created_at", 0); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTableTest.java deleted file mode 100644 index 3a19b4f7dfe..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.qualitygateconditions; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("quality_gate_conditions", "pk_quality_gate_conditions", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/AddUuidColumnToQualityGateConditionsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/AddUuidColumnToQualityGateConditionsTableTest.java deleted file mode 100644 index a60293d6886..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/AddUuidColumnToQualityGateConditionsTableTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.qualitygateconditions; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUuidColumnToQualityGateConditionsTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToQualityGateConditionsTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddUuidColumnToQualityGateConditionsTable(db.database()); - - private UuidFactoryFast uuidFactory = UuidFactoryFast.getInstance(); - - @Before - public void setup() { - insertQualityGateCondition(1L); - insertQualityGateCondition(2L); - insertQualityGateCondition(3L); - } - - @Test - public void add_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("quality_gate_conditions", "uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable("quality_gate_conditions")) - .isEqualTo(3); - } - - private void insertQualityGateCondition(Long id) { - db.executeInsert("quality_gate_conditions", - "id", id, - "qgate_id", id + 1, - "period", id + 2); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/DropIdColumnOfQualityGateConditionsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/DropIdColumnOfQualityGateConditionsTableTest.java deleted file mode 100644 index a80e871fef5..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/DropIdColumnOfQualityGateConditionsTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.qualitygateconditions; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfQualityGateConditionsTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfQualityGateConditionsTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropIdColumnOfQualityGateConditionsTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("quality_gate_conditions", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/DropPrimaryKeyOnIdColumnOfQualityGateConditionsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/DropPrimaryKeyOnIdColumnOfQualityGateConditionsTableTest.java deleted file mode 100644 index 20d7cddf43f..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/DropPrimaryKeyOnIdColumnOfQualityGateConditionsTableTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.server.platform.db.migration.version.v83.qualitygateconditions; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v83.util.SqlHelper; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropPrimaryKeyOnIdColumnOfQualityGateConditionsTableTest { - - private static final String TABLE_NAME = "quality_gate_conditions"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfQualityGateConditionsTableTest.class, "schema.sql"); - - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); - - private DdlChange underTest = new DropPrimaryKeyOnIdColumnOfQualityGateConditionsTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/MakeQualityGateConditionsUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/MakeQualityGateConditionsUuidColumnNotNullableTest.java deleted file mode 100644 index d045803b0af..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/MakeQualityGateConditionsUuidColumnNotNullableTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.qualitygateconditions; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeQualityGateConditionsUuidColumnNotNullableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeQualityGateConditionsUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeQualityGateConditionsUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_nullable() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("quality_gate_conditions", "uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/PopulateQualityGateConditionsUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/PopulateQualityGateConditionsUuidTest.java deleted file mode 100644 index cb852ddef9b..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/PopulateQualityGateConditionsUuidTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.qualitygateconditions; - -import java.sql.SQLException; -import java.util.Objects; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateQualityGateConditionsUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateQualityGateConditionsUuidTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulateQualityGateConditionsUuid(db.database(), uuidFactory); - - @Test - public void populate_uuids() throws SQLException { - insertQualityGateCondition(1L); - insertQualityGateCondition(2L); - insertQualityGateCondition(3L); - - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertQualityGateCondition(1L); - insertQualityGateCondition(2L); - insertQualityGateCondition(3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - private void verifyUuidsAreNotNull() { - assertThat(db.select("select uuid from quality_gate_conditions") - .stream() - .map(row -> row.get("UUID")) - .filter(Objects::isNull) - .collect(Collectors.toList())).isEmpty(); - } - - private void insertQualityGateCondition(Long id) { - db.executeInsert("quality_gate_conditions", - "id", id, - "uuid", uuidFactory.create(), - "qgate_id", id + 1, - "period", id + 2); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/AddPrimaryKeyOnUuidColumnOfQGatesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/AddPrimaryKeyOnUuidColumnOfQGatesTableTest.java deleted file mode 100644 index 7867c745cc6..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/AddPrimaryKeyOnUuidColumnOfQGatesTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.qualitygates; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfQGatesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfQGatesTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddPrimaryKeyOnUuidColumnOfQGatesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("quality_gates", "pk_quality_gates", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/AddQGateUuidColumnForQGateConditionsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/AddQGateUuidColumnForQGateConditionsTest.java deleted file mode 100644 index 1a0c67ad667..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/AddQGateUuidColumnForQGateConditionsTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.qualitygates; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddQGateUuidColumnForQGateConditionsTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddQGateUuidColumnForQGateConditionsTest.class, "schema.sql"); - - private MigrationStep underTest = new AddQGateUuidColumnForQGateConditions(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("quality_gate_conditions", "qgate_uuid", Types.VARCHAR, 40, true); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropIdColumnOfQGateTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropIdColumnOfQGateTableTest.java deleted file mode 100644 index bd52e1c149b..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropIdColumnOfQGateTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.qualitygates; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfQGateTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfQGateTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIdColumnOfQGateTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("quality_gates", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropOrphansQGateConditionsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropOrphansQGateConditionsTest.java deleted file mode 100644 index 3d4a6ae12ce..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropOrphansQGateConditionsTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.qualitygates; - -import java.sql.SQLException; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThat; - -public class DropOrphansQGateConditionsTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropOrphansQGateConditionsTest.class, "schema.sql"); - - private MigrationStep underTest = new DropOrphansQGateConditions(db.database()); - - @Test - public void deleteOrphanQGConditions() throws SQLException { - insertQualityGate(1L, "uuid1", "qualityGate1"); - insertQualityGateCondition("condition_uuid_1", "uuid1"); - insertQualityGateCondition("condition_uuid_2", "uuid1"); - insertQualityGateCondition("condition_uuid_3", null); - - underTest.execute(); - - verifyConditionExist("condition_uuid_1", true); - verifyConditionExist("condition_uuid_2", true); - verifyConditionExist("condition_uuid_3", false); - } - - private void verifyConditionExist(String uuid, boolean exist) { - assertThat(db.select("select count(uuid) as C from quality_gate_conditions where uuid='" + uuid + "'") - .stream() - .map(row -> (Long) row.get("C")) - .collect(Collectors.toList())).containsOnly(exist ? 1L : 0L); - } - - private void insertQualityGate(Long id, String uuid, String name) { - db.executeInsert("quality_gates", - "id", id, - "uuid", uuid, - "name", name, - "is_built_in", true); - } - - private void insertQualityGateCondition(String uuid, String qualityGateUuid) { - db.executeInsert("quality_gate_conditions", - "uuid", uuid, - "qgate_uuid", qualityGateUuid); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropPrimaryKeyOnIdColumnOfQGatesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropPrimaryKeyOnIdColumnOfQGatesTableTest.java deleted file mode 100644 index e01cb8885d8..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropPrimaryKeyOnIdColumnOfQGatesTableTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.qualitygates; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v83.util.SqlHelper; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropPrimaryKeyOnIdColumnOfQGatesTableTest { - - private static final String TABLE_NAME = "quality_gates"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfQGatesTableTest.class, "schema.sql"); - - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); - - private MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfQGatesTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropQGateIdColumnForQGateConditionsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropQGateIdColumnForQGateConditionsTest.java deleted file mode 100644 index d086bca98c0..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropQGateIdColumnForQGateConditionsTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.qualitygates; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v83.util.SqlHelper; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropQGateIdColumnForQGateConditionsTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropQGateIdColumnForQGateConditionsTest.class, "schema.sql"); - - private MigrationStep underTest = new DropQGateIdColumnForQGateConditions(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("quality_gate_conditions", "qgate_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropUniqueIndexOnUuidColumnOfQualityGatesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropUniqueIndexOnUuidColumnOfQualityGatesTableTest.java deleted file mode 100644 index d3837c5ce1b..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropUniqueIndexOnUuidColumnOfQualityGatesTableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.qualitygates; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropUniqueIndexOnUuidColumnOfQualityGatesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropUniqueIndexOnUuidColumnOfQualityGatesTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropUniqueIndexOnUuidColumnOfQualityGatesTable(db.database()); - - @Test - public void execute_drop_index() throws SQLException { - db.assertUniqueIndex("quality_gates", "uniq_quality_gates_uuid", "uuid"); - - underTest.execute(); - - db.assertIndexDoesNotExist("quality_gates", "uniq_quality_gates_uuid"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/MakeQGateUuidColumnNotNullableForQGateConditionsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/MakeQGateUuidColumnNotNullableForQGateConditionsTest.java deleted file mode 100644 index 0b403d923f0..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/MakeQGateUuidColumnNotNullableForQGateConditionsTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.qualitygates; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeQGateUuidColumnNotNullableForQGateConditionsTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeQGateUuidColumnNotNullableForQGateConditionsTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeQGateUuidColumnNotNullableForQGateConditions(db.database()); - - @Test - public void created_at_and_uuid_columns_are_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("quality_gate_conditions", "qgate_uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/PopulateQGateUuidColumnForQGateConditionsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/PopulateQGateUuidColumnForQGateConditionsTest.java deleted file mode 100644 index 26e9da4e67f..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/qualitygates/PopulateQGateUuidColumnForQGateConditionsTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.qualitygates; - -import java.sql.SQLException; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateQGateUuidColumnForQGateConditionsTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateQGateUuidColumnForQGateConditionsTest.class, "schema.sql"); - - private DataChange underTest = new PopulateQGateUuidColumnForQGateConditions(db.database()); - - @Test - public void populate_qgate_uuids() throws SQLException { - insertQualityGate(1L, "uuid1", "qualityGate1"); - insertQualityGate(2L, "uuid2", "qualityGate2"); - insertQualityGate(3L, "uuid3", "qualityGate3"); - insertQualityGateCondition("condition_uuid_1", "uuid1"); - insertQualityGateCondition("condition_uuid_2", "uuid1"); - insertQualityGateCondition("condition_uuid_3", "uuid2"); - - underTest.execute(); - - verifyUuid("condition_uuid_1", "uuid1"); - verifyUuid("condition_uuid_2", "uuid1"); - verifyUuid("condition_uuid_3", "uuid2"); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertQualityGate(1L, "uuid1", "qualityGate1"); - insertQualityGate(2L, "uuid2", "qualityGate2"); - insertQualityGate(3L, "uuid3", "qualityGate3"); - insertQualityGateCondition("condition_uuid_1", "uuid1"); - insertQualityGateCondition("condition_uuid_2", "uuid1"); - insertQualityGateCondition("condition_uuid_3", "uuid2"); - - underTest.execute(); - // re-entrant - underTest.execute(); - - verifyUuid("condition_uuid_1", "uuid1"); - verifyUuid("condition_uuid_2", "uuid1"); - verifyUuid("condition_uuid_3", "uuid2"); - } - - private void verifyUuid(String conditionUuid, String expectedUuid) { - assertThat(db.select("select QGATE_UUID from quality_gate_conditions where uuid='" + conditionUuid+"'") - .stream() - .map(row -> row.get("QGATE_UUID")) - .collect(Collectors.toList())).containsOnly(expectedUuid); - } - - private void insertQualityGate(Long id, String uuid, String name) { - db.executeInsert("quality_gates", - "id", id, - "uuid", uuid, - "name", name, - "is_built_in", true); - } - - private void insertQualityGateCondition(String uuid, String qualityGateUuid) { - db.executeInsert("quality_gate_conditions", - "uuid", uuid, - "qgate_uuid", qualityGateUuid); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/AddPrimaryKeyOnUuidColumnOfRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/AddPrimaryKeyOnUuidColumnOfRulesTableTest.java deleted file mode 100644 index d13c9e7300d..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/AddPrimaryKeyOnUuidColumnOfRulesTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfRulesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfRulesTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddPrimaryKeyOnUuidColumnOfRulesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("rules", "pk_rules", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/AddUuidAndTemplateUuidColumnsToRulesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/AddUuidAndTemplateUuidColumnsToRulesTest.java deleted file mode 100644 index f5c6c269cb3..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/AddUuidAndTemplateUuidColumnsToRulesTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUuidAndTemplateUuidColumnsToRulesTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidAndTemplateUuidColumnsToRulesTest.class, "schema.sql"); - - private DdlChange underTest = new AddUuidAndTemplateUuidColumnsToRules(db.database()); - - @Before - public void setup() { - insertRule(1L); - insertRule(2L); - insertRule(3L); - insertRule(4L); - } - - @Test - public void add_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("rules", "uuid", Types.VARCHAR, 40, true); - - assertThat(db.countSql("select count(*) from rules")) - .isEqualTo(4); - } - - private void insertRule(long id) { - db.executeInsert("rules", - "id", id, - "plugin_rule_key", "rk" + id, - "plugin_name", "rn" + id, - "scope", "MAIN", - "is_ad_hoc", false, - "is_external", false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/DropIdColumnOfRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/DropIdColumnOfRulesTableTest.java deleted file mode 100644 index dcc9910b73f..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/DropIdColumnOfRulesTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfRulesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfRulesTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropIdColumnOfRulesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("rules", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/DropPrimaryKeyOnIdColumnOfRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/DropPrimaryKeyOnIdColumnOfRulesTableTest.java deleted file mode 100644 index e49d5b9a201..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/DropPrimaryKeyOnIdColumnOfRulesTableTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v83.util.SqlHelper; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropPrimaryKeyOnIdColumnOfRulesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfRulesTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfRulesTable(db.database(), - new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database()))); - - @Test - public void execute() throws SQLException { - db.assertTableExists("rules"); - db.assertPrimaryKey("rules", "pk_rules", "id"); - - underTest.execute(); - - db.assertNoPrimaryKey("rules"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/DropTemplateIdColumnOfRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/DropTemplateIdColumnOfRulesTableTest.java deleted file mode 100644 index 0bc6c4b94b3..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/DropTemplateIdColumnOfRulesTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropTemplateIdColumnOfRulesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropTemplateIdColumnOfRulesTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropTemplateIdColumnOfRulesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("rules", "template_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/MakeRulesUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/MakeRulesUuidColumnNotNullableTest.java deleted file mode 100644 index f1c661646a5..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/MakeRulesUuidColumnNotNullableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeRulesUuidColumnNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeRulesUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeRulesUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("rules", "uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/PopulateRulesTemplateUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/PopulateRulesTemplateUuidTest.java deleted file mode 100644 index 3503979f94a..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/PopulateRulesTemplateUuidTest.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules; - -import java.sql.SQLException; -import javax.annotation.Nullable; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class PopulateRulesTemplateUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateRulesTemplateUuidTest.class, "schema.sql"); - - private DataChange underTest = new PopulateRulesTemplateUuid(db.database()); - - @Before - public void setup() { - insertRule(1L, "uuid-1", 1L); - insertRule(2L, "uuid-2", 1L); - insertRule(3L, "uuid-3", null); - insertRule(4L, "uuid-4", 2L); - } - - @Test - public void add_rule_uuid_column() throws SQLException { - underTest.execute(); - - assertThat(db.countSql("select count(*) from rules")) - .isEqualTo(4); - assertThat(db.select("select uuid, template_id, template_uuid from rules")) - .extracting(m -> m.get("UUID"), m -> m.get("TEMPLATE_ID"), m -> m.get("TEMPLATE_UUID")) - .containsExactlyInAnyOrder( - tuple("uuid-1", 1L, "uuid-1"), - tuple("uuid-2", 1L, "uuid-1"), - tuple("uuid-3", null, null), - tuple("uuid-4", 2L, "uuid-2")); - } - - private void insertRule(long id, String uuid, @Nullable Long templateId) { - db.executeInsert("rules", - "id", id, - "uuid", uuid, - "template_id", templateId, - "plugin_rule_key", "rk" + id, - "plugin_name", "rn" + id, - "scope", "MAIN", - "is_ad_hoc", false, - "is_external", false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/PopulateRulesUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/PopulateRulesUuidTest.java deleted file mode 100644 index 5c4d8bae2bd..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/PopulateRulesUuidTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules; - -import java.sql.SQLException; -import java.util.Objects; -import java.util.stream.Collectors; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; -import static org.mockito.ArgumentMatchers.anyString; - -public class PopulateRulesUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateRulesUuidTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulateRulesUuid(db.database(), uuidFactory); - - @Before - public void setup() { - insertRule(1L); - insertRule(2L); - insertRule(3L); - insertRule(4L); - } - - @Test - public void add_rule_uuid_column() throws SQLException { - underTest.execute(); - - assertThat(db.countSql("select count(*) from rules")) - .isEqualTo(4); - assertThat(db.select("select uuid from rules") - .stream() - .map(row -> row.get("UUID")) - .filter(Objects::isNull) - .collect(Collectors.toList())).isEmpty(); - } - - private void insertRule(long id) { - db.executeInsert("rules", - "id", id, - "plugin_rule_key", "rk" + id, - "plugin_name", "rn" + id, - "scope", "MAIN", - "is_ad_hoc", false, - "is_external", false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/AddIndexToActiveRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/AddIndexToActiveRulesTableTest.java deleted file mode 100644 index fd4282d750f..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/AddIndexToActiveRulesTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.activerules; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class AddIndexToActiveRulesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddIndexToActiveRulesTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddIndexToActiveRulesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertUniqueIndex("active_rules", "uniq_profile_rule_uuids", "profile_uuid", "rule_uuid"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertUniqueIndex("active_rules", "uniq_profile_rule_uuids", "profile_uuid", "rule_uuid"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/AddRuleUuidColumnToActiveRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/AddRuleUuidColumnToActiveRulesTableTest.java deleted file mode 100644 index 3b660a6cac0..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/AddRuleUuidColumnToActiveRulesTableTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.activerules; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddRuleUuidColumnToActiveRulesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddRuleUuidColumnToActiveRulesTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddRuleUuidColumnToActiveRulesTable(db.database()); - - @Before - public void setup() { - insertRule(1L, "uuid-rule-1"); - insertRule(2L, "uuid-rule-2"); - insertRule(3L, "uuid-rule-3"); - insertRule(4L, "uuid-rule-4"); - - insertActiveRule("uuid-ar-1", 1L, "uuid-profile-1"); - insertActiveRule("uuid-ar-2", 1L, "uuid-profile-2"); - insertActiveRule("uuid-ar-3", 2L, "uuid-profile-1"); - } - - @Test - public void add_rule_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("active_rules", "rule_uuid", Types.VARCHAR, 40, true); - assertThat(db.countSql("select count(*) from active_rules")) - .isEqualTo(3); - } - - private void insertRule(long id, String uuid) { - db.executeInsert("rules", - "id", id, - "uuid", uuid, - "plugin_rule_key", "rk" + id, - "plugin_name", "rn" + id, - "scope", "MAIN", - "is_ad_hoc", false, - "is_external", false); - } - - private void insertActiveRule(String uuid, long ruleId, String profileUuid) { - db.executeInsert("active_rules", - "uuid", uuid, - "rule_id", ruleId, - "profile_uuid", profileUuid, - "failure_level", 1); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/DropIndexOnRuleIdColumnOfActiveRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/DropIndexOnRuleIdColumnOfActiveRulesTableTest.java deleted file mode 100644 index 4cd93709c2f..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/DropIndexOnRuleIdColumnOfActiveRulesTableTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.activerules; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropIndexOnRuleIdColumnOfActiveRulesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIndexOnRuleIdColumnOfActiveRulesTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIndexOnRuleIdColumnOfActiveRulesTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertTableExists("active_rules"); - db.assertUniqueIndex("active_rules", "uniq_profile_rule_ids", "profile_uuid", "rule_id"); - - underTest.execute(); - - db.assertIndexDoesNotExist("active_rules", "uniq_profile_rule_ids"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertIndexDoesNotExist("active_rules", "uniq_profile_rule_ids"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/DropRuleIdColumnOfActiveRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/DropRuleIdColumnOfActiveRulesTableTest.java deleted file mode 100644 index b8c2a7a0285..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/DropRuleIdColumnOfActiveRulesTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.activerules; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropRuleIdColumnOfActiveRulesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropRuleIdColumnOfActiveRulesTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropRuleIdColumnOfActiveRulesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("active_rules", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/MakeActiveRulesRuleUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/MakeActiveRulesRuleUuidColumnNotNullableTest.java deleted file mode 100644 index 98a0fe477e4..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/MakeActiveRulesRuleUuidColumnNotNullableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.activerules; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeActiveRulesRuleUuidColumnNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeActiveRulesRuleUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeActiveRulesRuleUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("active_rules", "rule_uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/PopulateActiveRulesRuleUuidColumnTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/PopulateActiveRulesRuleUuidColumnTest.java deleted file mode 100644 index 9431c36ab30..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/activerules/PopulateActiveRulesRuleUuidColumnTest.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.activerules; - -import java.sql.SQLException; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class PopulateActiveRulesRuleUuidColumnTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateActiveRulesRuleUuidColumnTest.class, "schema.sql"); - - private DataChange underTest = new PopulateActiveRulesRuleUuidColumn(db.database()); - - @Before - public void setup() { - insertRule(1L, "uuid-rule-1"); - insertRule(2L, "uuid-rule-2"); - insertRule(3L, "uuid-rule-3"); - insertRule(4L, "uuid-rule-4"); - - insertActiveRule("uuid-ar-1", 1L, "uuid-profile-1"); - insertActiveRule("uuid-ar-2", 1L, "uuid-profile-2"); - insertActiveRule("uuid-ar-3", 2L, "uuid-profile-1"); - } - - @Test - public void add_rule_uuid_column() throws SQLException { - underTest.execute(); - - assertThat(db.countSql("select count(*) from active_rules")) - .isEqualTo(3); - assertThat(db.select("select uuid, rule_id, rule_uuid from active_rules")) - .extracting(m -> m.get("UUID"), m -> m.get("RULE_ID"), m -> m.get("RULE_UUID")) - .containsExactlyInAnyOrder( - tuple("uuid-ar-1", 1L, "uuid-rule-1"), - tuple("uuid-ar-2", 1L, "uuid-rule-1"), - tuple("uuid-ar-3", 2L, "uuid-rule-2")); - } - - private void insertRule(long id, String uuid) { - db.executeInsert("rules", - "id", id, - "uuid", uuid, - "plugin_rule_key", "rk" + id, - "plugin_name", "rn" + id, - "scope", "MAIN", - "is_ad_hoc", false, - "is_external", false); - } - - private void insertActiveRule(String uuid, long ruleId, String profileUuid) { - db.executeInsert("active_rules", - "uuid", uuid, - "rule_id", ruleId, - "profile_uuid", profileUuid, - "failure_level", 1); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/AddIndexToDeprecatedRuleKeysTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/AddIndexToDeprecatedRuleKeysTableTest.java deleted file mode 100644 index aa35897ee63..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/AddIndexToDeprecatedRuleKeysTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.deprecatedrulekeys; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class AddIndexToDeprecatedRuleKeysTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddIndexToDeprecatedRuleKeysTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddIndexToDeprecatedRuleKeysTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertIndex("deprecated_rule_keys", "rule_uuid_deprecated_rule_keys", "rule_uuid"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertIndex("deprecated_rule_keys", "rule_uuid_deprecated_rule_keys", "rule_uuid"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/AddRuleUuidColumnToDeprecatedRuleKeysTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/AddRuleUuidColumnToDeprecatedRuleKeysTableTest.java deleted file mode 100644 index 63fe5aabc74..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/AddRuleUuidColumnToDeprecatedRuleKeysTableTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.deprecatedrulekeys; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddRuleUuidColumnToDeprecatedRuleKeysTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddRuleUuidColumnToDeprecatedRuleKeysTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddRuleUuidColumnToDeprecatedRuleKeysTable(db.database()); - - @Before - public void setup() { - insertRule(1L, "uuid-rule-1"); - insertRule(2L, "uuid-rule-2"); - insertRule(3L, "uuid-rule-3"); - - insertDeprecatedRuleKeyRow("uuid-drk-1", 1L); - insertDeprecatedRuleKeyRow("uuid-drk-2", 1L); - insertDeprecatedRuleKeyRow("uuid-drk-3", 2L); - } - - @Test - public void add_rule_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("deprecated_rule_keys", "rule_uuid", Types.VARCHAR, 40, true); - assertThat(db.countSql("select count(*) from deprecated_rule_keys")) - .isEqualTo(3); - } - - private void insertRule(long id, String uuid) { - db.executeInsert("rules", - "id", id, - "uuid", uuid, - "plugin_rule_key", "rk" + id, - "plugin_name", "rn" + id, - "scope", "MAIN", - "is_ad_hoc", false, - "is_external", false); - } - - private void insertDeprecatedRuleKeyRow(String uuid, long ruleId) { - db.executeInsert("deprecated_rule_keys", - "uuid", uuid, - "rule_id", ruleId, - "old_repository_key", "old-repo-key" + uuid, - "old_rule_key", "old-rule-key" + uuid, - "created_at", System2.INSTANCE.now()); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTableTest.java deleted file mode 100644 index 242bda7ec84..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTableTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.deprecatedrulekeys; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertTableExists("deprecated_rule_keys"); - db.assertIndex("deprecated_rule_keys", "rule_id_deprecated_rule_keys", "rule_id"); - - underTest.execute(); - - db.assertIndexDoesNotExist("deprecated_rule_keys", "rule_id_deprecated_rule_keys"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertIndexDoesNotExist("deprecated_rule_keys", "rule_id_deprecated_rule_keys"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/DropRuleIdColumnOfDeprecatedRuleKeysTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/DropRuleIdColumnOfDeprecatedRuleKeysTableTest.java deleted file mode 100644 index c733836c101..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/DropRuleIdColumnOfDeprecatedRuleKeysTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.deprecatedrulekeys; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropRuleIdColumnOfDeprecatedRuleKeysTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropRuleIdColumnOfDeprecatedRuleKeysTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropRuleIdColumnOfDeprecatedRuleKeysTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("deprecated_rule_keys", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/MakeDeprecatedRuleKeysRuleUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/MakeDeprecatedRuleKeysRuleUuidColumnNotNullableTest.java deleted file mode 100644 index 25d4c0d689e..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/MakeDeprecatedRuleKeysRuleUuidColumnNotNullableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.deprecatedrulekeys; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeDeprecatedRuleKeysRuleUuidColumnNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeDeprecatedRuleKeysRuleUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeDeprecatedRuleKeysRuleUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("deprecated_rule_keys", "rule_uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/PopulateDeprecatedRuleKeysRuleUuidColumnTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/PopulateDeprecatedRuleKeysRuleUuidColumnTest.java deleted file mode 100644 index 6621b2b96f2..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/PopulateDeprecatedRuleKeysRuleUuidColumnTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.deprecatedrulekeys; - -import java.sql.SQLException; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class PopulateDeprecatedRuleKeysRuleUuidColumnTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateDeprecatedRuleKeysRuleUuidColumnTest.class, "schema.sql"); - - private DataChange underTest = new PopulateDeprecatedRuleKeysRuleUuidColumn(db.database()); - - @Before - public void setup() { - insertRule(1L, "uuid-rule-1"); - insertRule(2L, "uuid-rule-2"); - insertRule(3L, "uuid-rule-3"); - insertRule(4L, "uuid-rule-4"); - - insertDeprecatedRuleKeyRow("uuid-drk-1", 1L); - insertDeprecatedRuleKeyRow("uuid-drk-2", 1L); - insertDeprecatedRuleKeyRow("uuid-drk-3", 2L); - } - - @Test - public void add_rule_uuid_column() throws SQLException { - underTest.execute(); - - assertThat(db.countSql("select count(*) from deprecated_rule_keys")) - .isEqualTo(3); - assertThat(db.select("select uuid, rule_id, rule_uuid from deprecated_rule_keys")) - .extracting(m -> m.get("UUID"), m -> m.get("RULE_ID"), m -> m.get("RULE_UUID")) - .containsExactlyInAnyOrder( - tuple("uuid-drk-1", 1L, "uuid-rule-1"), - tuple("uuid-drk-2", 1L, "uuid-rule-1"), - tuple("uuid-drk-3", 2L, "uuid-rule-2")); - } - - private void insertRule(long id, String uuid) { - db.executeInsert("rules", - "id", id, - "uuid", uuid, - "plugin_rule_key", "rk" + id, - "plugin_name", "rn" + id, - "scope", "MAIN", - "is_ad_hoc", false, - "is_external", false); - } - - private void insertDeprecatedRuleKeyRow(String uuid, long ruleId) { - db.executeInsert("deprecated_rule_keys", - "uuid", uuid, - "rule_id", ruleId, - "old_repository_key", "old-repo-key" + uuid, - "old_rule_key", "old-rule-key" + uuid, - "created_at", System2.INSTANCE.now()); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/issues/AddIndexToIssuesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/issues/AddIndexToIssuesTableTest.java deleted file mode 100644 index 6433bd453fb..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/issues/AddIndexToIssuesTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.issues; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class AddIndexToIssuesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddIndexToIssuesTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddIndexToIssuesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertIndex("issues", "issues_rule_uuid", "rule_uuid"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertIndex("issues", "issues_rule_uuid", "rule_uuid"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/issues/AddRuleUuidColumnToIssuesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/issues/AddRuleUuidColumnToIssuesTableTest.java deleted file mode 100644 index 4e62b298628..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/issues/AddRuleUuidColumnToIssuesTableTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.issues; - -import java.sql.SQLException; -import java.sql.Types; -import javax.annotation.Nullable; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddRuleUuidColumnToIssuesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddRuleUuidColumnToIssuesTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddRuleUuidColumnToIssuesTable(db.database()); - - @Before - public void setup() { - insertRule(1L, "uuid-rule-1"); - insertRule(2L, "uuid-rule-2"); - insertRule(3L, "uuid-rule-3"); - insertRule(4L, "uuid-rule-4"); - - insertIssue("kee-iss-1", 1L); - insertIssue("kee-iss-2", 1L); - insertIssue("kee-iss-3", 2L); - insertIssue("kee-iss-4", null); - insertIssue("kee-iss-5", null); - } - - @Test - public void add_rule_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("issues", "rule_uuid", Types.VARCHAR, 40, true); - assertThat(db.countSql("select count(*) from issues")) - .isEqualTo(5); - } - - private void insertRule(long id, String uuid) { - db.executeInsert("rules", - "id", id, - "uuid", uuid, - "plugin_rule_key", "rk" + id, - "plugin_name", "rn" + id, - "scope", "MAIN", - "is_ad_hoc", false, - "is_external", false); - } - - private void insertIssue(String kee, @Nullable Long ruleId) { - db.executeInsert("issues", - "kee", kee, - "rule_id", ruleId, - "manual_severity", false); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/issues/DropIndexOnRuleIdColumnOfIssuesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/issues/DropIndexOnRuleIdColumnOfIssuesTableTest.java deleted file mode 100644 index dfe194f3465..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/issues/DropIndexOnRuleIdColumnOfIssuesTableTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.issues; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropIndexOnRuleIdColumnOfIssuesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIndexOnRuleIdColumnOfIssuesTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIndexOnRuleIdColumnOfIssuesTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertTableExists("issues"); - db.assertIndex("issues", "issues_rule_id", "rule_id"); - - underTest.execute(); - - db.assertIndexDoesNotExist("issues", "issues_rule_id"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertIndexDoesNotExist("issues", "issues_rule_id"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/issues/DropRuleIdColumnOfIssuesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/issues/DropRuleIdColumnOfIssuesTableTest.java deleted file mode 100644 index b529a45245d..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/issues/DropRuleIdColumnOfIssuesTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.issues; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropRuleIdColumnOfIssuesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropRuleIdColumnOfIssuesTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropRuleIdColumnOfIssuesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("issues", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/issues/PopulateIssuesRuleUuidColumnTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/issues/PopulateIssuesRuleUuidColumnTest.java deleted file mode 100644 index 5de76c19f38..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/issues/PopulateIssuesRuleUuidColumnTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.issues; - -import java.sql.SQLException; -import javax.annotation.Nullable; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class PopulateIssuesRuleUuidColumnTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateIssuesRuleUuidColumnTest.class, "schema.sql"); - - private DataChange underTest = new PopulateIssuesRuleUuidColumn(db.database()); - - @Before - public void setup() { - insertRule(1L, "uuid-rule-1"); - insertRule(2L, "uuid-rule-2"); - insertRule(3L, "uuid-rule-3"); - insertRule(4L, "uuid-rule-4"); - - insertIssue("kee-iss-1", 1L); - insertIssue("kee-iss-2", 1L); - insertIssue("kee-iss-3", 2L); - insertIssue("kee-iss-4", null); - insertIssue("kee-iss-5", null); - } - - @Test - public void add_rule_uuid_column() throws SQLException { - underTest.execute(); - - assertThat(db.countSql("select count(*) from issues")).isEqualTo(5); - assertThat(db.select("select kee, rule_id, rule_uuid from issues")) - .extracting(m -> m.get("KEE"), m -> m.get("RULE_ID"), m -> m.get("RULE_UUID")) - .containsExactlyInAnyOrder( - tuple("kee-iss-1", 1L, "uuid-rule-1"), - tuple("kee-iss-2", 1L, "uuid-rule-1"), - tuple("kee-iss-3", 2L, "uuid-rule-2"), - tuple("kee-iss-4", null, null), - tuple("kee-iss-5", null, null)); - } - - private void insertRule(long id, String uuid) { - db.executeInsert("rules", - "id", id, - "uuid", uuid, - "plugin_rule_key", "rk" + id, - "plugin_name", "rn" + id, - "scope", "MAIN", - "is_ad_hoc", false, - "is_external", false); - } - - private void insertIssue(String kee, @Nullable Long ruleId) { - db.executeInsert("issues", - "kee", kee, - "rule_id", ruleId, - "manual_severity", false); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTableTest.java deleted file mode 100644 index 992c26cf15b..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.rulesmetadata; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("rules_metadata", "pk_rules_metadata", "rule_uuid", "organization_uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/AddRuleUuidColumnToRulesMetadataTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/AddRuleUuidColumnToRulesMetadataTableTest.java deleted file mode 100644 index 64b45d13936..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/AddRuleUuidColumnToRulesMetadataTableTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.rulesmetadata; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddRuleUuidColumnToRulesMetadataTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddRuleUuidColumnToRulesMetadataTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddRuleUuidColumnToRulesMetadataTable(db.database()); - - @Before - public void setup() { - insertRule(1L, "uuid-rule-1"); - insertRule(2L, "uuid-rule-2"); - insertRule(3L, "uuid-rule-3"); - insertRule(4L, "uuid-rule-4"); - - insertRuleMetadata(1L, "org-1"); - insertRuleMetadata(1L, "org-2"); - insertRuleMetadata(2L, "org-1"); - } - - @Test - public void add_rule_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("rules_metadata", "rule_uuid", Types.VARCHAR, 40, true); - assertThat(db.countSql("select count(*) from rules_metadata")) - .isEqualTo(3); - } - - private void insertRule(long id, String uuid) { - db.executeInsert("rules", - "id", id, - "uuid", uuid, - "plugin_rule_key", "rk" + id, - "plugin_name", "rn" + id, - "scope", "MAIN", - "is_ad_hoc", false, - "is_external", false); - } - - private void insertRuleMetadata(long ruleId, String organizationUuid) { - db.executeInsert("rules_metadata", - "rule_id", ruleId, - "organization_uuid", organizationUuid, - "created_at", System2.INSTANCE.now(), - "updated_at", System2.INSTANCE.now()); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/DropPrimaryKeyOnIdColumnOfRulesMetadataTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/DropPrimaryKeyOnIdColumnOfRulesMetadataTableTest.java deleted file mode 100644 index e2b617b16ba..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/DropPrimaryKeyOnIdColumnOfRulesMetadataTableTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.rulesmetadata; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v83.util.SqlHelper; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropPrimaryKeyOnIdColumnOfRulesMetadataTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfRulesMetadataTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfRulesMetadataTable(db.database(), - new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database()))); - - @Test - public void execute() throws SQLException { - db.assertTableExists("rules_metadata"); - db.assertPrimaryKey("rules_metadata", "pk_rules_metadata", "rule_id", "organization_uuid"); - - underTest.execute(); - - db.assertNoPrimaryKey("rules_metadata"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/DropRuleIdColumnOfRulesMetadataTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/DropRuleIdColumnOfRulesMetadataTableTest.java deleted file mode 100644 index 24eeacc8495..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/DropRuleIdColumnOfRulesMetadataTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.rulesmetadata; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropRuleIdColumnOfRulesMetadataTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropRuleIdColumnOfRulesMetadataTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropRuleIdColumnOfRulesMetadataTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("rules_metadata", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/MakeRulesMetadataRuleUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/MakeRulesMetadataRuleUuidColumnNotNullableTest.java deleted file mode 100644 index 2fdb200fee3..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/MakeRulesMetadataRuleUuidColumnNotNullableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.rulesmetadata; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeRulesMetadataRuleUuidColumnNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeRulesMetadataRuleUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeRulesMetadataRuleUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("rules_metadata", "rule_uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/PopulateRulesMetadataRuleUuidColumnTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/PopulateRulesMetadataRuleUuidColumnTest.java deleted file mode 100644 index 02333f271aa..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/PopulateRulesMetadataRuleUuidColumnTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.rulesmetadata; - -import java.sql.SQLException; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class PopulateRulesMetadataRuleUuidColumnTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateRulesMetadataRuleUuidColumnTest.class, "schema.sql"); - - private DataChange underTest = new PopulateRulesMetadataRuleUuidColumn(db.database()); - - @Before - public void setup() { - insertRule(1L, "uuid-rule-1"); - insertRule(2L, "uuid-rule-2"); - insertRule(3L, "uuid-rule-3"); - insertRule(4L, "uuid-rule-4"); - - insertRuleMetadata(1L, "org-1"); - insertRuleMetadata(1L, "org-2"); - insertRuleMetadata(2L, "org-1"); - } - - @Test - public void add_rule_uuid_column() throws SQLException { - underTest.execute(); - - assertThat(db.countSql("select count(*) from rules_metadata")) - .isEqualTo(3); - assertThat(db.select("select rule_id, organization_uuid, rule_uuid from rules_metadata")) - .extracting(m -> m.get("RULE_ID"), m -> m.get("ORGANIZATION_UUID"), m -> m.get("RULE_UUID")) - .containsExactlyInAnyOrder( - tuple(1L, "org-1", "uuid-rule-1"), - tuple(1L, "org-2", "uuid-rule-1"), - tuple(2L, "org-1", "uuid-rule-2")); - } - - private void insertRule(long id, String uuid) { - db.executeInsert("rules", - "id", id, - "uuid", uuid, - "plugin_rule_key", "rk" + id, - "plugin_name", "rn" + id, - "scope", "MAIN", - "is_ad_hoc", false, - "is_external", false); - } - - private void insertRuleMetadata(long ruleId, String organizationUuid) { - db.executeInsert("rules_metadata", - "rule_id", ruleId, - "organization_uuid", organizationUuid, - "created_at", System2.INSTANCE.now(), - "updated_at", System2.INSTANCE.now()); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/AddIndexesToRulesParametersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/AddIndexesToRulesParametersTableTest.java deleted file mode 100644 index a442c2f1311..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/AddIndexesToRulesParametersTableTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.rulesparameters; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class AddIndexesToRulesParametersTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddIndexesToRulesParametersTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddIndexesToRulesParametersTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertIndex("rules_parameters", "rules_parameters_rule_uuid", "rule_uuid"); - db.assertUniqueIndex("rules_parameters", "rules_parameters_unique", "rule_uuid", "name"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertIndex("rules_parameters", "rules_parameters_rule_uuid", "rule_uuid"); - db.assertUniqueIndex("rules_parameters", "rules_parameters_unique", "rule_uuid", "name"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/AddRuleUuidColumnToRulesParametersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/AddRuleUuidColumnToRulesParametersTableTest.java deleted file mode 100644 index 7a8d1d95d0f..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/AddRuleUuidColumnToRulesParametersTableTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.rulesparameters; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddRuleUuidColumnToRulesParametersTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddRuleUuidColumnToRulesParametersTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddRuleUuidColumnToRulesParametersTable(db.database()); - - @Before - public void setup() { - insertRule(1L, "uuid-rule-1"); - insertRule(2L, "uuid-rule-2"); - insertRule(3L, "uuid-rule-3"); - - insertRulesParametersEntry("uuid-rp-1", 1L); - insertRulesParametersEntry("uuid-rp-2", 1L); - insertRulesParametersEntry("uuid-rp-3", 2L); - } - - @Test - public void add_rule_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("rules_parameters", "rule_uuid", Types.VARCHAR, 40, true); - assertThat(db.countSql("select count(*) from rules_parameters")) - .isEqualTo(3); - } - - private void insertRule(long id, String uuid) { - db.executeInsert("rules", - "id", id, - "uuid", uuid, - "plugin_rule_key", "rk" + id, - "plugin_name", "rn" + id, - "scope", "MAIN", - "is_ad_hoc", false, - "is_external", false); - } - - private void insertRulesParametersEntry(String uuid, long ruleId) { - db.executeInsert("rules_parameters", - "uuid", uuid, - "rule_id", ruleId, - "name", "name-" + uuid, - "param_type", "STRING"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/DropIndexesOnRuleIdColumnOfRulesParametersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/DropIndexesOnRuleIdColumnOfRulesParametersTableTest.java deleted file mode 100644 index 35418be3a2f..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/DropIndexesOnRuleIdColumnOfRulesParametersTableTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.rulesparameters; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropIndexesOnRuleIdColumnOfRulesParametersTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIndexesOnRuleIdColumnOfRulesParametersTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIndexesOnRuleIdColumnOfRulesParametersTable(db.database()); - - @Test - public void execute() throws SQLException { - db.assertTableExists("rules_parameters"); - db.assertIndex("rules_parameters", "rules_parameters_rule_id", "rule_id"); - db.assertUniqueIndex("rules_parameters", "rules_parameters_unique", "rule_id", "name"); - - underTest.execute(); - - db.assertIndexDoesNotExist("rules_parameters", "rules_parameters_rule_id"); - db.assertIndexDoesNotExist("rules_parameters", "rules_parameters_unique"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertIndexDoesNotExist("rules_parameters", "rules_parameters_rule_id"); - db.assertIndexDoesNotExist("rules_parameters", "rules_parameters_unique"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/DropRuleIdColumnOfRulesParametersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/DropRuleIdColumnOfRulesParametersTableTest.java deleted file mode 100644 index 7c4f9b3c242..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/DropRuleIdColumnOfRulesParametersTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.rulesparameters; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropRuleIdColumnOfRulesParametersTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropRuleIdColumnOfRulesParametersTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropRuleIdColumnOfRulesParametersTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("rules_parameters", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/MakeRulesParametersRuleUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/MakeRulesParametersRuleUuidColumnNotNullableTest.java deleted file mode 100644 index b657984f530..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/MakeRulesParametersRuleUuidColumnNotNullableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.rulesparameters; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeRulesParametersRuleUuidColumnNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeRulesParametersRuleUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeRulesParametersRuleUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("rules_parameters", "rule_uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/PopulateRulesParametersRuleUuidColumnTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/PopulateRulesParametersRuleUuidColumnTest.java deleted file mode 100644 index 4f8b401bc88..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/PopulateRulesParametersRuleUuidColumnTest.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rules.rulesparameters; - -import java.sql.SQLException; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.System2; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class PopulateRulesParametersRuleUuidColumnTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateRulesParametersRuleUuidColumnTest.class, "schema.sql"); - - private DataChange underTest = new PopulateRulesParametersRuleUuidColumn(db.database()); - - @Before - public void setup() { - insertRule(1L, "uuid-rule-1"); - insertRule(2L, "uuid-rule-2"); - insertRule(3L, "uuid-rule-3"); - - insertRulesParametersEntry("uuid-rp-1", 1L); - insertRulesParametersEntry("uuid-rp-2", 1L); - insertRulesParametersEntry("uuid-rp-3", 2L); - } - - @Test - public void add_rule_uuid_column() throws SQLException { - underTest.execute(); - - assertThat(db.countSql("select count(*) from rules_parameters")) - .isEqualTo(3); - assertThat(db.select("select uuid, rule_id, rule_uuid from rules_parameters")) - .extracting(m -> m.get("UUID"), m -> m.get("RULE_ID"), m -> m.get("RULE_UUID")) - .containsExactlyInAnyOrder( - tuple("uuid-rp-1", 1L, "uuid-rule-1"), - tuple("uuid-rp-2", 1L, "uuid-rule-1"), - tuple("uuid-rp-3", 2L, "uuid-rule-2")); - } - - private void insertRule(long id, String uuid) { - db.executeInsert("rules", - "id", id, - "uuid", uuid, - "plugin_rule_key", "rk" + id, - "plugin_name", "rn" + id, - "scope", "MAIN", - "is_ad_hoc", false, - "is_external", false); - } - - private void insertRulesParametersEntry(String uuid, long ruleId) { - db.executeInsert("rules_parameters", - "uuid", uuid, - "rule_id", ruleId, - "name", "name-" + uuid, - "param_type", "STRING"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/AddPrimaryKeyOnUuidColumnOfRulesParametersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/AddPrimaryKeyOnUuidColumnOfRulesParametersTableTest.java deleted file mode 100644 index 5b8f6d6fa5b..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/AddPrimaryKeyOnUuidColumnOfRulesParametersTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesparameters; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfRulesParametersTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfRulesParametersTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddPrimaryKeyOnUuidColumnOfRulesParametersTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("rules_parameters", "pk_rules_parameters", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/AddUuidColumnToRulesParametersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/AddUuidColumnToRulesParametersTest.java deleted file mode 100644 index ce27de8579c..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/AddUuidColumnToRulesParametersTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesparameters; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUuidColumnToRulesParametersTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToRulesParametersTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - - private DdlChange underTest = new AddUuidColumnToRulesParameters(db.database()); - - @Before - public void setup() { - insertRuleParameter(1L); - insertRuleParameter(2L); - insertRuleParameter(3L); - } - - @Test - public void add_uuid_column_to_project_measures() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("rules_parameters", "uuid", Types.VARCHAR, 40, true); - - assertThat(db.countSql("select count(id) from rules_parameters")) - .isEqualTo(3); - } - - private void insertRuleParameter(Long id) { - db.executeInsert("rules_parameters", - "id", id, - "rule_id", id + 100, - "name", uuidFactory.create(), - "param_type", uuidFactory.create()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/DropIdColumnOfRulesParametersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/DropIdColumnOfRulesParametersTableTest.java deleted file mode 100644 index 4d39980a948..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/DropIdColumnOfRulesParametersTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesparameters; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfRulesParametersTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfRulesParametersTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIdColumnOfRulesParametersTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("rules_parameters", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/DropPrimaryKeyOnIdColumnOfRulesParametersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/DropPrimaryKeyOnIdColumnOfRulesParametersTableTest.java deleted file mode 100644 index d07fa6118b7..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/DropPrimaryKeyOnIdColumnOfRulesParametersTableTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesparameters; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v83.util.SqlHelper; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropPrimaryKeyOnIdColumnOfRulesParametersTableTest { - - private static final String TABLE_NAME = "rules_parameters"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfRulesParametersTableTest.class, "schema.sql"); - - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); - - private MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfRulesParametersTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/MakeRulesParametersUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/MakeRulesParametersUuidColumnNotNullableTest.java deleted file mode 100644 index d2f29cf376d..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/MakeRulesParametersUuidColumnNotNullableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesparameters; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeRulesParametersUuidColumnNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeRulesParametersUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeRulesParametersUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("rules_parameters", "uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/PopulateRulesParametersUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/PopulateRulesParametersUuidTest.java deleted file mode 100644 index 0da6eba665f..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/PopulateRulesParametersUuidTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesparameters; - -import java.sql.SQLException; -import java.util.Objects; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateRulesParametersUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateRulesParametersUuidTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulateRulesParametersUuid(db.database(), uuidFactory); - - @Test - public void populate_uuids_and_created_at() throws SQLException { - insertRuleParameter(1L); - insertRuleParameter(2L); - insertRuleParameter(3L); - - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertRuleParameter(1L); - insertRuleParameter(2L); - insertRuleParameter(3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - private void verifyUuidsAreNotNull() { - assertThat(db.select("select uuid from rules_parameters") - .stream() - .map(row -> row.get("UUID")) - .filter(Objects::isNull) - .collect(Collectors.toList())).isEmpty(); - } - - private void insertRuleParameter(Long id) { - db.executeInsert("rules_parameters", - "id", id, - "rule_id", id + 100, - "name", uuidFactory.create(), - "param_type", uuidFactory.create()); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/AddRulesParameterUuidColumnToActiveRuleParametersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/AddRulesParameterUuidColumnToActiveRuleParametersTest.java deleted file mode 100644 index 5303f2fe192..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/AddRulesParameterUuidColumnToActiveRuleParametersTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesparameters.fk; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddRulesParameterUuidColumnToActiveRuleParametersTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddRulesParameterUuidColumnToActiveRuleParametersTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - - private DdlChange underTest = new AddRulesParameterUuidColumnToActiveRuleParameters(db.database()); - - @Before - public void setup() { - insertActiveRuleParameter(uuidFactory.create(), 1L, 4L); - insertActiveRuleParameter(uuidFactory.create(), 2L, 5L); - insertActiveRuleParameter(uuidFactory.create(), 3L, 6L); - } - - @Test - public void add_rules_parameter_uuid_column_to_active_rule_parameters() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("active_rule_parameters", "rules_parameter_uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable("active_rule_parameters")) - .isEqualTo(3); - } - - private void insertActiveRuleParameter(String uuid, Long ruleId, Long rulesParameterId) { - db.executeInsert("active_rule_parameters", - "uuid", uuid, - "active_rule_id", ruleId, - "rules_parameter_id", rulesParameterId); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/DropRulesParameterIdColumnOfActiveRuleParametersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/DropRulesParameterIdColumnOfActiveRuleParametersTableTest.java deleted file mode 100644 index da25ea3d878..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/DropRulesParameterIdColumnOfActiveRuleParametersTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesparameters.fk; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropRulesParameterIdColumnOfActiveRuleParametersTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropRulesParameterIdColumnOfActiveRuleParametersTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropRulesParameterIdColumnOfActiveRuleParametersTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("active_rule_parameters", "rules_parameter_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/MakeActiveRuleParametersRulesParameterUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/MakeActiveRuleParametersRulesParameterUuidColumnNotNullableTest.java deleted file mode 100644 index b9951ffc3c2..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/MakeActiveRuleParametersRulesParameterUuidColumnNotNullableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesparameters.fk; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeActiveRuleParametersRulesParameterUuidColumnNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeActiveRuleParametersRulesParameterUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeActiveRuleParametersRulesParameterUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("active_rule_parameters", "rules_parameter_uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/PopulateActiveRuleParametersRulesParameterUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/PopulateActiveRuleParametersRulesParameterUuidTest.java deleted file mode 100644 index f0b6c3254db..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/PopulateActiveRuleParametersRulesParameterUuidTest.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesparameters.fk; - -import java.sql.SQLException; -import java.util.Objects; -import java.util.stream.Collectors; -import java.util.stream.Stream; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static java.lang.String.format; -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateActiveRuleParametersRulesParameterUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateActiveRuleParametersRulesParameterUuidTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulateActiveRuleParametersRulesParameterUuid(db.database()); - - @Test - public void populate_rules_parameter_uuids() throws SQLException { - String ruleParamUuid1 = uuidFactory.create(); - long ruleParamId1 = 1L; - insertRuleParameter(ruleParamId1, ruleParamUuid1, 101L); - String activeRuleParameter11 = insertActiveRuleParameter(101L, ruleParamId1); - String activeRuleParameter12 = insertActiveRuleParameter(101L, ruleParamId1); - String activeRuleParameter13 = insertActiveRuleParameter(101L, ruleParamId1); - - String ruleParamUuid2 = uuidFactory.create(); - long ruleParamId2 = 2L; - insertRuleParameter(ruleParamId2, ruleParamUuid2, 101L); - String activeRuleParameter21 = insertActiveRuleParameter(101L, ruleParamId2); - String activeRuleParameter22 = insertActiveRuleParameter(101L, ruleParamId2); - - insertRuleParameter(3L, uuidFactory.create(), 101L); - - underTest.execute(); - - assertRulesParameterUuidsAreNotNull(); - assertThatRulesParametersUuidAreSet(ruleParamUuid1, activeRuleParameter11, activeRuleParameter12, activeRuleParameter13); - assertThatRulesParametersUuidAreSet(ruleParamUuid2, activeRuleParameter21, activeRuleParameter22); - } - - @Test - public void migration_is_reentrant() throws SQLException { - String ruleParamUuid1 = uuidFactory.create(); - long ruleParamId1 = 1L; - insertRuleParameter(ruleParamId1, ruleParamUuid1, 101L); - String activeRuleParameter11 = insertActiveRuleParameter(101L, ruleParamId1); - String activeRuleParameter12 = insertActiveRuleParameter(101L, ruleParamId1); - String activeRuleParameter13 = insertActiveRuleParameter(101L, ruleParamId1); - - underTest.execute(); - - String ruleParamUuid2 = uuidFactory.create(); - long ruleParamId2 = 2L; - insertRuleParameter(ruleParamId2, ruleParamUuid2, 101L); - String activeRuleParameter21 = insertActiveRuleParameter(101L, ruleParamId2); - String activeRuleParameter22 = insertActiveRuleParameter(101L, ruleParamId2); - // re-entrant - underTest.execute(); - - assertRulesParameterUuidsAreNotNull(); - assertThatRulesParametersUuidAreSet(ruleParamUuid1, activeRuleParameter11, activeRuleParameter12, activeRuleParameter13); - assertThatRulesParametersUuidAreSet(ruleParamUuid2, activeRuleParameter21, activeRuleParameter22); - } - - private void assertThatRulesParametersUuidAreSet(String ruleParameterUuid, String... activeRuleParameters) { - assertThat(db.select("select rules_parameter_uuid from active_rule_parameters where uuid in (" - + Stream.of(activeRuleParameters).map(s -> format("'%s'", s)).collect(Collectors.joining(",")) + ")") - .stream() - .map(row -> row.get("RULES_PARAMETER_UUID")) - .filter(o -> !Objects.equals(o, ruleParameterUuid)) - .collect(Collectors.toList())).isEmpty(); - } - - private void assertRulesParameterUuidsAreNotNull() { - assertThat(db.select("select rules_parameter_uuid from active_rule_parameters") - .stream() - .map(row -> row.get("RULES_PARAMETER_UUID")) - .filter(Objects::isNull) - .collect(Collectors.toList())).isEmpty(); - } - - private void insertRuleParameter(Long id, String uuid, Long ruleId) { - db.executeInsert("rules_parameters", - "id", id, - "uuid", uuid, - "rule_id", ruleId, - "name", uuidFactory.create(), - "param_type", uuidFactory.create()); - } - - private String insertActiveRuleParameter(Long ruleId, Long rulesParameterId) { - String uuid = uuidFactory.create(); - db.executeInsert("active_rule_parameters", - "uuid", uuid, - "active_rule_id", ruleId, - "rules_parameter_id", rulesParameterId); - return uuid; - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/AddPrimaryKeyOnUuidColumnOfRulesProfilesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/AddPrimaryKeyOnUuidColumnOfRulesProfilesTableTest.java deleted file mode 100644 index 9afa60ff498..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/AddPrimaryKeyOnUuidColumnOfRulesProfilesTableTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesprofiles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfRulesProfilesTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfRulesProfilesTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddPrimaryKeyOnUuidColumnOfRulesProfilesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("rules_profiles", "pk_rules_profiles", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/AddUuidColumnToRulesProfilesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/AddUuidColumnToRulesProfilesTableTest.java deleted file mode 100644 index 3dca0a58d25..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/AddUuidColumnToRulesProfilesTableTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesprofiles; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUuidColumnToRulesProfilesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToRulesProfilesTableTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - - private DdlChange underTest = new AddUuidColumnToRulesProfilesTable(db.database()); - - @Before - public void setup() { - insertRuleProfile(1L); - insertRuleProfile(2L); - insertRuleProfile(3L); - } - - @Test - public void add_uuid_column_to_rules_profiles() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("rules_profiles", "uuid", Types.VARCHAR, 40, true); - - assertThat(db.countSql("select count(id) from rules_profiles")) - .isEqualTo(3); - } - - private void insertRuleProfile(Long id) { - db.executeInsert("rules_profiles", - "id", id, - "name", "name" + id, - "kee", "kee" + id, - "is_built_in", false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropIdColumnOfRulesProfilesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropIdColumnOfRulesProfilesTableTest.java deleted file mode 100644 index c356f3f0712..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropIdColumnOfRulesProfilesTableTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesprofiles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfRulesProfilesTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfRulesProfilesTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropIdColumnOfRulesProfilesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("rules_profiles", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropKeeColumnOfRulesProfilesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropKeeColumnOfRulesProfilesTableTest.java deleted file mode 100644 index fce041d784a..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropKeeColumnOfRulesProfilesTableTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesprofiles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropKeeColumnOfRulesProfilesTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropKeeColumnOfRulesProfilesTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropKeeColumnOfRulesProfilesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("rules_profiles", "kee"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropPrimaryKeyOnIdColumnOfRulesProfilesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropPrimaryKeyOnIdColumnOfRulesProfilesTableTest.java deleted file mode 100644 index 99724f345d0..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropPrimaryKeyOnIdColumnOfRulesProfilesTableTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesprofiles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v83.util.SqlHelper; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropPrimaryKeyOnIdColumnOfRulesProfilesTableTest { - private static final String TABLE_NAME = "rules_profiles"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfRulesProfilesTableTest.class, "schema.sql"); - - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); - - private DdlChange underTest = new DropPrimaryKeyOnIdColumnOfRulesProfilesTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropUniqueIndexOnKeeColumnOfRulesProfilesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropUniqueIndexOnKeeColumnOfRulesProfilesTableTest.java deleted file mode 100644 index 92452543714..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropUniqueIndexOnKeeColumnOfRulesProfilesTableTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesprofiles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropUniqueIndexOnKeeColumnOfRulesProfilesTableTest { - - private static final String TABLE_NAME = "rules_profiles"; - private static final String INDEX_NAME = "uniq_qprof_key"; - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropUniqueIndexOnKeeColumnOfRulesProfilesTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropUniqueIndexOnKeeColumnOfRulesProfilesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - // migration is re-entrant - underTest.execute(); - - db.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/MakeRulesProfilesUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/MakeRulesProfilesUuidColumnNotNullableTest.java deleted file mode 100644 index 7e6339c43ee..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/MakeRulesProfilesUuidColumnNotNullableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesprofiles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeRulesProfilesUuidColumnNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeRulesProfilesUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeRulesProfilesUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("rules_profiles", "uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/PopulateRulesProfilesUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/PopulateRulesProfilesUuidTest.java deleted file mode 100644 index db6851c9cfc..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/PopulateRulesProfilesUuidTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesprofiles; - -import java.sql.SQLException; -import java.util.Objects; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateRulesProfilesUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateRulesProfilesUuidTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulateRulesProfilesUuid(db.database(), uuidFactory); - - @Test - public void populate_uuids() throws SQLException { - insertRuleProfile(1L); - insertRuleProfile(2L); - insertRuleProfile(3L); - - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertRuleProfile(1L); - insertRuleProfile(2L); - insertRuleProfile(3L); - - underTest.execute(); - // re-entrant - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - private void verifyUuidsAreNotNull() { - assertThat(db.select("select uuid from rules_profiles") - .stream() - .map(row -> row.get("UUID")) - .filter(Objects::isNull) - .collect(Collectors.toList())).isEmpty(); - } - - private void insertRuleProfile(Long id) { - db.executeInsert("rules_profiles", - "id", id, - "name", "name" + id, - "kee", "kee" + id, - "is_built_in", false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/AddProfileUuidColumnToActiveRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/AddProfileUuidColumnToActiveRulesTableTest.java deleted file mode 100644 index a794fc06ccb..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/AddProfileUuidColumnToActiveRulesTableTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesprofiles.fk.activerules; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddProfileUuidColumnToActiveRulesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddProfileUuidColumnToActiveRulesTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddProfileUuidColumnToActiveRulesTable(db.database()); - - @Before - public void setup() { - insertActiveRule("1", 1L, 2L); - insertActiveRule("2", 3L, 4L); - insertActiveRule("3", 5L, 6L); - } - - @Test - public void add_uuid_column_to_rules_profiles() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("active_rules", "profile_uuid", Types.VARCHAR, 40, true); - - assertThat(db.countRowsOfTable("active_rules")) - .isEqualTo(3); - } - - private void insertActiveRule(String uuid, long profileId, long rule_id) { - db.executeInsert("active_rules", - "uuid", uuid, - "profile_id", profileId, - "rule_id", rule_id, - "failure_level", 3); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/AddUniqueIndexOnProfileUuidColumnOfActiveRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/AddUniqueIndexOnProfileUuidColumnOfActiveRulesTableTest.java deleted file mode 100644 index 4801d8cefa4..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/AddUniqueIndexOnProfileUuidColumnOfActiveRulesTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesprofiles.fk.activerules; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class AddUniqueIndexOnProfileUuidColumnOfActiveRulesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUniqueIndexOnProfileUuidColumnOfActiveRulesTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddUniqueIndexOnProfileUuidColumnOfActiveRulesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertUniqueIndex("active_rules", "uniq_profile_rule_ids", "profile_uuid", "rule_id"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - // re-entrant - underTest.execute(); - - db.assertUniqueIndex("active_rules", "uniq_profile_rule_ids", "profile_uuid", "rule_id"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/DropProfileIdColumnOfActiveRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/DropProfileIdColumnOfActiveRulesTableTest.java deleted file mode 100644 index f48b46d8d40..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/DropProfileIdColumnOfActiveRulesTableTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesprofiles.fk.activerules; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropProfileIdColumnOfActiveRulesTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropProfileIdColumnOfActiveRulesTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropProfileIdColumnOfActiveRulesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("active_rules", "profile_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/DropUniqueIndexOnProfileIdColumnOfActiveRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/DropUniqueIndexOnProfileIdColumnOfActiveRulesTableTest.java deleted file mode 100644 index 5524bd2fbd7..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/DropUniqueIndexOnProfileIdColumnOfActiveRulesTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesprofiles.fk.activerules; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -public class DropUniqueIndexOnProfileIdColumnOfActiveRulesTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropUniqueIndexOnProfileIdColumnOfActiveRulesTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropUniqueIndexOnProfileIdColumnOfActiveRulesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertIndexDoesNotExist("perm_tpl_characteristics", "uniq_perm_tpl_charac"); - } - - @Test - public void migration_is_re_entrant() throws SQLException { - underTest.execute(); - - // re-entrant - underTest.execute(); - - db.assertIndexDoesNotExist("perm_tpl_characteristics", "uniq_perm_tpl_charac"); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/MakeActiveRulesProfileUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/MakeActiveRulesProfileUuidColumnNotNullableTest.java deleted file mode 100644 index 33c92e91960..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/MakeActiveRulesProfileUuidColumnNotNullableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesprofiles.fk.activerules; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeActiveRulesProfileUuidColumnNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeActiveRulesProfileUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeActiveRulesProfileUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("active_rules", "profile_uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/PopulateActiveRulesProfileUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/PopulateActiveRulesProfileUuidTest.java deleted file mode 100644 index cb5527ccbd5..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/PopulateActiveRulesProfileUuidTest.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesprofiles.fk.activerules; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateActiveRulesProfileUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateActiveRulesProfileUuidTest.class, "schema.sql"); - - private DataChange underTest = new PopulateActiveRulesProfileUuid(db.database()); - - @Test - public void populate_uuids() throws SQLException { - long ruleProfileId_1 = 1L; - String ruleProfileUuid_1 = "uuid-1"; - insertRuleProfile(ruleProfileId_1, ruleProfileUuid_1); - - long ruleProfileId_2 = 2L; - String ruleProfileUuid_2 = "uuid-2"; - insertRuleProfile(ruleProfileId_2, ruleProfileUuid_2); - - long ruleProfileId_3 = 3L; - String ruleProfileUuid_3 = "uuid-3"; - insertRuleProfile(ruleProfileId_3, ruleProfileUuid_3); - - insertActiveRule("4", ruleProfileId_1); - insertActiveRule("5", ruleProfileId_2); - insertActiveRule("6", ruleProfileId_3); - - underTest.execute(); - - assertThatActiveRulesProfileUuidIsEqualTo("4", ruleProfileUuid_1); - assertThatActiveRulesProfileUuidIsEqualTo("5", ruleProfileUuid_2); - assertThatActiveRulesProfileUuidIsEqualTo("6", ruleProfileUuid_3); - } - - @Test - public void migration_is_reentrant() throws SQLException { - long ruleProfileId_1 = 1L; - String ruleProfileUuid_1 = "uuid-1"; - insertRuleProfile(ruleProfileId_1, ruleProfileUuid_1); - - long ruleProfileId_2 = 2L; - String ruleProfileUuid_2 = "uuid-2"; - insertRuleProfile(ruleProfileId_2, ruleProfileUuid_2); - - long ruleProfileId_3 = 3L; - String ruleProfileUuid_3 = "uuid-3"; - insertRuleProfile(ruleProfileId_3, ruleProfileUuid_3); - - insertActiveRule("4", ruleProfileId_1); - insertActiveRule("5", ruleProfileId_2); - insertActiveRule("6", ruleProfileId_3); - - underTest.execute(); - // re-entrant - underTest.execute(); - - assertThatActiveRulesProfileUuidIsEqualTo("4", ruleProfileUuid_1); - assertThatActiveRulesProfileUuidIsEqualTo("5", ruleProfileUuid_2); - assertThatActiveRulesProfileUuidIsEqualTo("6", ruleProfileUuid_3); - } - - private void assertThatActiveRulesProfileUuidIsEqualTo(String uuid, String expectedUuid) { - assertThat(db.select("select profile_uuid from active_rules where uuid = '" + uuid + "'") - .stream() - .map(row -> row.get("PROFILE_UUID")) - .findFirst()) - .hasValue(expectedUuid); - } - - private void insertActiveRule(String uuid, Long profileId) { - db.executeInsert("active_rules", - "uuid", uuid, - "profile_id", profileId, - "rule_id", 1, - "failure_level", 2); - } - - private void insertRuleProfile(Long id, String uuid) { - db.executeInsert("rules_profiles", - "id", id, - "uuid", uuid, - "name", "name" + id, - "kee", "kee" + id, - "is_built_in", false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/orgqprofiles/PopulateOrgQProfilesRulesProfileUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/orgqprofiles/PopulateOrgQProfilesRulesProfileUuidTest.java deleted file mode 100644 index 238dcf5a012..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/orgqprofiles/PopulateOrgQProfilesRulesProfileUuidTest.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesprofiles.fk.orgqprofiles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.Uuids; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateOrgQProfilesRulesProfileUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateOrgQProfilesRulesProfileUuidTest.class, "schema.sql"); - - private DataChange underTest = new PopulateOrgQProfilesRulesProfileUuid(db.database()); - - @Test - public void populate_uuids() throws SQLException { - long ruleProfileId_1 = 1L; - String ruleProfileUuid_1 = "uuid-1"; - String ruleProfileKee_1 = "kee-1"; - insertRuleProfile(ruleProfileId_1, ruleProfileUuid_1, ruleProfileKee_1); - - long ruleProfileId_2 = 2L; - String ruleProfileUuid_2 = "uuid-2"; - String ruleProfileKee_2 = "kee-2"; - insertRuleProfile(ruleProfileId_2, ruleProfileUuid_2, ruleProfileKee_2); - - long ruleProfileId_3 = 3L; - String ruleProfileUuid_3 = "uuid-3"; - String ruleProfileKee_3 = "kee-3"; - insertRuleProfile(ruleProfileId_3, ruleProfileUuid_3, ruleProfileKee_3); - - String orgQProfileUuid_1 = "orgQProfileUuid_1"; - insertOrgQProfiles(orgQProfileUuid_1, ruleProfileKee_1); - String orgQProfileUuid_2 = "orgQProfileUuid_2"; - insertOrgQProfiles(orgQProfileUuid_2, ruleProfileKee_2); - String orgQProfileUuid_3 = "orgQProfileUuid_3"; - insertOrgQProfiles(orgQProfileUuid_3, ruleProfileKee_3); - - underTest.execute(); - - assertThatOrgQprofileRulesProfileUuidIsEqualTo(orgQProfileUuid_1, ruleProfileUuid_1); - assertThatOrgQprofileRulesProfileUuidIsEqualTo(orgQProfileUuid_2, ruleProfileUuid_2); - assertThatOrgQprofileRulesProfileUuidIsEqualTo(orgQProfileUuid_3, ruleProfileUuid_3); - } - - @Test - public void migration_is_reentrant() throws SQLException { - long ruleProfileId_1 = 1L; - String ruleProfileUuid_1 = "uuid-1"; - String ruleProfileKee_1 = "kee-1"; - insertRuleProfile(ruleProfileId_1, ruleProfileUuid_1, ruleProfileKee_1); - - long ruleProfileId_2 = 2L; - String ruleProfileUuid_2 = "uuid-2"; - String ruleProfileKee_2 = "kee-2"; - insertRuleProfile(ruleProfileId_2, ruleProfileUuid_2, ruleProfileKee_2); - - long ruleProfileId_3 = 3L; - String ruleProfileUuid_3 = "uuid-3"; - String ruleProfileKee_3 = "kee-3"; - insertRuleProfile(ruleProfileId_3, ruleProfileUuid_3, ruleProfileKee_3); - - String orgQProfileUuid_1 = "orgQProfileUuid_1"; - insertOrgQProfiles(orgQProfileUuid_1, ruleProfileKee_1); - String orgQProfileUuid_2 = "orgQProfileUuid_2"; - insertOrgQProfiles(orgQProfileUuid_2, ruleProfileKee_2); - String orgQProfileUuid_3 = "orgQProfileUuid_3"; - insertOrgQProfiles(orgQProfileUuid_3, ruleProfileKee_3); - - underTest.execute(); - - long ruleProfileId_4 = 4L; - String ruleProfileUuid_4 = "uuid-4"; - String ruleProfileKee_4 = "kee-4"; - insertRuleProfile(ruleProfileId_4, ruleProfileUuid_4, ruleProfileKee_4); - - String orgQProfileUuid_4 = "orgQProfileUuid_4"; - insertOrgQProfiles(orgQProfileUuid_4, ruleProfileKee_4); - - // re-entrant - underTest.execute(); - - assertThatOrgQprofileRulesProfileUuidIsEqualTo(orgQProfileUuid_1, ruleProfileUuid_1); - assertThatOrgQprofileRulesProfileUuidIsEqualTo(orgQProfileUuid_2, ruleProfileUuid_2); - assertThatOrgQprofileRulesProfileUuidIsEqualTo(orgQProfileUuid_3, ruleProfileUuid_3); - assertThatOrgQprofileRulesProfileUuidIsEqualTo(orgQProfileUuid_4, ruleProfileUuid_4); - } - - private void assertThatOrgQprofileRulesProfileUuidIsEqualTo(String orgQprofileUuid, String expectedUuid) { - assertThat(db.select("select rules_profile_uuid from org_qprofiles where uuid = '" + orgQprofileUuid + "'") - .stream() - .map(row -> row.get("RULES_PROFILE_UUID")) - .findFirst()) - .hasValue(expectedUuid); - } - - private void insertOrgQProfiles(String uuid, String rulesProfileUuid) { - db.executeInsert("org_qprofiles", - "uuid", uuid, - "organization_uuid", Uuids.createFast(), - "rules_profile_uuid", rulesProfileUuid, - "created_at", System.currentTimeMillis(), - "updated_at", System.currentTimeMillis()); - } - - private void insertRuleProfile(Long id, String uuid, String kee) { - db.executeInsert("rules_profiles", - "id", id, - "uuid", uuid, - "name", "name" + id, - "kee", kee, - "is_built_in", false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/qprofilechanges/PopulateQProfileChangesRulesProfileUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/qprofilechanges/PopulateQProfileChangesRulesProfileUuidTest.java deleted file mode 100644 index ac4936ea4ed..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/qprofilechanges/PopulateQProfileChangesRulesProfileUuidTest.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.rulesprofiles.fk.qprofilechanges; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.Uuids; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateQProfileChangesRulesProfileUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateQProfileChangesRulesProfileUuidTest.class, "schema.sql"); - - private DataChange underTest = new PopulateQProfileChangesRulesProfileUuid(db.database()); - - @Test - public void populate_uuids() throws SQLException { - long ruleProfileId_1 = 1L; - String ruleProfileUuid_1 = "uuid-1"; - String ruleProfileKee_1 = "kee-1"; - insertRuleProfile(ruleProfileId_1, ruleProfileUuid_1, ruleProfileKee_1); - - long ruleProfileId_2 = 2L; - String ruleProfileUuid_2 = "uuid-2"; - String ruleProfileKee_2 = "kee-2"; - insertRuleProfile(ruleProfileId_2, ruleProfileUuid_2, ruleProfileKee_2); - - long ruleProfileId_3 = 3L; - String ruleProfileUuid_3 = "uuid-3"; - String ruleProfileKee_3 = "kee-3"; - insertRuleProfile(ruleProfileId_3, ruleProfileUuid_3, ruleProfileKee_3); - - String qProfileChangeUuid_1 = "qProfileChangeUuid_1"; - insertQProfileChange(qProfileChangeUuid_1, ruleProfileKee_1); - String qProfileChangeUuid_2 = "qProfileChangeUuid_2"; - insertQProfileChange(qProfileChangeUuid_2, ruleProfileKee_2); - String qProfileChangeUuid_3 = "qProfileChangeUuid_3"; - insertQProfileChange(qProfileChangeUuid_3, ruleProfileKee_3); - - underTest.execute(); - - assertThatQProfileChangeRulesProfileUuidIsEqualTo(qProfileChangeUuid_1, ruleProfileUuid_1); - assertThatQProfileChangeRulesProfileUuidIsEqualTo(qProfileChangeUuid_2, ruleProfileUuid_2); - assertThatQProfileChangeRulesProfileUuidIsEqualTo(qProfileChangeUuid_3, ruleProfileUuid_3); - } - - @Test - public void migration_is_reentrant() throws SQLException { - long ruleProfileId_1 = 1L; - String ruleProfileUuid_1 = "uuid-1"; - String ruleProfileKee_1 = "kee-1"; - insertRuleProfile(ruleProfileId_1, ruleProfileUuid_1, ruleProfileKee_1); - - long ruleProfileId_2 = 2L; - String ruleProfileUuid_2 = "uuid-2"; - String ruleProfileKee_2 = "kee-2"; - insertRuleProfile(ruleProfileId_2, ruleProfileUuid_2, ruleProfileKee_2); - - long ruleProfileId_3 = 3L; - String ruleProfileUuid_3 = "uuid-3"; - String ruleProfileKee_3 = "kee-3"; - insertRuleProfile(ruleProfileId_3, ruleProfileUuid_3, ruleProfileKee_3); - - String qProfileChangeUuid_1 = "qProfileChangeUuid_1"; - insertQProfileChange(qProfileChangeUuid_1, ruleProfileKee_1); - String qProfileChangeUuid_2 = "qProfileChangeUuid_2"; - insertQProfileChange(qProfileChangeUuid_2, ruleProfileKee_2); - String qProfileChangeUuid_3 = "qProfileChangeUuid_3"; - insertQProfileChange(qProfileChangeUuid_3, ruleProfileKee_3); - - underTest.execute(); - - long ruleProfileId_4 = 4L; - String ruleProfileUuid_4 = "uuid-4"; - String ruleProfileKee_4 = "kee-4"; - insertRuleProfile(ruleProfileId_4, ruleProfileUuid_4, ruleProfileKee_4); - - String qProfileChangeUuid_4 = "qProfileChangeUuid_4"; - insertQProfileChange(qProfileChangeUuid_4, ruleProfileKee_4); - - // re-entrant - underTest.execute(); - - assertThatQProfileChangeRulesProfileUuidIsEqualTo(qProfileChangeUuid_1, ruleProfileUuid_1); - assertThatQProfileChangeRulesProfileUuidIsEqualTo(qProfileChangeUuid_2, ruleProfileUuid_2); - assertThatQProfileChangeRulesProfileUuidIsEqualTo(qProfileChangeUuid_3, ruleProfileUuid_3); - assertThatQProfileChangeRulesProfileUuidIsEqualTo(qProfileChangeUuid_4, ruleProfileUuid_4); - } - - private void assertThatQProfileChangeRulesProfileUuidIsEqualTo(String qProfileChangeKee, String expectedUuid) { - assertThat(db.select("select rules_profile_uuid from qprofile_changes where kee = '" + qProfileChangeKee + "'") - .stream() - .map(row -> row.get("RULES_PROFILE_UUID")) - .findFirst()) - .hasValue(expectedUuid); - } - - private void insertQProfileChange(String kee, String rulesProfileUuid) { - db.executeInsert("qprofile_changes", - "kee", kee, - "change_type", Uuids.createFast(), - "rules_profile_uuid", rulesProfileUuid, - "created_at", System.currentTimeMillis()); - } - - private void insertRuleProfile(Long id, String uuid, String kee) { - db.executeInsert("rules_profiles", - "id", id, - "uuid", uuid, - "name", "name" + id, - "kee", kee, - "is_built_in", false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/snapshots/AddPrimaryKeyOnUuidColumnOfSnapshotsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/snapshots/AddPrimaryKeyOnUuidColumnOfSnapshotsTableTest.java deleted file mode 100644 index 8301a65fe7e..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/snapshots/AddPrimaryKeyOnUuidColumnOfSnapshotsTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.snapshots; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.version.v83.snapshots.issues.AddPrimaryKeyOnUuidColumnOfSnapshotsTable; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfSnapshotsTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfSnapshotsTableTest.class, "schema.sql"); - - private AddPrimaryKeyOnUuidColumnOfSnapshotsTable underTest = new AddPrimaryKeyOnUuidColumnOfSnapshotsTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("snapshots", "pk_snapshots", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/snapshots/DropIdColumnOfSnapshotsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/snapshots/DropIdColumnOfSnapshotsTableTest.java deleted file mode 100644 index 8cdf3ed937c..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/snapshots/DropIdColumnOfSnapshotsTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.snapshots; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.version.v83.snapshots.issues.DropIdColumnOfSnapshotsTable; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfSnapshotsTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfSnapshotsTableTest.class, "schema.sql"); - - private DropIdColumnOfSnapshotsTable underTest = new DropIdColumnOfSnapshotsTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("snapshots", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/snapshots/DropPrimaryKeyOnIdColumnOfSnapshotsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/snapshots/DropPrimaryKeyOnIdColumnOfSnapshotsTableTest.java deleted file mode 100644 index de7014fef39..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/snapshots/DropPrimaryKeyOnIdColumnOfSnapshotsTableTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.server.platform.db.migration.version.v83.snapshots; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.version.v83.snapshots.issues.DropPrimaryKeyOnIdColumnOfSnapshotsTable; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v83.util.SqlHelper; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropPrimaryKeyOnIdColumnOfSnapshotsTableTest { - - private static final String TABLE_NAME = "snapshots"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfSnapshotsTableTest.class, "schema.sql"); - - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); - - private DropPrimaryKeyOnIdColumnOfSnapshotsTable underTest = new DropPrimaryKeyOnIdColumnOfSnapshotsTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/AddPrimaryKeyOnUuidColumnOfUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/AddPrimaryKeyOnUuidColumnOfUsersTableTest.java deleted file mode 100644 index aa88e22348a..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/AddPrimaryKeyOnUuidColumnOfUsersTableTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfUsersTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfUsersTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddPrimaryKeyOnUuidColumnOfUsersTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("users", "pk_users", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/DropIdColumnOfUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/DropIdColumnOfUsersTableTest.java deleted file mode 100644 index 31875ba8186..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/DropIdColumnOfUsersTableTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfUsersTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfUsersTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropIdColumnOfUsersTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("users", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/DropPrimaryKeyOnIdColumnOfUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/DropPrimaryKeyOnIdColumnOfUsersTableTest.java deleted file mode 100644 index ee4603ec19a..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/DropPrimaryKeyOnIdColumnOfUsersTableTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v83.util.SqlHelper; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropPrimaryKeyOnIdColumnOfUsersTableTest { - private static final String TABLE_NAME = "users"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfUsersTableTest.class, "schema.sql"); - - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); - - private DdlChange underTest = new DropPrimaryKeyOnIdColumnOfUsersTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/DropUniqueIndexOnUuidColumnOfUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/DropUniqueIndexOnUuidColumnOfUsersTableTest.java deleted file mode 100644 index 8d3fce112b8..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/DropUniqueIndexOnUuidColumnOfUsersTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropUniqueIndexOnUuidColumnOfUsersTableTest { - private static final String TABLE_NAME = "users"; - private static final String INDEX_NAME = "users_uuid"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropUniqueIndexOnUuidColumnOfUsersTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropUniqueIndexOnUuidColumnOfUsersTable(db.database()); - - @Test - public void remove_index_if_exists() throws SQLException { - underTest.execute(); - db.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - // re-entrant - underTest.execute(); - db.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/AddIndexOnUserUuidOfGroupsUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/AddIndexOnUserUuidOfGroupsUsersTableTest.java deleted file mode 100644 index 1f60086c2ea..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/AddIndexOnUserUuidOfGroupsUsersTableTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.groupsusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddIndexOnUserUuidOfGroupsUsersTableTest { - - private static final String TABLE_NAME = "groups_users"; - private static final String INDEX_NAME = "index_groups_users_user_uuid"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(AddIndexOnUserUuidOfGroupsUsersTableTest.class, "schema.sql"); - - DdlChange underTest = new AddIndexOnUserUuidOfGroupsUsersTable(dbTester.database()); - - @Test - public void add_index() throws SQLException { - underTest.execute(); - dbTester.assertIndex(TABLE_NAME, INDEX_NAME, "user_uuid"); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - dbTester.assertIndex(TABLE_NAME, INDEX_NAME, "user_uuid"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTableTest.java deleted file mode 100644 index e73ea9b92d6..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.groupsusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTableTest { - - private static final String TABLE_NAME = "groups_users"; - private static final String INDEX_NAME = "groups_users_unique"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTableTest.class, "schema.sql"); - - DdlChange underTest = new AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTable(dbTester.database()); - - @Test - public void add_index() throws SQLException { - underTest.execute(); - dbTester.assertUniqueIndex(TABLE_NAME, INDEX_NAME, "user_uuid", "group_uuid"); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - // re-entrant - underTest.execute(); - dbTester.assertUniqueIndex(TABLE_NAME, INDEX_NAME, "user_uuid", "group_uuid"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/AddUserUuidColumnToGroupsUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/AddUserUuidColumnToGroupsUsersTest.java deleted file mode 100644 index 54557005451..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/AddUserUuidColumnToGroupsUsersTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.groupsusers; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.Uuids; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUserUuidColumnToGroupsUsersTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUserUuidColumnToGroupsUsersTest.class, "schema.sql"); - - private DdlChange underTest = new AddUserUuidColumnToGroupsUsers(db.database()); - - @Before - public void setup() { - insertGroupUser(Uuids.createFast(), 1L); - insertGroupUser(Uuids.createFast(), 2L); - insertGroupUser(Uuids.createFast(), 3L); - } - - @Test - public void add_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("groups_users", "user_uuid", Types.VARCHAR, 40, true); - - assertThat(db.countSql("select count(*) from groups_users")) - .isEqualTo(3); - } - - private void insertGroupUser(String uuid, Long userId) { - db.executeInsert("groups_users", - "group_uuid", uuid, - "user_id", userId + 1); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/DropIndexOnUserIdOfGroupsUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/DropIndexOnUserIdOfGroupsUsersTableTest.java deleted file mode 100644 index 7a6a648af4a..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/DropIndexOnUserIdOfGroupsUsersTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.groupsusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropIndexOnUserIdOfGroupsUsersTableTest { - - private static final String TABLE_NAME = "users_groups"; - private static final String INDEX_NAME = "index_groups_users_on_user_id"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(DropIndexOnUserIdOfGroupsUsersTableTest.class, "schema.sql"); - - DdlChange underTest = new DropIndexOnUserIdOfGroupsUsersTable(dbTester.database()); - - @Test - public void add_index() throws SQLException { - underTest.execute(); - dbTester.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - dbTester.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTableTest.java deleted file mode 100644 index 4bc8a6846ec..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.groupsusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTableTest { - - private static final String TABLE_NAME = "groups_users"; - private static final String INDEX_NAME = "groups_users_unique"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTableTest.class, "schema.sql"); - - DdlChange underTest = new DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTable(dbTester.database()); - - @Test - public void add_index() throws SQLException { - underTest.execute(); - dbTester.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - dbTester.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/DropUserIdColumnOfGroupsUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/DropUserIdColumnOfGroupsUsersTableTest.java deleted file mode 100644 index 1c5e239a066..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/DropUserIdColumnOfGroupsUsersTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.groupsusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropUserIdColumnOfGroupsUsersTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropUserIdColumnOfGroupsUsersTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropUserIdColumnOfGroupsUsersTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("groups_users", "user_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/MakeGroupsUsersUserUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/MakeGroupsUsersUserUuidColumnNotNullableTest.java deleted file mode 100644 index f53d0e87008..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/MakeGroupsUsersUserUuidColumnNotNullableTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.groupsusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v83.rulesprofiles.MakeRulesProfilesUuidColumnNotNullable; - -import static java.sql.Types.VARCHAR; - -public class MakeGroupsUsersUserUuidColumnNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeGroupsUsersUserUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeGroupsUsersUserUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("groups_users", "user_uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/PopulateGroupsUsersUserUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/PopulateGroupsUsersUserUuidTest.java deleted file mode 100644 index e2bde353f35..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/PopulateGroupsUsersUserUuidTest.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.groupsusers; - -import java.sql.SQLException; -import java.util.Objects; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.Uuids; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateGroupsUsersUserUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateGroupsUsersUserUuidTest.class, "schema.sql"); - - private DataChange underTest = new PopulateGroupsUsersUserUuid(db.database()); - - @Test - public void populate_uuids() throws SQLException { - long userId_1 = 1L; - String userUuid_1 = "uuid-1"; - insertUser(userId_1, userUuid_1); - - long userId_2 = 2L; - String userUuid_2 = "uuid-2"; - insertUser(userId_2, userUuid_2); - - long userId_3 = 3L; - String userUuid_3 = "uuid-3"; - insertUser(userId_3, userUuid_3); - - long userId_4 = 4L; - String userUuid_4 = "uuid-4"; - insertUser(userId_4, userUuid_4); - - String groupUuid_1 = Uuids.createFast(); - insertGroupUser(userId_1, groupUuid_1); - String groupUuid_2 = Uuids.createFast(); - insertGroupUser(userId_2, groupUuid_2); - String groupUuid_3 = Uuids.createFast(); - insertGroupUser(userId_3, groupUuid_3); - String groupUuid_4 = Uuids.createFast(); - insertGroupUser(userId_1, groupUuid_4); - - underTest.execute(); - - assertThatGroupsUserUserUuidIsEqualTo(userId_1, groupUuid_1, userUuid_1); - assertThatGroupsUserUserUuidIsEqualTo(userId_2, groupUuid_2, userUuid_2); - assertThatGroupsUserUserUuidIsEqualTo(userId_3, groupUuid_3, userUuid_3); - assertThatGroupsUserUserUuidIsEqualTo(userId_1, groupUuid_4, userUuid_1); - } - - @Test - public void migration_is_reentrant() throws SQLException { - long userId_1 = 1L; - String userUuid_1 = "uuid-1"; - insertUser(userId_1, userUuid_1); - - long userId_2 = 2L; - String userUuid_2 = "uuid-2"; - insertUser(userId_2, userUuid_2); - - long userId_3 = 3L; - String userUuid_3 = "uuid-3"; - insertUser(userId_3, userUuid_3); - - long userId_4 = 4L; - String userUuid_4 = "uuid-4"; - insertUser(userId_4, userUuid_4); - - String groupUuid_1 = Uuids.createFast(); - insertGroupUser(userId_1, groupUuid_1); - String groupUuid_2 = Uuids.createFast(); - insertGroupUser(userId_2, groupUuid_2); - String groupUuid_3 = Uuids.createFast(); - insertGroupUser(userId_3, groupUuid_3); - - underTest.execute(); - - String groupUuid_4 = Uuids.createFast(); - insertGroupUser(userId_1, groupUuid_4); - - // re-entrant - underTest.execute(); - - assertThatGroupsUserUserUuidIsEqualTo(userId_1, groupUuid_1, userUuid_1); - assertThatGroupsUserUserUuidIsEqualTo(userId_2, groupUuid_2, userUuid_2); - assertThatGroupsUserUserUuidIsEqualTo(userId_3, groupUuid_3, userUuid_3); - assertThatGroupsUserUserUuidIsEqualTo(userId_1, groupUuid_4, userUuid_1); - } - - private void assertThatGroupsUserUserUuidIsEqualTo(Long userId, String groupUuid, String expectedUuid) { - assertThat(db.select(String.format("select user_uuid from groups_users where user_id = %d and group_uuid = '%s'", userId, groupUuid)) - .stream() - .map(row -> row.get("USER_UUID")) - .filter(Objects::nonNull) - .findFirst()) - .hasValue(expectedUuid); - } - - private void insertGroupUser(Long userId, String groupUuid) { - db.executeInsert("groups_users", - "user_id", userId, - "group_uuid", groupUuid); - } - - private void insertUser(Long id, String uuid) { - db.executeInsert("users", - "id", id, - "uuid", uuid, - "login", "login" + id, - "external_login", "ex-login" + id, - "external_identity_provider", "ex-provider" + id, - "external_id", id + 1, - "is_root", false, - "onboarded", false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/AddIndexOnUserUuidOfOrganizationMembersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/AddIndexOnUserUuidOfOrganizationMembersTableTest.java deleted file mode 100644 index 300b8bdd41a..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/AddIndexOnUserUuidOfOrganizationMembersTableTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.organizationmembers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddIndexOnUserUuidOfOrganizationMembersTableTest { - - private static final String TABLE_NAME = "organization_members"; - private static final String INDEX_NAME = "org_members_user_uuid"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(AddIndexOnUserUuidOfOrganizationMembersTableTest.class, "schema.sql"); - - DdlChange underTest = new AddIndexOnUserUuidOfOrganizationMembersTable(dbTester.database()); - - @Test - public void add_index() throws SQLException { - underTest.execute(); - dbTester.assertIndex(TABLE_NAME, INDEX_NAME, "user_uuid"); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - dbTester.assertIndex(TABLE_NAME, INDEX_NAME, "user_uuid"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTableTest.java deleted file mode 100644 index 4a57df06503..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.organizationmembers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTableTest.class, "schema.sql"); - - private DdlChange underTest = new AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("organization_members", "pk_organization_members", "user_uuid", "organization_uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/AddUserUuidColumnToOrganizationMembersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/AddUserUuidColumnToOrganizationMembersTest.java deleted file mode 100644 index b3c3fea8d25..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/AddUserUuidColumnToOrganizationMembersTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.organizationmembers; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUserUuidColumnToOrganizationMembersTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUserUuidColumnToOrganizationMembersTest.class, "schema.sql"); - - private DdlChange underTest = new AddUserUuidColumnToOrganizationMembers(db.database()); - - @Before - public void setup() { - insertGroupUser(1L); - insertGroupUser(2L); - insertGroupUser(3L); - } - - @Test - public void add_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("organization_members", "user_uuid", Types.VARCHAR, 40, true); - - assertThat(db.countSql("select count(*) from organization_members")) - .isEqualTo(3); - } - - private void insertGroupUser(Long id) { - db.executeInsert("organization_members", - "user_id", id, - "organization_uuid", "uuid-" + id); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/DropIndexOnUserIdOfOrganizationMembersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/DropIndexOnUserIdOfOrganizationMembersTableTest.java deleted file mode 100644 index e22757456d5..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/DropIndexOnUserIdOfOrganizationMembersTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.organizationmembers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropIndexOnUserIdOfOrganizationMembersTableTest { - - private static final String TABLE_NAME = "organization_members"; - private static final String INDEX_NAME = "ix_org_members_on_user_id"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(DropIndexOnUserIdOfOrganizationMembersTableTest.class, "schema.sql"); - - DdlChange underTest = new DropIndexOnUserIdOfOrganizationMembersTable(dbTester.database()); - - @Test - public void add_index() throws SQLException { - underTest.execute(); - dbTester.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - dbTester.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTableTest.java deleted file mode 100644 index a8fa3adcc85..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTableTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.organizationmembers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v83.util.SqlHelper; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTableTest { - private static final String TABLE_NAME = "organization_members"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTableTest.class, "schema.sql"); - - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); - - private DdlChange underTest = new DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/DropUserIdColumnOfOrganizationMembersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/DropUserIdColumnOfOrganizationMembersTableTest.java deleted file mode 100644 index ffdedf27613..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/DropUserIdColumnOfOrganizationMembersTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.organizationmembers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropUserIdColumnOfOrganizationMembersTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropUserIdColumnOfOrganizationMembersTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropUserIdColumnOfOrganizationMembersTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("organization_members", "user_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/MakeOrganizationMembersUserUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/MakeOrganizationMembersUserUuidColumnNotNullableTest.java deleted file mode 100644 index b435228a59f..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/MakeOrganizationMembersUserUuidColumnNotNullableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.organizationmembers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_SIZE; - -public class MakeOrganizationMembersUserUuidColumnNotNullableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeOrganizationMembersUserUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeOrganizationMembersUserUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("organization_members", "user_uuid", VARCHAR, UUID_SIZE, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/PopulateOrganizationMembersUserUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/PopulateOrganizationMembersUserUuidTest.java deleted file mode 100644 index f94a3ba7590..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/PopulateOrganizationMembersUserUuidTest.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.organizationmembers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.Uuids; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateOrganizationMembersUserUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateOrganizationMembersUserUuidTest.class, "schema.sql"); - - private DataChange underTest = new PopulateOrganizationMembersUserUuid(db.database()); - - @Test - public void populate_uuids() throws SQLException { - long userId_1 = 1L; - String userUuid_1 = "uuid-1"; - insertUser(userId_1, userUuid_1); - - long userId_2 = 2L; - String userUuid_2 = "uuid-2"; - insertUser(userId_2, userUuid_2); - - long userId_3 = 3L; - String userUuid_3 = "uuid-3"; - insertUser(userId_3, userUuid_3); - - long userId_4 = 4L; - String userUuid_4 = "uuid-4"; - insertUser(userId_4, userUuid_4); - - String organizationUuid_1 = Uuids.createFast(); - insertOrganizationMember(userId_1, organizationUuid_1); - String organizationUuid_2 = Uuids.createFast(); - insertOrganizationMember(userId_2, organizationUuid_2); - String organizationUuid_3 = Uuids.createFast(); - insertOrganizationMember(userId_3, organizationUuid_3); - String organizationUuid_4 = Uuids.createFast(); - insertOrganizationMember(userId_4, organizationUuid_4); - String organizationUuid_5 = Uuids.createFast(); - insertOrganizationMember(userId_1, organizationUuid_5); - - underTest.execute(); - - assertThatQProfileChangeRulesProfileUuidIsEqualTo(userId_1, organizationUuid_1, userUuid_1); - assertThatQProfileChangeRulesProfileUuidIsEqualTo(userId_2, organizationUuid_2, userUuid_2); - assertThatQProfileChangeRulesProfileUuidIsEqualTo(userId_3, organizationUuid_3, userUuid_3); - assertThatQProfileChangeRulesProfileUuidIsEqualTo(userId_4, organizationUuid_4, userUuid_4); - assertThatQProfileChangeRulesProfileUuidIsEqualTo(userId_1, organizationUuid_5, userUuid_1); - } - - @Test - public void migration_is_reentrant() throws SQLException { - long userId_1 = 1L; - String userUuid_1 = "uuid-1"; - insertUser(userId_1, userUuid_1); - - long userId_2 = 2L; - String userUuid_2 = "uuid-2"; - insertUser(userId_2, userUuid_2); - - long userId_3 = 3L; - String userUuid_3 = "uuid-3"; - insertUser(userId_3, userUuid_3); - - long userId_4 = 4L; - String userUuid_4 = "uuid-4"; - insertUser(userId_4, userUuid_4); - - String organizationUuid_1 = Uuids.createFast(); - insertOrganizationMember(userId_1, organizationUuid_1); - String organizationUuid_2 = Uuids.createFast(); - insertOrganizationMember(userId_2, organizationUuid_2); - String organizationUuid_3 = Uuids.createFast(); - insertOrganizationMember(userId_3, organizationUuid_3); - - underTest.execute(); - - String organizationUuid_4 = Uuids.createFast(); - insertOrganizationMember(userId_3, organizationUuid_4); - - // re-entrant - underTest.execute(); - - assertThatQProfileChangeRulesProfileUuidIsEqualTo(userId_1, organizationUuid_1, userUuid_1); - assertThatQProfileChangeRulesProfileUuidIsEqualTo(userId_2, organizationUuid_2, userUuid_2); - assertThatQProfileChangeRulesProfileUuidIsEqualTo(userId_3, organizationUuid_3, userUuid_3); - assertThatQProfileChangeRulesProfileUuidIsEqualTo(userId_3, organizationUuid_4, userUuid_3); - } - - private void assertThatQProfileChangeRulesProfileUuidIsEqualTo(Long userId, String organizationUuid, String expectedUuid) { - assertThat(db.select(String.format("select user_uuid from organization_members where user_id = %d and organization_uuid = '%s'", userId, organizationUuid)) - .stream() - .map(row -> row.get("USER_UUID")) - .findFirst()) - .hasValue(expectedUuid); - } - - private void insertOrganizationMember(Long userId, String organizationUuid) { - db.executeInsert("organization_members", - "user_id", userId, - "organization_uuid", organizationUuid); - } - - private void insertUser(Long id, String uuid) { - db.executeInsert("users", - "id", id, - "uuid", uuid, - "login", "login" + id, - "external_login", "ex-login" + id, - "external_identity_provider", "ex-provider" + id, - "external_id", id + 1, - "is_root", false, - "onboarded", false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/AddUserUuidColumnToPermTemplatesUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/AddUserUuidColumnToPermTemplatesUsersTest.java deleted file mode 100644 index b1bf8a67e51..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/AddUserUuidColumnToPermTemplatesUsersTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.permtemplatesusers; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.Uuids; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUserUuidColumnToPermTemplatesUsersTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUserUuidColumnToPermTemplatesUsersTest.class, "schema.sql"); - - private DdlChange underTest = new AddUserUuidColumnToPermTemplatesUsers(db.database()); - - @Before - public void setup() { - insertPermTemplatesUser(Uuids.createFast(), 1L); - insertPermTemplatesUser(Uuids.createFast(), 2L); - insertPermTemplatesUser(Uuids.createFast(), 3L); - } - - @Test - public void add_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("perm_templates_users", "user_uuid", Types.VARCHAR, 40, true); - - assertThat(db.countSql("select count(*) from perm_templates_users")) - .isEqualTo(3); - } - - private void insertPermTemplatesUser(String uuid, long userId) { - db.executeInsert("perm_templates_users", - "uuid", uuid, - "user_id", userId, - "template_id", userId + 100, - "permission_reference", Uuids.createFast()); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/DropUserIdColumnOfPermTemplatesUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/DropUserIdColumnOfPermTemplatesUsersTableTest.java deleted file mode 100644 index 01665365ca4..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/DropUserIdColumnOfPermTemplatesUsersTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.permtemplatesusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropUserIdColumnOfPermTemplatesUsersTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropUserIdColumnOfPermTemplatesUsersTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropUserIdColumnOfPermTemplatesUsersTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("perm_templates_users", "user_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/MakePermTemplatesUsersUserUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/MakePermTemplatesUsersUserUuidColumnNotNullableTest.java deleted file mode 100644 index 423ae483f62..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/MakePermTemplatesUsersUserUuidColumnNotNullableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.permtemplatesusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_SIZE; - -public class MakePermTemplatesUsersUserUuidColumnNotNullableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakePermTemplatesUsersUserUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakePermTemplatesUsersUserUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("perm_templates_users", "user_uuid", VARCHAR, UUID_SIZE, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/PopulatePermTemplatesUsersUserUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/PopulatePermTemplatesUsersUserUuidTest.java deleted file mode 100644 index 9a9cc197d27..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/PopulatePermTemplatesUsersUserUuidTest.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.permtemplatesusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.Uuids; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulatePermTemplatesUsersUserUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulatePermTemplatesUsersUserUuidTest.class, "schema.sql"); - - private DataChange underTest = new PopulatePermTemplatesUsersUserUuid(db.database()); - - @Test - public void populate_uuids() throws SQLException { - long userId_1 = 1L; - String userUuid_1 = "uuid-1"; - insertUser(userId_1, userUuid_1); - - long userId_2 = 2L; - String userUuid_2 = "uuid-2"; - insertUser(userId_2, userUuid_2); - - long userId_3 = 3L; - String userUuid_3 = "uuid-3"; - insertUser(userId_3, userUuid_3); - - long userId_4 = 4L; - String userUuid_4 = "uuid-4"; - insertUser(userId_4, userUuid_4); - - String permTemplatesUserUuid_1 = Uuids.createFast(); - insertPermTemplatesUser(permTemplatesUserUuid_1, userId_1); - String permTemplatesUserUuid_2 = Uuids.createFast(); - insertPermTemplatesUser(permTemplatesUserUuid_2, userId_2); - String permTemplatesUserUuid_3 = Uuids.createFast(); - insertPermTemplatesUser(permTemplatesUserUuid_3, userId_3); - String permTemplatesUserUuid_4 = Uuids.createFast(); - insertPermTemplatesUser(permTemplatesUserUuid_4, userId_4); - String permTemplatesUserUuid_5 = Uuids.createFast(); - insertPermTemplatesUser(permTemplatesUserUuid_5, userId_1); - - underTest.execute(); - - assertThatPermTemplatesUsersUserUuidIsEqualTo(permTemplatesUserUuid_1, userUuid_1); - assertThatPermTemplatesUsersUserUuidIsEqualTo(permTemplatesUserUuid_2, userUuid_2); - assertThatPermTemplatesUsersUserUuidIsEqualTo(permTemplatesUserUuid_3, userUuid_3); - assertThatPermTemplatesUsersUserUuidIsEqualTo(permTemplatesUserUuid_4, userUuid_4); - assertThatPermTemplatesUsersUserUuidIsEqualTo(permTemplatesUserUuid_5, userUuid_1); - } - - @Test - public void migration_is_reentrant() throws SQLException { - long userId_1 = 1L; - String userUuid_1 = "uuid-1"; - insertUser(userId_1, userUuid_1); - - long userId_2 = 2L; - String userUuid_2 = "uuid-2"; - insertUser(userId_2, userUuid_2); - - long userId_3 = 3L; - String userUuid_3 = "uuid-3"; - insertUser(userId_3, userUuid_3); - - long userId_4 = 4L; - String userUuid_4 = "uuid-4"; - insertUser(userId_4, userUuid_4); - - String permTemplatesUserUuid_1 = Uuids.createFast(); - insertPermTemplatesUser(permTemplatesUserUuid_1, userId_1); - String permTemplatesUserUuid_2 = Uuids.createFast(); - insertPermTemplatesUser(permTemplatesUserUuid_2, userId_2); - String permTemplatesUserUuid_3 = Uuids.createFast(); - insertPermTemplatesUser(permTemplatesUserUuid_3, userId_3); - - underTest.execute(); - - String permTemplatesUserUuid_4 = Uuids.createFast(); - insertPermTemplatesUser(permTemplatesUserUuid_4, userId_4); - String permTemplatesUserUuid_5 = Uuids.createFast(); - insertPermTemplatesUser(permTemplatesUserUuid_5, userId_1); - - // re-entrant - underTest.execute(); - - assertThatPermTemplatesUsersUserUuidIsEqualTo(permTemplatesUserUuid_1, userUuid_1); - assertThatPermTemplatesUsersUserUuidIsEqualTo(permTemplatesUserUuid_2, userUuid_2); - assertThatPermTemplatesUsersUserUuidIsEqualTo(permTemplatesUserUuid_3, userUuid_3); - assertThatPermTemplatesUsersUserUuidIsEqualTo(permTemplatesUserUuid_4, userUuid_4); - assertThatPermTemplatesUsersUserUuidIsEqualTo(permTemplatesUserUuid_5, userUuid_1); - } - - private void assertThatPermTemplatesUsersUserUuidIsEqualTo(String permTemplatesUserUuid, String expectedUuid) { - assertThat(db.select(String.format("select user_uuid from perm_templates_users where uuid = '%s'", permTemplatesUserUuid)) - .stream() - .map(row -> row.get("USER_UUID")) - .findFirst()) - .hasValue(expectedUuid); - } - - private void insertPermTemplatesUser(String uuid, long userId) { - db.executeInsert("perm_templates_users", - "uuid", uuid, - "user_id", userId, - "template_id", userId + 100, - "permission_reference", Uuids.createFast()); - } - - private void insertUser(Long id, String uuid) { - db.executeInsert("users", - "id", id, - "uuid", uuid, - "login", "login" + id, - "external_login", "ex-login" + id, - "external_identity_provider", "ex-provider" + id, - "external_id", id + 1, - "is_root", false, - "onboarded", false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/AddUserUuidColumnToPropertiesUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/AddUserUuidColumnToPropertiesUsersTest.java deleted file mode 100644 index 49370b15b1e..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/AddUserUuidColumnToPropertiesUsersTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.properties; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.Uuids; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUserUuidColumnToPropertiesUsersTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUserUuidColumnToPropertiesUsersTest.class, "schema.sql"); - - private DdlChange underTest = new AddUserUuidColumnToPropertiesUsers(db.database()); - - @Before - public void setup() { - insertProperty(Uuids.createFast()); - insertProperty(Uuids.createFast()); - insertProperty(Uuids.createFast()); - } - - @Test - public void add_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("properties", "user_uuid", Types.VARCHAR, 40, true); - - assertThat(db.countSql("select count(*) from properties")) - .isEqualTo(3); - } - - private void insertProperty(String uuid) { - db.executeInsert("properties", - "uuid", uuid, - "prop_key", "kee-" + uuid, - "is_empty", false, - "created_at", System.currentTimeMillis()); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/DropUserIdColumnOfPropertiesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/DropUserIdColumnOfPropertiesTableTest.java deleted file mode 100644 index ca84f8399cf..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/DropUserIdColumnOfPropertiesTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.properties; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropUserIdColumnOfPropertiesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropUserIdColumnOfPropertiesTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropUserIdColumnOfPropertiesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("properties", "user_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/PopulatePropertiesUserUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/PopulatePropertiesUserUuidTest.java deleted file mode 100644 index 63943ddc6ad..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/PopulatePropertiesUserUuidTest.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.properties; - -import java.sql.SQLException; -import java.util.Objects; -import java.util.Optional; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.Uuids; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulatePropertiesUserUuidTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulatePropertiesUserUuidTest.class, "schema.sql"); - - private DataChange underTest = new PopulatePropertiesUserUuid(db.database()); - - @Test - public void populate_uuids() throws SQLException { - long userId_1 = 1L; - String userUuid_1 = "uuid-1"; - insertUser(userId_1, userUuid_1); - - long userId_2 = 2L; - String userUuid_2 = "uuid-2"; - insertUser(userId_2, userUuid_2); - - long userId_3 = 3L; - String userUuid_3 = "uuid-3"; - insertUser(userId_3, userUuid_3); - - long userId_4 = 4L; - String userUuid_4 = "uuid-4"; - insertUser(userId_4, userUuid_4); - - String propertyUuid_1 = Uuids.createFast(); - insertProperty(propertyUuid_1, userId_1); - String propertyUuid_2 = Uuids.createFast(); - insertProperty(propertyUuid_2, userId_2); - String propertyUuid_3 = Uuids.createFast(); - insertProperty(propertyUuid_3, userId_3); - String propertyUuid_4 = Uuids.createFast(); - insertProperty(propertyUuid_4, userId_4); - String propertyUuid_5 = Uuids.createFast(); - insertProperty(propertyUuid_5, null); - - underTest.execute(); - - assertThatPropertyUserUuidIsEqualTo(propertyUuid_1, userUuid_1); - assertThatPropertyUserUuidIsEqualTo(propertyUuid_2, userUuid_2); - assertThatPropertyUserUuidIsEqualTo(propertyUuid_3, userUuid_3); - assertThatPropertyUserUuidIsEqualTo(propertyUuid_4, userUuid_4); - assertThatPropertyUserUuidIsEqualTo(propertyUuid_5, null); - } - - @Test - public void migration_is_reentrant() throws SQLException { - long userId_1 = 1L; - String userUuid_1 = "uuid-1"; - insertUser(userId_1, userUuid_1); - - long userId_2 = 2L; - String userUuid_2 = "uuid-2"; - insertUser(userId_2, userUuid_2); - - long userId_3 = 3L; - String userUuid_3 = "uuid-3"; - insertUser(userId_3, userUuid_3); - - long userId_4 = 4L; - String userUuid_4 = "uuid-4"; - insertUser(userId_4, userUuid_4); - - String propertyUuid_1 = Uuids.createFast(); - insertProperty(propertyUuid_1, userId_1); - String propertyUuid_2 = Uuids.createFast(); - insertProperty(propertyUuid_2, userId_2); - String propertyUuid_3 = Uuids.createFast(); - insertProperty(propertyUuid_3, userId_3); - - underTest.execute(); - - String propertyUuid_4 = Uuids.createFast(); - insertProperty(propertyUuid_4, userId_4); - String propertyUuid_5 = Uuids.createFast(); - insertProperty(propertyUuid_5, null); - - // re-entrant - underTest.execute(); - - assertThatPropertyUserUuidIsEqualTo(propertyUuid_1, userUuid_1); - assertThatPropertyUserUuidIsEqualTo(propertyUuid_2, userUuid_2); - assertThatPropertyUserUuidIsEqualTo(propertyUuid_3, userUuid_3); - assertThatPropertyUserUuidIsEqualTo(propertyUuid_4, userUuid_4); - assertThatPropertyUserUuidIsEqualTo(propertyUuid_5, null); - } - - private void assertThatPropertyUserUuidIsEqualTo(String propertyUuid, String expectedUuid) { - Optional optional = db.select(String.format("select user_uuid from properties where uuid = '%s'", propertyUuid)) - .stream() - .map(row -> row.get("USER_UUID")) - .filter(Objects::nonNull) - .findFirst(); - - if (expectedUuid != null) { - assertThat(optional).hasValue(expectedUuid); - } else { - assertThat(optional).isEmpty(); - } - - } - - private void insertProperty(String uuid, Long userId) { - db.executeInsert("properties", - "uuid", uuid, - "user_id", userId, - "prop_key", "kee-" + uuid, - "is_empty", false, - "created_at", System.currentTimeMillis()); - } - - private void insertUser(Long id, String uuid) { - db.executeInsert("users", - "id", id, - "uuid", uuid, - "login", "login" + id, - "external_login", "ex-login" + id, - "external_identity_provider", "ex-provider" + id, - "external_id", id + 1, - "is_root", false, - "onboarded", false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTableTest.java deleted file mode 100644 index f7aafed1ad5..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTableTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.qprofileeditusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTableTest { - - private static final String TABLE_NAME = "qprofile_edit_users"; - private static final String INDEX_NAME = "qprofile_edit_users_unique"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTableTest.class, "schema.sql"); - - DdlChange underTest = new AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTable(dbTester.database()); - - @Test - public void add_index() throws SQLException { - underTest.execute(); - dbTester.assertUniqueIndex(TABLE_NAME, INDEX_NAME, "user_uuid", "qprofile_uuid"); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - dbTester.assertUniqueIndex(TABLE_NAME, INDEX_NAME, "user_uuid", "qprofile_uuid"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/AddUserUuidColumnToQProfileEditUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/AddUserUuidColumnToQProfileEditUsersTest.java deleted file mode 100644 index 4beb6c96eef..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/AddUserUuidColumnToQProfileEditUsersTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.qprofileeditusers; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.Uuids; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUserUuidColumnToQProfileEditUsersTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUserUuidColumnToQProfileEditUsersTest.class, "schema.sql"); - - private DdlChange underTest = new AddUserUuidColumnToQProfileEditUsers(db.database()); - - @Before - public void setup() { - insertQProfileEditUser(Uuids.createFast(), 1L); - insertQProfileEditUser(Uuids.createFast(), 2L); - insertQProfileEditUser(Uuids.createFast(), 3L); - } - - @Test - public void add_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("qprofile_edit_users", "user_uuid", Types.VARCHAR, 40, true); - - assertThat(db.countSql("select count(*) from qprofile_edit_users")) - .isEqualTo(3); - } - - private void insertQProfileEditUser(String uuid, long userId) { - db.executeInsert("qprofile_edit_users", - "uuid", uuid, - "user_id", userId, - "qprofile_uuid", Uuids.createFast(), - "created_at", System.currentTimeMillis()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTableTest.java deleted file mode 100644 index e7669043943..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTableTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.qprofileeditusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTableTest { - - private static final String TABLE_NAME = "qprofile_edit_users"; - private static final String INDEX_NAME = "qprofile_edit_users_unique"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTableTest.class, "schema.sql"); - - DdlChange underTest = new DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTable(dbTester.database()); - - @Test - public void add_index() throws SQLException { - underTest.execute(); - dbTester.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - dbTester.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/DropUserIdColumnOfQProfileEditUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/DropUserIdColumnOfQProfileEditUsersTableTest.java deleted file mode 100644 index f5b8acdd528..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/DropUserIdColumnOfQProfileEditUsersTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.qprofileeditusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropUserIdColumnOfQProfileEditUsersTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropUserIdColumnOfQProfileEditUsersTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropUserIdColumnOfQProfileEditUsersTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("qprofile_edit_users", "user_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/MakeQProfileEditUsersUserUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/MakeQProfileEditUsersUserUuidColumnNotNullableTest.java deleted file mode 100644 index 1d6b6f54e36..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/MakeQProfileEditUsersUserUuidColumnNotNullableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.qprofileeditusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_SIZE; - -public class MakeQProfileEditUsersUserUuidColumnNotNullableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeQProfileEditUsersUserUuidColumnNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeQProfileEditUsersUserUuidColumnNotNullable(db.database()); - - @Test - public void uuid_column_is_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("qprofile_edit_users", "user_uuid", VARCHAR, UUID_SIZE, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/PopulateQProfileEditUsersUserUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/PopulateQProfileEditUsersUserUuidTest.java deleted file mode 100644 index 28e18bf816d..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/PopulateQProfileEditUsersUserUuidTest.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.qprofileeditusers; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.Uuids; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateQProfileEditUsersUserUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateQProfileEditUsersUserUuidTest.class, "schema.sql"); - - private DataChange underTest = new PopulateQProfileEditUsersUserUuid(db.database()); - - @Test - public void populate_uuids() throws SQLException { - long userId_1 = 1L; - String userUuid_1 = "uuid-1"; - insertUser(userId_1, userUuid_1); - - long userId_2 = 2L; - String userUuid_2 = "uuid-2"; - insertUser(userId_2, userUuid_2); - - long userId_3 = 3L; - String userUuid_3 = "uuid-3"; - insertUser(userId_3, userUuid_3); - - long userId_4 = 4L; - String userUuid_4 = "uuid-4"; - insertUser(userId_4, userUuid_4); - - String qprofileEditUserUuid_1 = Uuids.createFast(); - insertQProfileEditUser(qprofileEditUserUuid_1, userId_1); - String qprofileEditUserUuid_2 = Uuids.createFast(); - insertQProfileEditUser(qprofileEditUserUuid_2, userId_2); - String qprofileEditUserUuid_3 = Uuids.createFast(); - insertQProfileEditUser(qprofileEditUserUuid_3, userId_3); - String qprofileEditUserUuid_4 = Uuids.createFast(); - insertQProfileEditUser(qprofileEditUserUuid_4, userId_4); - String qprofileEditUserUuid_5 = Uuids.createFast(); - insertQProfileEditUser(qprofileEditUserUuid_5, userId_1); - - underTest.execute(); - - assertThatQProfileEditUserUserUuidIsEqualTo(qprofileEditUserUuid_1, userUuid_1); - assertThatQProfileEditUserUserUuidIsEqualTo(qprofileEditUserUuid_2, userUuid_2); - assertThatQProfileEditUserUserUuidIsEqualTo(qprofileEditUserUuid_3, userUuid_3); - assertThatQProfileEditUserUserUuidIsEqualTo(qprofileEditUserUuid_4, userUuid_4); - assertThatQProfileEditUserUserUuidIsEqualTo(qprofileEditUserUuid_5, userUuid_1); - } - - @Test - public void migration_is_reentrant() throws SQLException { - long userId_1 = 1L; - String userUuid_1 = "uuid-1"; - insertUser(userId_1, userUuid_1); - - long userId_2 = 2L; - String userUuid_2 = "uuid-2"; - insertUser(userId_2, userUuid_2); - - long userId_3 = 3L; - String userUuid_3 = "uuid-3"; - insertUser(userId_3, userUuid_3); - - long userId_4 = 4L; - String userUuid_4 = "uuid-4"; - insertUser(userId_4, userUuid_4); - - String qprofileEditUserUuid_1 = Uuids.createFast(); - insertQProfileEditUser(qprofileEditUserUuid_1, userId_1); - String qprofileEditUserUuid_2 = Uuids.createFast(); - insertQProfileEditUser(qprofileEditUserUuid_2, userId_2); - String qprofileEditUserUuid_3 = Uuids.createFast(); - insertQProfileEditUser(qprofileEditUserUuid_3, userId_3); - - underTest.execute(); - - String qprofileEditUserUuid_4 = Uuids.createFast(); - insertQProfileEditUser(qprofileEditUserUuid_4, userId_4); - String qprofileEditUserUuid_5 = Uuids.createFast(); - insertQProfileEditUser(qprofileEditUserUuid_5, userId_1); - - // re-entrant - underTest.execute(); - - assertThatQProfileEditUserUserUuidIsEqualTo(qprofileEditUserUuid_1, userUuid_1); - assertThatQProfileEditUserUserUuidIsEqualTo(qprofileEditUserUuid_2, userUuid_2); - assertThatQProfileEditUserUserUuidIsEqualTo(qprofileEditUserUuid_3, userUuid_3); - assertThatQProfileEditUserUserUuidIsEqualTo(qprofileEditUserUuid_4, userUuid_4); - assertThatQProfileEditUserUserUuidIsEqualTo(qprofileEditUserUuid_5, userUuid_1); - } - - private void assertThatQProfileEditUserUserUuidIsEqualTo(String qprofileEditUserUuid, String expectedUuid) { - assertThat(db.select(String.format("select user_uuid from qprofile_edit_users where uuid = '%s'", qprofileEditUserUuid)) - .stream() - .map(row -> row.get("USER_UUID")) - .findFirst()) - .hasValue(expectedUuid); - } - - private void insertQProfileEditUser(String uuid, long userId) { - db.executeInsert("qprofile_edit_users", - "uuid", uuid, - "user_id", userId, - "qprofile_uuid", Uuids.createFast(), - "created_at", System.currentTimeMillis()); - } - - private void insertUser(Long id, String uuid) { - db.executeInsert("users", - "id", id, - "uuid", uuid, - "login", "login" + id, - "external_login", "ex-login" + id, - "external_identity_provider", "ex-provider" + id, - "external_id", id + 1, - "is_root", false, - "onboarded", false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/AddIndexOnUserUuidOfUserRolesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/AddIndexOnUserUuidOfUserRolesTableTest.java deleted file mode 100644 index d64e1151b25..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/AddIndexOnUserUuidOfUserRolesTableTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.userroles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class AddIndexOnUserUuidOfUserRolesTableTest { - - private static final String TABLE_NAME = "user_roles"; - private static final String INDEX_NAME = "user_roles_user"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(AddIndexOnUserUuidOfUserRolesTableTest.class, "schema.sql"); - - DdlChange underTest = new AddIndexOnUserUuidOfUserRolesTable(dbTester.database()); - - @Test - public void add_index() throws SQLException { - underTest.execute(); - dbTester.assertIndex(TABLE_NAME, INDEX_NAME, "user_uuid"); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - dbTester.assertIndex(TABLE_NAME, INDEX_NAME, "user_uuid"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/AddUserUuidColumnToUserRolesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/AddUserUuidColumnToUserRolesTest.java deleted file mode 100644 index 6103d41fe7d..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/AddUserUuidColumnToUserRolesTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.userroles; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.Uuids; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUserUuidColumnToUserRolesTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUserUuidColumnToUserRolesTest.class, "schema.sql"); - - private DdlChange underTest = new AddUserUuidColumnToUserRoles(db.database()); - - @Before - public void setup() { - insertUserRole(Uuids.createFast(), 1L); - insertUserRole(Uuids.createFast(), 2L); - insertUserRole(Uuids.createFast(), 3L); - } - - @Test - public void add_uuid_column() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("user_roles", "user_uuid", Types.VARCHAR, 40, true); - - assertThat(db.countSql("select count(*) from user_roles")) - .isEqualTo(3); - } - - private void insertUserRole(String uuid, Long userId) { - db.executeInsert("user_roles", - "uuid", uuid, - "organization_uuid", Uuids.createFast(), - "user_id", userId, - "role", Uuids.createFast()); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/DropIndexOnUserIdOfUserRolesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/DropIndexOnUserIdOfUserRolesTableTest.java deleted file mode 100644 index d80fff5cdaf..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/DropIndexOnUserIdOfUserRolesTableTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.userroles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class DropIndexOnUserIdOfUserRolesTableTest { - - private static final String TABLE_NAME = "user_roles"; - private static final String INDEX_NAME = "user_roles_user"; - - @Rule - public CoreDbTester dbTester = CoreDbTester.createForSchema(DropIndexOnUserIdOfUserRolesTableTest.class, "schema.sql"); - - DdlChange underTest = new DropIndexOnUserIdOfUserRolesTable(dbTester.database()); - - @Test - public void add_index() throws SQLException { - underTest.execute(); - dbTester.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - // re-entrant - underTest.execute(); - dbTester.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/DropUserIdColumnOfUserRolesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/DropUserIdColumnOfUserRolesTableTest.java deleted file mode 100644 index 793662bb419..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/DropUserIdColumnOfUserRolesTableTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.userroles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropUserIdColumnOfUserRolesTableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropUserIdColumnOfUserRolesTableTest.class, "schema.sql"); - - private DdlChange underTest = new DropUserIdColumnOfUserRolesTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("user_roles", "user_id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } - -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/PopulateUserRolesUserUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/PopulateUserRolesUserUuidTest.java deleted file mode 100644 index 6a771d21883..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/PopulateUserRolesUserUuidTest.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.users.fk.userroles; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.Uuids; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateUserRolesUserUuidTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateUserRolesUserUuidTest.class, "schema.sql"); - - private DataChange underTest = new PopulateUserRolesUserUuid(db.database()); - - @Test - public void populate_uuids() throws SQLException { - long userId_1 = 1L; - String userUuid_1 = "uuid-1"; - insertUser(userId_1, userUuid_1); - - long userId_2 = 2L; - String userUuid_2 = "uuid-2"; - insertUser(userId_2, userUuid_2); - - long userId_3 = 3L; - String userUuid_3 = "uuid-3"; - insertUser(userId_3, userUuid_3); - - long userId_4 = 4L; - String userUuid_4 = "uuid-4"; - insertUser(userId_4, userUuid_4); - - String userRoleUuid_1 = Uuids.createFast(); - insertUserRole(userRoleUuid_1, userId_1); - String userRoleUuid_2 = Uuids.createFast(); - insertUserRole(userRoleUuid_2, userId_2); - String userRoleUuid_3 = Uuids.createFast(); - insertUserRole(userRoleUuid_3, userId_3); - String userRoleUuid_4 = Uuids.createFast(); - insertUserRole(userRoleUuid_4, userId_4); - String userRoleUuid_5 = Uuids.createFast(); - insertUserRole(userRoleUuid_5, userId_1); - - underTest.execute(); - - assertThatUserRoleUserUuidIsEqualTo(userRoleUuid_1, userUuid_1); - assertThatUserRoleUserUuidIsEqualTo(userRoleUuid_2, userUuid_2); - assertThatUserRoleUserUuidIsEqualTo(userRoleUuid_3, userUuid_3); - assertThatUserRoleUserUuidIsEqualTo(userRoleUuid_4, userUuid_4); - assertThatUserRoleUserUuidIsEqualTo(userRoleUuid_5, userUuid_1); - } - - @Test - public void migration_is_reentrant() throws SQLException { - long userId_1 = 1L; - String userUuid_1 = "uuid-1"; - insertUser(userId_1, userUuid_1); - - long userId_2 = 2L; - String userUuid_2 = "uuid-2"; - insertUser(userId_2, userUuid_2); - - long userId_3 = 3L; - String userUuid_3 = "uuid-3"; - insertUser(userId_3, userUuid_3); - - long userId_4 = 4L; - String userUuid_4 = "uuid-4"; - insertUser(userId_4, userUuid_4); - - String userRoleUuid_1 = Uuids.createFast(); - insertUserRole(userRoleUuid_1, userId_1); - String userRoleUuid_2 = Uuids.createFast(); - insertUserRole(userRoleUuid_2, userId_2); - String userRoleUuid_3 = Uuids.createFast(); - insertUserRole(userRoleUuid_3, userId_3); - - underTest.execute(); - - String userRoleUuid_4 = Uuids.createFast(); - insertUserRole(userRoleUuid_4, userId_4); - String userRoleUuid_5 = Uuids.createFast(); - insertUserRole(userRoleUuid_5, userId_1); - - // re-entrant - underTest.execute(); - - assertThatUserRoleUserUuidIsEqualTo(userRoleUuid_1, userUuid_1); - assertThatUserRoleUserUuidIsEqualTo(userRoleUuid_2, userUuid_2); - assertThatUserRoleUserUuidIsEqualTo(userRoleUuid_3, userUuid_3); - assertThatUserRoleUserUuidIsEqualTo(userRoleUuid_4, userUuid_4); - assertThatUserRoleUserUuidIsEqualTo(userRoleUuid_5, userUuid_1); - } - - private void assertThatUserRoleUserUuidIsEqualTo(String userRoleUuid, String expectedUuid) { - assertThat(db.select(String.format("select user_uuid from user_roles where uuid = '%s'", userRoleUuid)) - .stream() - .map(row -> row.get("USER_UUID")) - .findFirst()) - .hasValue(expectedUuid); - } - - private void insertUserRole(String uuid, Long userId) { - db.executeInsert("user_roles", - "uuid", uuid, - "organization_uuid", Uuids.createFast(), - "user_id", userId, - "role", Uuids.createFast()); - } - - private void insertUser(Long id, String uuid) { - db.executeInsert("users", - "id", id, - "uuid", uuid, - "login", "login" + id, - "external_login", "ex-login" + id, - "external_identity_provider", "ex-provider" + id, - "external_id", id + 1, - "is_root", false, - "onboarded", false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/usertokens/AddPrimaryKeyOnUuidColumnOfUserTokensTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/usertokens/AddPrimaryKeyOnUuidColumnOfUserTokensTableTest.java deleted file mode 100644 index a04284e6375..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/usertokens/AddPrimaryKeyOnUuidColumnOfUserTokensTableTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.usertokens; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyOnUuidColumnOfUserTokensTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfUserTokensTableTest.class, "schema.sql"); - - private MigrationStep underTest = new AddPrimaryKeyOnUuidColumnOfUserTokensTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertPrimaryKey("user_tokens", "pk_user_tokens", "uuid"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/usertokens/AddUuidColumnToUserTokensTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/usertokens/AddUuidColumnToUserTokensTest.java deleted file mode 100644 index 5435864c12a..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/usertokens/AddUuidColumnToUserTokensTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.usertokens; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddUuidColumnToUserTokensTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToUserTokensTest.class, "schema.sql"); - - private DdlChange underTest = new AddUuidColumnToUserTokens(db.database()); - - @Before - public void setup() { - insertUserToken(1L, "user1", "name1", "token1"); - insertUserToken(2L, "user2", "name2", "token2"); - insertUserToken(3L, "user3", "name3", "token3"); - } - - @Test - public void add_uuid_column_to_user_tokens() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("user_tokens", "uuid", Types.VARCHAR, 40, true); - - assertThat(db.countSql("select count(id) from user_tokens")) - .isEqualTo(3); - } - - private void insertUserToken(Long id, String userUuid, String name, String tokenHash) { - db.executeInsert("user_tokens", - "id", id, - "USER_UUID", userUuid, - "NAME", name, - "TOKEN_HASH", tokenHash, - "CREATED_AT", 0L); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/usertokens/DropIdColumnOfUserTokensTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/usertokens/DropIdColumnOfUserTokensTableTest.java deleted file mode 100644 index 7ccd4c4b7ca..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/usertokens/DropIdColumnOfUserTokensTableTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.usertokens; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropIdColumnOfUserTokensTableTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfUserTokensTableTest.class, "schema.sql"); - - private MigrationStep underTest = new DropIdColumnOfUserTokensTable(db.database()); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertColumnDoesNotExist("user_tokens", "id"); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/usertokens/DropPrimaryKeyOnIdColumnOfUserTokensTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/usertokens/DropPrimaryKeyOnIdColumnOfUserTokensTableTest.java deleted file mode 100644 index a58a4a3e1dc..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/usertokens/DropPrimaryKeyOnIdColumnOfUserTokensTableTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.usertokens; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v83.util.SqlHelper; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class DropPrimaryKeyOnIdColumnOfUserTokensTableTest { - - private static final String TABLE_NAME = "user_tokens"; - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfUserTokensTableTest.class, "schema.sql"); - - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); - - private MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfUserTokensTable(db.database(), dropPrimaryKeySqlGenerator); - - @Test - public void execute() throws SQLException { - underTest.execute(); - - db.assertNoPrimaryKey(TABLE_NAME); - } - - @Test - public void migration_is_not_re_entrant() throws SQLException { - underTest.execute(); - - assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/usertokens/MakeUserTokensUuidNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/usertokens/MakeUserTokensUuidNotNullableTest.java deleted file mode 100644 index 929af5554a6..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/usertokens/MakeUserTokensUuidNotNullableTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.usertokens; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.MigrationStep; - -import static java.sql.Types.VARCHAR; - -public class MakeUserTokensUuidNotNullableTest { - - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(MakeUserTokensUuidNotNullableTest.class, "schema.sql"); - - private MigrationStep underTest = new MakeUserTokensUuidNotNullable(db.database()); - - @Test - public void created_at_and_uuid_columns_are_not_null() throws SQLException { - underTest.execute(); - - db.assertColumnDefinition("user_tokens", "uuid", VARCHAR, null, false); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/usertokens/PopulateUserTokensUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/usertokens/PopulateUserTokensUuidTest.java deleted file mode 100644 index e0a967fb5a6..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/usertokens/PopulateUserTokensUuidTest.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.usertokens; - -import java.sql.SQLException; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.UuidFactoryFast; -import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.step.DataChange; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateUserTokensUuidTest { - @Rule - public CoreDbTester db = CoreDbTester.createForSchema(PopulateUserTokensUuidTest.class, "schema.sql"); - - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private DataChange underTest = new PopulateUserTokensUuid(db.database(), uuidFactory); - - @Test - public void populate_uuids() throws SQLException { - insertUserToken(1L, "user1", "name1", "token1"); - insertUserToken(2L, "user2", "name2", "token2"); - insertUserToken(3L, "user3", "name3", "token3"); - - underTest.execute(); - - verifyUuidsAreNotNull(); - } - - @Test - public void migration_is_reentrant() throws SQLException { - insertUserToken(1L, "user1", "name1", "token1"); - insertUserToken(2L, "user2", "name2", "token2"); - insertUserToken(3L, "user3", "name3", "token3"); - - underTest.execute(); - verifyUuidsAreNotNull(); - insertUserToken(4L, "user4", "name4", "token4"); - insertUserToken(5L, "user5", "name5", "token5"); - - List uuids = db.select("select uuid from user_tokens where id = 1 or id = 2 or id = 3") - .stream() - .map(row -> (String) row.get("UUID")) - .collect(Collectors.toList()); - - // re-entrant - underTest.execute(); - verifyUuidsAreNotNull(); - - // verify that uuid set during the first migration have not been updated during the second migration - assertThat(db.select("select uuid from user_tokens") - .stream() - .map(row -> (String) row.get("UUID")) - .collect(Collectors.toList())) - .containsAll(uuids); - } - - private void verifyUuidsAreNotNull() { - assertThat(db.select("select uuid from user_tokens") - .stream() - .map(row -> row.get("UUID")) - .filter(Objects::isNull) - .collect(Collectors.toList())).isEmpty(); - } - - private void insertUserToken(Long id, String userUuid, String name, String tokenHash) { - db.executeInsert("user_tokens", - "id", id, - "USER_UUID", userUuid, - "NAME", name, - "TOKEN_HASH", tokenHash, - "CREATED_AT", 0L); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/util/AddPrimaryKeyBuilderTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/util/AddPrimaryKeyBuilderTest.java deleted file mode 100644 index 3e99cda4a7c..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/util/AddPrimaryKeyBuilderTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.util; - -import org.junit.Test; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyBuilderTest { - - private static final String TABLE_NAME = "issues"; - - @Test - public void generate() { - String sql = new AddPrimaryKeyBuilder(TABLE_NAME, "id").build(); - - assertThat(sql).isEqualTo("ALTER TABLE issues ADD CONSTRAINT pk_issues PRIMARY KEY (id)"); - } - - @Test - public void fail_when_table_name_is_invalid() { - assertThatThrownBy(() -> new AddPrimaryKeyBuilder("abcdefghijklmnopqrstuvwxyz", "id").build()) - .isInstanceOf(IllegalArgumentException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/util/DropPrimaryKeySqlGeneratorTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/util/DropPrimaryKeySqlGeneratorTest.java deleted file mode 100644 index 747ffeeb63f..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/util/DropPrimaryKeySqlGeneratorTest.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v83.util; - -import java.sql.SQLException; -import java.util.List; -import org.junit.Test; -import org.sonar.db.Database; -import org.sonar.db.dialect.H2; -import org.sonar.db.dialect.MsSql; -import org.sonar.db.dialect.Oracle; -import org.sonar.db.dialect.PostgreSql; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class DropPrimaryKeySqlGeneratorTest { - - private static final String TABLE_NAME = "issues"; - private static final String PK_COLUMN = "id"; - private static final String CONSTRAINT = "pk_id"; - - private static final PostgreSql POSTGRESQL = new PostgreSql(); - private static final MsSql MS_SQL = new MsSql(); - private static final Oracle ORACLE = new Oracle(); - private static final org.sonar.db.dialect.H2 H2 = new H2(); - - private Database db = mock(Database.class); - private SqlHelper sqlHelper = mock(SqlHelper.class); - - private DropPrimaryKeySqlGenerator underTest = new DropPrimaryKeySqlGenerator(db, sqlHelper); - - @Test - public void generate_for_postgres_sql() throws SQLException { - when(sqlHelper.getPostgresSqlConstraint(TABLE_NAME)).thenReturn(CONSTRAINT); - when(sqlHelper.getPostgresSqlSequence(TABLE_NAME, "id")).thenReturn(TABLE_NAME + "_id_seq"); - when(db.getDialect()).thenReturn(POSTGRESQL); - - List sqls = underTest.generate(TABLE_NAME, PK_COLUMN, true); - - assertThat(sqls).containsExactly("ALTER TABLE issues ALTER COLUMN id DROP DEFAULT", - "DROP SEQUENCE issues_id_seq", - "ALTER TABLE issues DROP CONSTRAINT pk_id"); - } - - @Test - public void generate_for_ms_sql() throws SQLException { - when(sqlHelper.getMssqlConstraint(TABLE_NAME)).thenReturn(CONSTRAINT); - when(db.getDialect()).thenReturn(MS_SQL); - - List sqls = underTest.generate(TABLE_NAME, PK_COLUMN, true); - - assertThat(sqls).containsExactly("ALTER TABLE issues DROP CONSTRAINT pk_id"); - } - - @Test - public void generate_for_oracle() throws SQLException { - when(sqlHelper.getOracleConstraint(TABLE_NAME)).thenReturn(CONSTRAINT); - when(db.getDialect()).thenReturn(ORACLE); - - List sqls = underTest.generate(TABLE_NAME, PK_COLUMN, true); - - assertThat(sqls).containsExactly("DROP TRIGGER issues_IDT", - "DROP SEQUENCE issues_SEQ", - "ALTER TABLE issues DROP CONSTRAINT pk_id"); - } - - @Test - public void generate_for_h2() throws SQLException { - when(sqlHelper.getH2Constraint(TABLE_NAME)).thenReturn(CONSTRAINT); - when(db.getDialect()).thenReturn(H2); - - List sqls = underTest.generate(TABLE_NAME, PK_COLUMN, true); - - assertThat(sqls).containsExactly("ALTER TABLE issues DROP CONSTRAINT pk_id", - "ALTER TABLE issues ALTER COLUMN id INTEGER NOT NULL"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/DbVersion84Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/DbVersion84Test.java new file mode 100644 index 00000000000..a01d5eef14e --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/DbVersion84Test.java @@ -0,0 +1,42 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84; + +import org.junit.Test; +import org.sonar.server.platform.db.migration.version.DbVersion; + +import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMigrationNotEmpty; +import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMinimumMigrationNumber; + +public class DbVersion84Test { + + private DbVersion underTest = new DbVersion84(); + + @Test + public void migrationNumber_starts_at_3400() { + verifyMinimumMigrationNumber(underTest, 3400); + } + + @Test + public void verify_migration_count() { + verifyMigrationNotEmpty(underTest); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTableTest.java new file mode 100644 index 00000000000..c6cec53b5d1 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.activeruleparameters; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTableTest.class, "schema.sql"); + + private MigrationStep underTest = new AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertPrimaryKey("active_rule_parameters", "pk_active_rule_parameters", "uuid"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddUuidColumnToActiveRuleParametersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddUuidColumnToActiveRuleParametersTest.java new file mode 100644 index 00000000000..52c7c65ed92 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddUuidColumnToActiveRuleParametersTest.java @@ -0,0 +1,62 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.activeruleparameters; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddUuidColumnToActiveRuleParametersTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToActiveRuleParametersTest.class, "schema.sql"); + + private DdlChange underTest = new AddUuidColumnToActiveRuleParametersTable(db.database()); + + @Before + public void setup() { + insertActiveRuleParameter(1L); + insertActiveRuleParameter(2L); + insertActiveRuleParameter(3L); + } + + @Test + public void add_uuid_column_to_active_rule_parameters() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("active_rule_parameters", "uuid", Types.VARCHAR, 40, true); + + assertThat(db.countSql("select count(id) from active_rule_parameters")) + .isEqualTo(3); + } + + private void insertActiveRuleParameter(Long id) { + db.executeInsert("active_rule_parameters", + "id", id, + "active_rule_id", id + 2, + "rules_parameter_id", id + 3); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropIdColumnOfActiveRuleParametersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropIdColumnOfActiveRuleParametersTableTest.java new file mode 100644 index 00000000000..8bf225535c3 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropIdColumnOfActiveRuleParametersTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.activeruleparameters; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropIdColumnOfActiveRuleParametersTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfActiveRuleParametersTableTest.class, "schema.sql"); + + private MigrationStep underTest = new DropIdColumnOfActiveRuleParametersTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("active_rule_parameters", "id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropPrimaryKeyOnIdColumnOfActiveRuleParametersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropPrimaryKeyOnIdColumnOfActiveRuleParametersTableTest.java new file mode 100644 index 00000000000..4900f0fec87 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropPrimaryKeyOnIdColumnOfActiveRuleParametersTableTest.java @@ -0,0 +1,56 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.activeruleparameters; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; +import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropPrimaryKeyOnIdColumnOfActiveRuleParametersTableTest { + + private static final String TABLE_NAME = "active_rule_parameters"; + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfActiveRuleParametersTableTest.class, "schema.sql"); + + private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + + private MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfActiveRuleParametersTable(db.database(), dropPrimaryKeySqlGenerator); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertNoPrimaryKey(TABLE_NAME); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/MakeActiveRuleParametersUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/MakeActiveRuleParametersUuidColumnNotNullableTest.java new file mode 100644 index 00000000000..d698f45a6b9 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/MakeActiveRuleParametersUuidColumnNotNullableTest.java @@ -0,0 +1,43 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.activeruleparameters; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static java.sql.Types.VARCHAR; + +public class MakeActiveRuleParametersUuidColumnNotNullableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(MakeActiveRuleParametersUuidColumnNotNullableTest.class, "schema.sql"); + + private MigrationStep underTest = new MakeActiveRuleParametersUuidColumnNotNullable(db.database()); + + @Test + public void created_at_and_uuid_columns_are_not_null() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("active_rule_parameters", "uuid", VARCHAR, null, false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/PopulateActiveRuleParametersUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/PopulateActiveRuleParametersUuidTest.java new file mode 100644 index 00000000000..0fb5241992b --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/PopulateActiveRuleParametersUuidTest.java @@ -0,0 +1,81 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.activeruleparameters; + +import java.sql.SQLException; +import java.util.Objects; +import java.util.stream.Collectors; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.UuidFactory; +import org.sonar.core.util.UuidFactoryFast; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulateActiveRuleParametersUuidTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulateActiveRuleParametersUuidTest.class, "schema.sql"); + + private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); + private DataChange underTest = new PopulateActiveRuleParametersUuid(db.database(), uuidFactory); + + @Test + public void populate_uuids() throws SQLException { + insertActiveRuleParameter(1L); + insertActiveRuleParameter(2L); + insertActiveRuleParameter(3L); + + underTest.execute(); + + verifyUuidsAreNotNull(); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertActiveRuleParameter(1L); + insertActiveRuleParameter(2L); + insertActiveRuleParameter(3L); + + underTest.execute(); + // re-entrant + underTest.execute(); + + verifyUuidsAreNotNull(); + } + + private void verifyUuidsAreNotNull() { + assertThat(db.select("select uuid from active_rule_parameters") + .stream() + .map(row -> row.get("UUID")) + .filter(Objects::isNull) + .collect(Collectors.toList())).isEmpty(); + } + + private void insertActiveRuleParameter(Long id) { + db.executeInsert("active_rule_parameters", + "id", id, + "active_rule_id", id + 2, + "rules_parameter_id", id + 3); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddActiveRuleUuidColumnToActiveRuleParametersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddActiveRuleUuidColumnToActiveRuleParametersTest.java new file mode 100644 index 00000000000..f09e93fbff9 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddActiveRuleUuidColumnToActiveRuleParametersTest.java @@ -0,0 +1,61 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.activerules; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddActiveRuleUuidColumnToActiveRuleParametersTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddActiveRuleUuidColumnToActiveRuleParametersTest.class, "schema.sql"); + private DdlChange underTest = new AddActiveRuleUuidColumnToActiveRuleParameters(db.database()); + + @Before + public void setup() { + insertActiveRuleParameter(1L); + insertActiveRuleParameter(2L); + insertActiveRuleParameter(3L); + } + + @Test + public void add_active_rule_uuid_column() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("active_rule_parameters", "active_rule_uuid", Types.VARCHAR, 40, true); + + assertThat(db.countRowsOfTable("active_rule_parameters")) + .isEqualTo(3); + } + + private void insertActiveRuleParameter(Long id) { + db.executeInsert("active_rule_parameters", + "uuid", "uuid" + id, + "rules_parameter_id", id, + "value", "value" + id, + "active_rule_id", id + 1); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddIndexOnActiveRuleUuidOfActiveRuleParametersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddIndexOnActiveRuleUuidOfActiveRuleParametersTableTest.java new file mode 100644 index 00000000000..86405983c9f --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddIndexOnActiveRuleUuidOfActiveRuleParametersTableTest.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.activerules; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +public class AddIndexOnActiveRuleUuidOfActiveRuleParametersTableTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddIndexOnActiveRuleUuidOfActiveRuleParametersTableTest.class, "schema.sql"); + + private MigrationStep underTest = new AddIndexOnActiveRuleUuidOfActiveRuleParametersTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertIndex("active_rule_parameters", "arp_active_rule_uuid", "active_rule_uuid"); + } + + @Test + public void migration_is_re_entrant() throws SQLException { + underTest.execute(); + + // re-entrant + underTest.execute(); + + db.assertIndex("active_rule_parameters", "arp_active_rule_uuid", "active_rule_uuid"); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddPrimaryKeyOnUuidColumnOfActiveRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddPrimaryKeyOnUuidColumnOfActiveRulesTableTest.java new file mode 100644 index 00000000000..941c4fc4f03 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddPrimaryKeyOnUuidColumnOfActiveRulesTableTest.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.activerules; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class AddPrimaryKeyOnUuidColumnOfActiveRulesTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfActiveRulesTableTest.class, "schema.sql"); + + private DdlChange underTest = new AddPrimaryKeyOnUuidColumnOfActiveRulesTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertPrimaryKey("active_rules", "pk_active_rules", "uuid"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddUuidColumnToActiveRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddUuidColumnToActiveRulesTableTest.java new file mode 100644 index 00000000000..4805a65018a --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddUuidColumnToActiveRulesTableTest.java @@ -0,0 +1,62 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.activerules; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddUuidColumnToActiveRulesTableTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToActiveRulesTableTest.class, "schema.sql"); + private DdlChange underTest = new AddUuidColumnToActiveRulesTable(db.database()); + + @Before + public void setup() { + insertActiveRule(1L); + insertActiveRule(2L); + insertActiveRule(3L); + } + + @Test + public void add_uuid_column() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("active_rules", "uuid", Types.VARCHAR, 40, true); + + assertThat(db.countRowsOfTable("active_rules")) + .isEqualTo(3); + } + + private void insertActiveRule(Long id) { + db.executeInsert("active_rules", + "id", id, + "profile_id", id + 1, + "rule_id", id + 2, + "failure_level", id + 3); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropActiveRuleIdColumnOfActiveRuleParametersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropActiveRuleIdColumnOfActiveRuleParametersTableTest.java new file mode 100644 index 00000000000..be932ccd028 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropActiveRuleIdColumnOfActiveRuleParametersTableTest.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.activerules; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropActiveRuleIdColumnOfActiveRuleParametersTableTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropActiveRuleIdColumnOfActiveRuleParametersTableTest.class, "schema.sql"); + + private DdlChange underTest = new DropActiveRuleIdColumnOfActiveRuleParametersTable(db.database()); + + @Test + public void execute() throws SQLException { + db.assertColumnDefinition("active_rule_parameters", "active_rule_id", Types.INTEGER, null, false); + underTest.execute(); + db.assertColumnDoesNotExist("active_rule_parameters", "active_rule_id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropIdColumnOfActiveRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropIdColumnOfActiveRulesTableTest.java new file mode 100644 index 00000000000..398aa231a37 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropIdColumnOfActiveRulesTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.activerules; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropIdColumnOfActiveRulesTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfActiveRulesTableTest.class, "schema.sql"); + + private DdlChange underTest = new DropIdColumnOfActiveRulesTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("active_rules", "id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropIndexOnActiveRuleIdOfActiveRuleParametersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropIndexOnActiveRuleIdOfActiveRuleParametersTableTest.java new file mode 100644 index 00000000000..e045fdca222 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropIndexOnActiveRuleIdOfActiveRuleParametersTableTest.java @@ -0,0 +1,54 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.activerules; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +public class DropIndexOnActiveRuleIdOfActiveRuleParametersTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropIndexOnActiveRuleIdOfActiveRuleParametersTableTest.class, "schema.sql"); + + private MigrationStep underTest = new DropIndexOnActiveRuleIdOfActiveRuleParametersTable(db.database()); + + @Test + public void execute() throws SQLException { + db.assertTableExists("active_rule_parameters"); + db.assertIndex("active_rule_parameters", "ix_arp_on_active_rule_id", "active_rule_id"); + + underTest.execute(); + + db.assertIndexDoesNotExist("active_rule_parameters", "ix_arp_on_active_rule_id"); + } + + @Test + public void migration_is_re_entrant() throws SQLException { + underTest.execute(); + + // re-entrant + underTest.execute(); + + db.assertIndexDoesNotExist("active_rule_parameters", "ix_arp_on_active_rule_id"); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropPrimaryKeyOnIdColumnOfActiveRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropPrimaryKeyOnIdColumnOfActiveRulesTableTest.java new file mode 100644 index 00000000000..a0b0b18d8ce --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropPrimaryKeyOnIdColumnOfActiveRulesTableTest.java @@ -0,0 +1,56 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.sonar.server.platform.db.migration.version.v84.activerules; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; +import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropPrimaryKeyOnIdColumnOfActiveRulesTableTest { + + private static final String TABLE_NAME = "active_rules"; + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfActiveRulesTableTest.class, "schema.sql"); + + private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + + private DdlChange underTest = new DropPrimaryKeyOnIdColumnOfActiveRulesTable(db.database(), dropPrimaryKeySqlGenerator); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertNoPrimaryKey(TABLE_NAME); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/MakeActiveRuleParametersActiveRuleUuidNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/MakeActiveRuleParametersActiveRuleUuidNotNullableTest.java new file mode 100644 index 00000000000..82a5bba7e28 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/MakeActiveRuleParametersActiveRuleUuidNotNullableTest.java @@ -0,0 +1,42 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.activerules; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static java.sql.Types.VARCHAR; + +public class MakeActiveRuleParametersActiveRuleUuidNotNullableTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(MakeActiveRuleParametersActiveRuleUuidNotNullableTest.class, "schema.sql"); + + private MigrationStep underTest = new MakeActiveRuleParametersActiveRuleUuidNotNullable(db.database()); + + @Test + public void uuid_column_is_not_null() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("active_rule_parameters", "active_rule_uuid", VARCHAR, null, false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/MakeActiveRulesUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/MakeActiveRulesUuidColumnNotNullableTest.java new file mode 100644 index 00000000000..3c732cc5ce3 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/MakeActiveRulesUuidColumnNotNullableTest.java @@ -0,0 +1,42 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.activerules; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static java.sql.Types.VARCHAR; + +public class MakeActiveRulesUuidColumnNotNullableTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(MakeActiveRulesUuidColumnNotNullableTest.class, "schema.sql"); + + private MigrationStep underTest = new MakeActiveRulesUuidColumnNotNullable(db.database()); + + @Test + public void uuid_column_is_not_nullable() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("active_rules", "uuid", VARCHAR, null, false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/PopulateActiveRuleParametersActiveRuleUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/PopulateActiveRuleParametersActiveRuleUuidTest.java new file mode 100644 index 00000000000..10aaed20c52 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/PopulateActiveRuleParametersActiveRuleUuidTest.java @@ -0,0 +1,102 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.activerules; + +import java.sql.SQLException; +import java.util.List; +import java.util.Map; +import org.assertj.core.groups.Tuple; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.tuple; + +public class PopulateActiveRuleParametersActiveRuleUuidTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulateActiveRuleParametersActiveRuleUuidTest.class, "schema.sql"); + + private DataChange underTest = new PopulateActiveRuleParametersActiveRuleUuid(db.database()); + + @Test + public void populate_uuids() throws SQLException { + insertActiveRule(1L); + insertActiveRule(2L); + insertActiveRule(3L); + + insertActiveRuleParameter(4L, 1L); + insertActiveRuleParameter(5L, 2L); + insertActiveRuleParameter(6L, 3L); + + underTest.execute(); + + assertThatTableContains( + tuple("uuid4", 1L, "uuid1", "value4"), + tuple("uuid5", 2L, "uuid2", "value5"), + tuple("uuid6", 3L, "uuid3", "value6") + ); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertActiveRule(1L); + insertActiveRule(2L); + insertActiveRule(3L); + + insertActiveRuleParameter(4L, 1L); + insertActiveRuleParameter(5L, 2L); + insertActiveRuleParameter(6L, 3L); + + underTest.execute(); + // re-entrant + underTest.execute(); + + assertThatTableContains( + tuple("uuid4", 1L, "uuid1", "value4"), + tuple("uuid5", 2L, "uuid2", "value5"), + tuple("uuid6", 3L, "uuid3", "value6") + ); + } + + private void assertThatTableContains(Tuple... tuples) { + List> select = db.select("select uuid, active_rule_id, active_rule_uuid, value from active_rule_parameters"); + assertThat(select).extracting(m -> m.get("UUID"), m -> m.get("ACTIVE_RULE_ID"), m -> m.get("ACTIVE_RULE_UUID"), m -> m.get("VALUE")) + .containsExactlyInAnyOrder(tuples); + } + + private void insertActiveRule(Long id) { + db.executeInsert("active_rules", + "uuid", "uuid" + id, + "id", id, + "profile_id", id + 1, + "rule_id", id + 2, + "failure_level", id + 3); + } + + private void insertActiveRuleParameter(Long id, Long activeRuleId) { + db.executeInsert("active_rule_parameters", + "uuid", "uuid" + id, + "rules_parameter_id", id, + "value", "value" + id, + "active_rule_id", activeRuleId); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/PopulateActiveRulesUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/PopulateActiveRulesUuidTest.java new file mode 100644 index 00000000000..32f30b4b945 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/PopulateActiveRulesUuidTest.java @@ -0,0 +1,81 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.activerules; + +import java.sql.SQLException; +import java.util.Objects; +import java.util.stream.Collectors; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.UuidFactory; +import org.sonar.core.util.UuidFactoryFast; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulateActiveRulesUuidTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulateActiveRulesUuidTest.class, "schema.sql"); + + private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); + private DataChange underTest = new PopulateActiveRulesUuid(db.database(), uuidFactory); + + @Test + public void populate_uuids() throws SQLException { + insertActiveRule(1L); + insertActiveRule(2L); + insertActiveRule(3L); + + underTest.execute(); + + verifyUuidsAreNotNull(); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertActiveRule(1L); + insertActiveRule(2L); + insertActiveRule(3L); + + underTest.execute(); + // re-entrant + underTest.execute(); + + verifyUuidsAreNotNull(); + } + + private void verifyUuidsAreNotNull() { + assertThat(db.select("select uuid from active_rules") + .stream() + .map(row -> row.get("UUID")) + .filter(Objects::isNull) + .collect(Collectors.toList())).isEmpty(); + } + + private void insertActiveRule(Long id) { + db.executeInsert("active_rules", + "id", id, + "profile_id", id + 1, + "rule_id", id + 2, + "failure_level", id + 3); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTableTest.java new file mode 100644 index 00000000000..5bf532607ee --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTableTest.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.ceactivity; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class AddPrimaryKeyOnUuidColumnOfCeActivityTableTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfCeActivityTableTest.class, "schema.sql"); + + private MigrationStep underTest = new AddPrimaryKeyOnUuidColumnOfCeActivityTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertPrimaryKey("ce_activity", "pk_ce_activity", "uuid"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropIdColumnOfCeActivityTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropIdColumnOfCeActivityTableTest.java new file mode 100644 index 00000000000..34f543fb0e5 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropIdColumnOfCeActivityTableTest.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.ceactivity; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropIdColumnOfCeActivityTableTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfCeActivityTableTest.class, "schema.sql"); + + private MigrationStep underTest = new DropIdColumnOfCeActivityTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("ce_activity", "id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTableTest.java new file mode 100644 index 00000000000..ce746d13e3d --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTableTest.java @@ -0,0 +1,56 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.ceactivity; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; +import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropPrimaryKeyOnIdColumnOfCeActivityTableTest { + + private static final String TABLE_NAME = "ce_activity"; + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfCeActivityTableTest.class, "schema.sql"); + + private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + + private MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfCeActivityTable(db.database(), dropPrimaryKeySqlGenerator); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertNoPrimaryKey(TABLE_NAME); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/cequeue/AddPrimaryKeyOnUuidColumnOfCeQueueTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/cequeue/AddPrimaryKeyOnUuidColumnOfCeQueueTableTest.java new file mode 100644 index 00000000000..e1da942cf89 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/cequeue/AddPrimaryKeyOnUuidColumnOfCeQueueTableTest.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.cequeue; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class AddPrimaryKeyOnUuidColumnOfCeQueueTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfCeQueueTableTest.class, "schema.sql"); + + private MigrationStep underTest = new AddPrimaryKeyOnUuidColumnOfCeQueueTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertPrimaryKey("ce_queue", "pk_ce_queue", "uuid"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropIdColumnOfCeQueueTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropIdColumnOfCeQueueTableTest.java new file mode 100644 index 00000000000..69b969a6aa4 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropIdColumnOfCeQueueTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.cequeue; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropIdColumnOfCeQueueTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfCeQueueTableTest.class, "schema.sql"); + + private MigrationStep underTest = new DropIdColumnOfCeQueueTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("ce_queue", "id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropPrimaryKeyOnIdColumnOfCeQueueTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropPrimaryKeyOnIdColumnOfCeQueueTableTest.java new file mode 100644 index 00000000000..1ddcecbf85f --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropPrimaryKeyOnIdColumnOfCeQueueTableTest.java @@ -0,0 +1,56 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.sonar.server.platform.db.migration.version.v84.cequeue; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; +import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropPrimaryKeyOnIdColumnOfCeQueueTableTest { + + private static final String TABLE_NAME = "ce_queue"; + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfCeQueueTableTest.class, "schema.sql"); + + private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + + private MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfCeQueueTable(db.database(), dropPrimaryKeySqlGenerator); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertNoPrimaryKey(TABLE_NAME); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropUniqueIndexOnUuidColumnOfCeQueueTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropUniqueIndexOnUuidColumnOfCeQueueTableTest.java new file mode 100644 index 00000000000..a86dd681ea1 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropUniqueIndexOnUuidColumnOfCeQueueTableTest.java @@ -0,0 +1,44 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.cequeue; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +public class DropUniqueIndexOnUuidColumnOfCeQueueTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropUniqueIndexOnUuidColumnOfCeQueueTableTest.class, "schema.sql"); + + private MigrationStep underTest = new DropUniqueIndexOnUuidColumnOfCeQueueTable(db.database()); + + @Test + public void execute_drop_index() throws SQLException { + db.assertUniqueIndex("ce_queue", "ce_queue_uuid", "uuid"); + + underTest.execute(); + + db.assertIndexDoesNotExist("ce_queue", "ce_queue_uuid"); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTableTest.java new file mode 100644 index 00000000000..fa6ac38485b --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.duplicationsindex; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTableTest.class, "schema.sql"); + + private MigrationStep underTest = new AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertPrimaryKey("duplications_index", "pk_duplications_index", "uuid"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddUuidToDuplicationsIndexTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddUuidToDuplicationsIndexTableTest.java new file mode 100644 index 00000000000..cea97b64e25 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddUuidToDuplicationsIndexTableTest.java @@ -0,0 +1,70 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.duplicationsindex; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.UuidFactoryFast; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddUuidToDuplicationsIndexTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddUuidToDuplicationsIndexTableTest.class, "schema.sql"); + + private DdlChange underTest = new AddUuidToDuplicationsIndexTable(db.database()); + + private UuidFactoryFast uuidFactory = UuidFactoryFast.getInstance(); + + @Before + public void setup() { + insertDuplicationsIndex(1L); + insertDuplicationsIndex(2L); + insertDuplicationsIndex(3L); + } + + @Test + public void add_uuid_column_to_duplications_index() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("duplications_index", "uuid", Types.VARCHAR, 40, true); + + assertThat(db.countRowsOfTable("duplications_index")) + .isEqualTo(3); + } + + private void insertDuplicationsIndex(Long id) { + db.executeInsert("duplications_index", + "id", id, + "hash", uuidFactory.create(), + "index_in_file", id + 1, + "start_line", id + 2, + "end_line", id + 3, + "component_uuid", uuidFactory.create(), + "analysis_uuid", uuidFactory.create()); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropIdColumnOfDuplicationsIndexTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropIdColumnOfDuplicationsIndexTableTest.java new file mode 100644 index 00000000000..5a68acf0a65 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropIdColumnOfDuplicationsIndexTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.duplicationsindex; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropIdColumnOfDuplicationsIndexTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfDuplicationsIndexTableTest.class, "schema.sql"); + + private MigrationStep underTest = new DropIdColumnOfDuplicationsIndexTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("duplications_index", "id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropPrimaryKeyOnIdColumnOfDuplicationsIndexTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropPrimaryKeyOnIdColumnOfDuplicationsIndexTableTest.java new file mode 100644 index 00000000000..3ae0004ec58 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropPrimaryKeyOnIdColumnOfDuplicationsIndexTableTest.java @@ -0,0 +1,56 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.duplicationsindex; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; +import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropPrimaryKeyOnIdColumnOfDuplicationsIndexTableTest { + + private static final String TABLE_NAME = "duplications_index"; + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfDuplicationsIndexTableTest.class, "schema.sql"); + + private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + + private MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfDuplicationsIndexTable(db.database(), dropPrimaryKeySqlGenerator); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertNoPrimaryKey(TABLE_NAME); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/MakeDuplicationsIndexUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/MakeDuplicationsIndexUuidColumnNotNullableTest.java new file mode 100644 index 00000000000..59a13a7d8de --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/MakeDuplicationsIndexUuidColumnNotNullableTest.java @@ -0,0 +1,43 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.duplicationsindex; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static java.sql.Types.VARCHAR; + +public class MakeDuplicationsIndexUuidColumnNotNullableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(MakeDuplicationsIndexUuidColumnNotNullableTest.class, "schema.sql"); + + private MigrationStep underTest = new MakeDuplicationsIndexUuidColumnNotNullable(db.database()); + + @Test + public void created_at_and_uuid_columns_are_not_null() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("duplications_index", "uuid", VARCHAR, null, false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/PopulateDuplicationsIndexUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/PopulateDuplicationsIndexUuidTest.java new file mode 100644 index 00000000000..b0b89005196 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/PopulateDuplicationsIndexUuidTest.java @@ -0,0 +1,85 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.duplicationsindex; + +import java.sql.SQLException; +import java.util.Objects; +import java.util.stream.Collectors; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.UuidFactory; +import org.sonar.core.util.UuidFactoryFast; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulateDuplicationsIndexUuidTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulateDuplicationsIndexUuidTest.class, "schema.sql"); + + private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); + private DataChange underTest = new PopulateDuplicationsIndexUuid(db.database(), uuidFactory); + + @Test + public void populate_uuids() throws SQLException { + insertDuplicationsIndex(1L); + insertDuplicationsIndex(2L); + insertDuplicationsIndex(3L); + + underTest.execute(); + + verifyUuidsAreNotNull(); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertDuplicationsIndex(1L); + insertDuplicationsIndex(2L); + insertDuplicationsIndex(3L); + + underTest.execute(); + // re-entrant + underTest.execute(); + + verifyUuidsAreNotNull(); + } + + private void verifyUuidsAreNotNull() { + assertThat(db.select("select uuid from duplications_index") + .stream() + .map(row -> row.get("UUID")) + .filter(Objects::isNull) + .collect(Collectors.toList())).isEmpty(); + } + + private void insertDuplicationsIndex(Long id) { + db.executeInsert("duplications_index", + "id", id, + "hash", uuidFactory.create(), + "index_in_file", id + 1, + "start_line", id + 2, + "end_line", id + 3, + "component_uuid", uuidFactory.create(), + "analysis_uuid", uuidFactory.create()); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/events/AddPrimaryKeyOnUuidColumnOfEventsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/events/AddPrimaryKeyOnUuidColumnOfEventsTableTest.java new file mode 100644 index 00000000000..d0029df9158 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/events/AddPrimaryKeyOnUuidColumnOfEventsTableTest.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.events; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class AddPrimaryKeyOnUuidColumnOfEventsTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfEventsTableTest.class, "schema.sql"); + + private AddPrimaryKeyOnUuidColumnOfEventsTable underTest = new AddPrimaryKeyOnUuidColumnOfEventsTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertPrimaryKey("events", "pk_events", "uuid"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/events/DropIdColumnOfEventsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/events/DropIdColumnOfEventsTableTest.java new file mode 100644 index 00000000000..a9ad30adeda --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/events/DropIdColumnOfEventsTableTest.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.events; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropIdColumnOfEventsTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfEventsTableTest.class, "schema.sql"); + + private DropIdColumnOfEventsTable underTest = new DropIdColumnOfEventsTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("events", "id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/events/DropPrimaryKeyOnIdColumnOfEventsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/events/DropPrimaryKeyOnIdColumnOfEventsTableTest.java new file mode 100644 index 00000000000..4e4a7a8b0cf --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/events/DropPrimaryKeyOnIdColumnOfEventsTableTest.java @@ -0,0 +1,55 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.sonar.server.platform.db.migration.version.v84.events; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; +import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropPrimaryKeyOnIdColumnOfEventsTableTest { + + private static final String TABLE_NAME = "events"; + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfEventsTableTest.class, "schema.sql"); + + private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + + private DropPrimaryKeyOnIdColumnOfEventsTable underTest = new DropPrimaryKeyOnIdColumnOfEventsTable(db.database(), dropPrimaryKeySqlGenerator); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertNoPrimaryKey(TABLE_NAME); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/AddPrimaryKeyOnUuidColumnOfFileSourcesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/AddPrimaryKeyOnUuidColumnOfFileSourcesTableTest.java new file mode 100644 index 00000000000..4e8c8797a61 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/AddPrimaryKeyOnUuidColumnOfFileSourcesTableTest.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.filesources; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class AddPrimaryKeyOnUuidColumnOfFileSourcesTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfFileSourcesTableTest.class, "schema.sql"); + + private DdlChange underTest = new AddPrimaryKeyOnUuidColumnOfFileSourcesTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertPrimaryKey("file_sources", "pk_file_sources", "uuid"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/AddUuidColumnToFileSourcesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/AddUuidColumnToFileSourcesTableTest.java new file mode 100644 index 00000000000..265e8bc70c6 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/AddUuidColumnToFileSourcesTableTest.java @@ -0,0 +1,69 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.filesources; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.UuidFactoryFast; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddUuidColumnToFileSourcesTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToFileSourcesTableTest.class, "schema.sql"); + + private DdlChange underTest = new AddUuidColumnToFileSourcesTable(db.database()); + + private UuidFactoryFast uuidFactory = UuidFactoryFast.getInstance(); + + @Before + public void setup() { + insertFileSources(1L); + insertFileSources(2L); + insertFileSources(3L); + } + + @Test + public void add_uuid_column() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("file_sources", "uuid", Types.VARCHAR, 40, true); + + assertThat(db.countRowsOfTable("file_sources")) + .isEqualTo(3); + } + + private void insertFileSources(Long id) { + db.executeInsert("file_sources", + "id", id, + "project_uuid", uuidFactory.create(), + "file_uuid", uuidFactory.create(), + "line_count", id + 1, + "created_at", id + 2, + "updated_at", id + 3); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/DropIdColumnOfFileSourcesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/DropIdColumnOfFileSourcesTableTest.java new file mode 100644 index 00000000000..d6f63eb0317 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/DropIdColumnOfFileSourcesTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.filesources; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropIdColumnOfFileSourcesTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfFileSourcesTableTest.class, "schema.sql"); + + private DdlChange underTest = new DropIdColumnOfFileSourcesTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("file_sources", "id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/DropPrimaryKeyOnIdColumnOfFileSourcesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/DropPrimaryKeyOnIdColumnOfFileSourcesTableTest.java new file mode 100644 index 00000000000..b4add2d6133 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/DropPrimaryKeyOnIdColumnOfFileSourcesTableTest.java @@ -0,0 +1,56 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.sonar.server.platform.db.migration.version.v84.filesources; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; +import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropPrimaryKeyOnIdColumnOfFileSourcesTableTest { + + private static final String TABLE_NAME = "file_sources"; + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfFileSourcesTableTest.class, "schema.sql"); + + private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + + private DdlChange underTest = new DropPrimaryKeyOnIdColumnOfFileSourcesTable(db.database(), dropPrimaryKeySqlGenerator); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertNoPrimaryKey(TABLE_NAME); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/MakeFileSourcesUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/MakeFileSourcesUuidColumnNotNullableTest.java new file mode 100644 index 00000000000..98b6ec4bcbb --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/MakeFileSourcesUuidColumnNotNullableTest.java @@ -0,0 +1,42 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.filesources; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static java.sql.Types.VARCHAR; + +public class MakeFileSourcesUuidColumnNotNullableTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(MakeFileSourcesUuidColumnNotNullableTest.class, "schema.sql"); + + private MigrationStep underTest = new MakeFileSourcesUuidColumnNotNullable(db.database()); + + @Test + public void uuid_column_is_not_nullable() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("file_sources", "uuid", VARCHAR, null, false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/PopulateFileSourcesUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/PopulateFileSourcesUuidTest.java new file mode 100644 index 00000000000..2d1f8cd73b0 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/PopulateFileSourcesUuidTest.java @@ -0,0 +1,83 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.filesources; + +import java.sql.SQLException; +import java.util.Objects; +import java.util.stream.Collectors; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.UuidFactory; +import org.sonar.core.util.UuidFactoryFast; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulateFileSourcesUuidTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulateFileSourcesUuidTest.class, "schema.sql"); + + private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); + private DataChange underTest = new PopulateFileSourcesUuid(db.database(), uuidFactory); + + @Test + public void populate_uuids() throws SQLException { + insertFileSources(1L); + insertFileSources(2L); + insertFileSources(3L); + + underTest.execute(); + + verifyUuidsAreNotNull(); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertFileSources(1L); + insertFileSources(2L); + insertFileSources(3L); + + underTest.execute(); + // re-entrant + underTest.execute(); + + verifyUuidsAreNotNull(); + } + + private void verifyUuidsAreNotNull() { + assertThat(db.select("select uuid from file_sources") + .stream() + .map(row -> row.get("UUID")) + .filter(Objects::isNull) + .collect(Collectors.toList())).isEmpty(); + } + + private void insertFileSources(Long id) { + db.executeInsert("file_sources", + "id", id, + "project_uuid", uuidFactory.create(), + "file_uuid", uuidFactory.create(), + "line_count", id + 1, + "created_at", id + 2, + "updated_at", id + 3); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/AddPrimaryKeyOnUuidColumnOfGroupRolesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/AddPrimaryKeyOnUuidColumnOfGroupRolesTableTest.java new file mode 100644 index 00000000000..5ad9cdfdb96 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/AddPrimaryKeyOnUuidColumnOfGroupRolesTableTest.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.grouproles; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class AddPrimaryKeyOnUuidColumnOfGroupRolesTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfGroupRolesTableTest.class, "schema.sql"); + + private AddPrimaryKeyOnUuidColumnOfGroupRolesTable underTest = new AddPrimaryKeyOnUuidColumnOfGroupRolesTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertPrimaryKey("group_roles", "pk_group_roles", "uuid"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/AddUuidColumnToGroupRolesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/AddUuidColumnToGroupRolesTableTest.java new file mode 100644 index 00000000000..7681f1bf2a6 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/AddUuidColumnToGroupRolesTableTest.java @@ -0,0 +1,68 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.grouproles; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.UuidFactoryFast; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddUuidColumnToGroupRolesTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToGroupRolesTableTest.class, "schema.sql"); + + private DdlChange underTest = new AddUuidColumnToGroupRolesTable(db.database()); + + private UuidFactoryFast uuidFactory = UuidFactoryFast.getInstance(); + + @Before + public void setup() { + insertGroupRoles(1L); + insertGroupRoles(2L); + insertGroupRoles(3L); + } + + @Test + public void add_uuid_column() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("group_roles", "uuid", Types.VARCHAR, 40, true); + + assertThat(db.countRowsOfTable("group_roles")) + .isEqualTo(3); + } + + private void insertGroupRoles(Long id) { + db.executeInsert("group_roles", + "id", id, + "organization_uuid", uuidFactory.create(), + "group_id", id + 1, + "role", id + 2, + "component_uuid", uuidFactory.create()); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/DropIdColumnOfGroupRolesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/DropIdColumnOfGroupRolesTableTest.java new file mode 100644 index 00000000000..96d2ed9de2e --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/DropIdColumnOfGroupRolesTableTest.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.grouproles; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropIdColumnOfGroupRolesTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfGroupRolesTableTest.class, "schema.sql"); + + private DropIdColumnOfGroupRolesTable underTest = new DropIdColumnOfGroupRolesTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("group_roles", "id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/DropPrimaryKeyOnIdColumnOfGroupRolesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/DropPrimaryKeyOnIdColumnOfGroupRolesTableTest.java new file mode 100644 index 00000000000..670a6711c30 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/DropPrimaryKeyOnIdColumnOfGroupRolesTableTest.java @@ -0,0 +1,55 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.sonar.server.platform.db.migration.version.v84.grouproles; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; +import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropPrimaryKeyOnIdColumnOfGroupRolesTableTest { + + private static final String TABLE_NAME = "group_roles"; + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfGroupRolesTableTest.class, "schema.sql"); + + private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + + private DropPrimaryKeyOnIdColumnOfGroupRolesTable underTest = new DropPrimaryKeyOnIdColumnOfGroupRolesTable(db.database(), dropPrimaryKeySqlGenerator); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertNoPrimaryKey(TABLE_NAME); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/MakeGroupRolesUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/MakeGroupRolesUuidColumnNotNullableTest.java new file mode 100644 index 00000000000..7db12ca3382 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/MakeGroupRolesUuidColumnNotNullableTest.java @@ -0,0 +1,42 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.grouproles; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static java.sql.Types.VARCHAR; + +public class MakeGroupRolesUuidColumnNotNullableTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(MakeGroupRolesUuidColumnNotNullableTest.class, "schema.sql"); + + private MigrationStep underTest = new MakeGroupRolesUuidColumnNotNullable(db.database()); + + @Test + public void uuid_column_is_not_nullable() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("group_roles", "uuid", VARCHAR, null, false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/PopulateGroupRolesUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/PopulateGroupRolesUuidTest.java new file mode 100644 index 00000000000..2aea473c62c --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/PopulateGroupRolesUuidTest.java @@ -0,0 +1,84 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.grouproles; + +import java.sql.SQLException; +import java.util.Objects; +import java.util.stream.Collectors; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.UuidFactory; +import org.sonar.core.util.UuidFactoryFast; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulateGroupRolesUuidTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulateGroupRolesUuidTest.class, "schema.sql"); + + private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); + private DataChange underTest = new PopulateGroupRolesUuid(db.database(), uuidFactory); + + @Test + public void populate_uuids() throws SQLException { + insertGroupRoles(1L); + insertGroupRoles(2L); + insertGroupRoles(3L); + + underTest.execute(); + + verifyUuidsAreNotNull(); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertGroupRoles(1L); + insertGroupRoles(2L); + insertGroupRoles(3L); + + underTest.execute(); + // re-entrant + underTest.execute(); + + verifyUuidsAreNotNull(); + } + + private void verifyUuidsAreNotNull() { + assertThat(db.select("select uuid from group_roles") + .stream() + .map(row -> row.get("UUID")) + .filter(Objects::isNull) + .collect(Collectors.toList())).isEmpty(); + } + + private void insertGroupRoles(Long id) { + db.executeInsert("group_roles", + "id", id, + "uuid", uuidFactory.create(), + "organization_uuid", uuidFactory.create(), + "group_id", id + 1, + "role", id + 2, + "component_uuid", uuidFactory.create()); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/AddPrimaryKeyOnUuidColumnOfGroupsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/AddPrimaryKeyOnUuidColumnOfGroupsTableTest.java new file mode 100644 index 00000000000..9cfdd19f1e7 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/AddPrimaryKeyOnUuidColumnOfGroupsTableTest.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class AddPrimaryKeyOnUuidColumnOfGroupsTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfGroupsTableTest.class, "schema.sql"); + + private DdlChange underTest = new AddPrimaryKeyOnUuidColumnOfGroupsTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertPrimaryKey("groups", "pk_groups", "uuid"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/AddUuidColumnToGroupsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/AddUuidColumnToGroupsTableTest.java new file mode 100644 index 00000000000..69a5faced10 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/AddUuidColumnToGroupsTableTest.java @@ -0,0 +1,61 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddUuidColumnToGroupsTableTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToGroupsTableTest.class, "schema.sql"); + private DdlChange underTest = new AddUuidColumnToGroupsTable(db.database()); + + @Before + public void setup() { + insertGroups(1L); + insertGroups(2L); + insertGroups(3L); + } + + @Test + public void add_uuid_column() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("groups", "uuid", Types.VARCHAR, 40, true); + + assertThat(db.countRowsOfTable("groups")) + .isEqualTo(3); + } + + private void insertGroups(Long id) { + db.executeInsert("groups", + "id", id, + "organization_uuid", "org" + id, + "name", "name" + id); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/DropIdColumnOfGroupsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/DropIdColumnOfGroupsTableTest.java new file mode 100644 index 00000000000..9e1025f7f35 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/DropIdColumnOfGroupsTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropIdColumnOfGroupsTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfGroupsTableTest.class, "schema.sql"); + + private DdlChange underTest = new DropIdColumnOfGroupsTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("groups", "id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/DropPrimaryKeyOnIdColumnOfGroupsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/DropPrimaryKeyOnIdColumnOfGroupsTableTest.java new file mode 100644 index 00000000000..9986f83caff --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/DropPrimaryKeyOnIdColumnOfGroupsTableTest.java @@ -0,0 +1,56 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.sonar.server.platform.db.migration.version.v84.groups; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; +import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropPrimaryKeyOnIdColumnOfGroupsTableTest { + + private static final String TABLE_NAME = "groups"; + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfGroupsTableTest.class, "schema.sql"); + + private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + + private DdlChange underTest = new DropPrimaryKeyOnIdColumnOfGroupsTable(db.database(), dropPrimaryKeySqlGenerator); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertNoPrimaryKey(TABLE_NAME); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/MakeGroupsUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/MakeGroupsUuidColumnNotNullableTest.java new file mode 100644 index 00000000000..b9283aabf4c --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/MakeGroupsUuidColumnNotNullableTest.java @@ -0,0 +1,42 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static java.sql.Types.VARCHAR; + +public class MakeGroupsUuidColumnNotNullableTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(MakeGroupsUuidColumnNotNullableTest.class, "schema.sql"); + + private MigrationStep underTest = new MakeGroupsUuidColumnNotNullable(db.database()); + + @Test + public void uuid_column_is_not_nullable() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("groups", "uuid", VARCHAR, null, false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/PopulateGroupsUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/PopulateGroupsUuidTest.java new file mode 100644 index 00000000000..c86023bca74 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/PopulateGroupsUuidTest.java @@ -0,0 +1,80 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups; + +import java.sql.SQLException; +import java.util.Objects; +import java.util.stream.Collectors; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.UuidFactory; +import org.sonar.core.util.UuidFactoryFast; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulateGroupsUuidTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulateGroupsUuidTest.class, "schema.sql"); + + private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); + private DataChange underTest = new PopulateGroupsUuid(db.database(), uuidFactory); + + @Test + public void populate_uuids() throws SQLException { + insertGroups(1L); + insertGroups(2L); + insertGroups(3L); + + underTest.execute(); + + verifyUuidsAreNotNull(); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertGroups(1L); + insertGroups(2L); + insertGroups(3L); + + underTest.execute(); + // re-entrant + underTest.execute(); + + verifyUuidsAreNotNull(); + } + + private void verifyUuidsAreNotNull() { + assertThat(db.select("select uuid from groups") + .stream() + .map(row -> row.get("UUID")) + .filter(Objects::isNull) + .collect(Collectors.toList())).isEmpty(); + } + + private void insertGroups(Long id) { + db.executeInsert("groups", + "id", id, + "organization_uuid", "org" + id, + "name", "name" + id); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/AddGroupUuidColumnToGroupRolesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/AddGroupUuidColumnToGroupRolesTest.java new file mode 100644 index 00000000000..ede97fbc071 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/AddGroupUuidColumnToGroupRolesTest.java @@ -0,0 +1,64 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.grouproles; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddGroupUuidColumnToGroupRolesTest { + private static final String TABLE_NAME = "group_roles"; + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddGroupUuidColumnToGroupRolesTest.class, "schema.sql"); + private DdlChange underTest = new AddGroupUuidColumnToGroupRoles(db.database()); + + @Before + public void setup() { + insertGroupRole(1L); + insertGroupRole(2L); + insertGroupRole(3L); + } + + @Test + public void add_active_rule_uuid_column() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition(TABLE_NAME, "group_uuid", Types.VARCHAR, 40, true); + + assertThat(db.countRowsOfTable(TABLE_NAME)) + .isEqualTo(3); + } + + private void insertGroupRole(Long id) { + db.executeInsert(TABLE_NAME, + "uuid", "uuid" + id, + "group_id", id + 1, + "role", "role" + id, + "organization_uuid", "org" + id + ); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/AddIndexOnGroupUuidOfGroupRolesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/AddIndexOnGroupUuidOfGroupRolesTableTest.java new file mode 100644 index 00000000000..1315fbc7e18 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/AddIndexOnGroupUuidOfGroupRolesTableTest.java @@ -0,0 +1,54 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.grouproles; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +public class AddIndexOnGroupUuidOfGroupRolesTableTest { + private static final String TABLE_NAME = "group_roles"; + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddIndexOnGroupUuidOfGroupRolesTableTest.class, "schema.sql"); + + private MigrationStep underTest = new AddIndexOnGroupUuidOfGroupRolesTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertUniqueIndex(TABLE_NAME, "uniq_group_roles", "organization_uuid", "group_uuid", + "component_uuid", "role"); + } + + @Test + public void migration_is_re_entrant() throws SQLException { + underTest.execute(); + + // re-entrant + underTest.execute(); + + db.assertUniqueIndex(TABLE_NAME, "uniq_group_roles", "organization_uuid", "group_uuid", + "component_uuid", "role"); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/DropGroupIdColumnOfGroupRolesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/DropGroupIdColumnOfGroupRolesTableTest.java new file mode 100644 index 00000000000..563e38137e6 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/DropGroupIdColumnOfGroupRolesTableTest.java @@ -0,0 +1,52 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.grouproles; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropGroupIdColumnOfGroupRolesTableTest { + private static final String TABLE_NAME = "group_roles"; + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropGroupIdColumnOfGroupRolesTableTest.class, "schema.sql"); + + private DdlChange underTest = new DropGroupIdColumnOfGroupRolesTable(db.database()); + + @Test + public void execute() throws SQLException { + db.assertColumnDefinition(TABLE_NAME, "group_id", Types.INTEGER, null, true); + underTest.execute(); + db.assertColumnDoesNotExist(TABLE_NAME, "group_id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/DropIndexOnGroupIdOfGroupRolesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/DropIndexOnGroupIdOfGroupRolesTableTest.java new file mode 100644 index 00000000000..aeaf1d7a930 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/DropIndexOnGroupIdOfGroupRolesTableTest.java @@ -0,0 +1,56 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.grouproles; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +public class DropIndexOnGroupIdOfGroupRolesTableTest { + private static final String TABLE_NAME = "group_roles"; + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropIndexOnGroupIdOfGroupRolesTableTest.class, "schema.sql"); + + private MigrationStep underTest = new DropIndexOnGroupIdOfGroupRolesTable(db.database()); + + @Test + public void execute() throws SQLException { + db.assertTableExists(TABLE_NAME); + db.assertUniqueIndex(TABLE_NAME, "uniq_group_roles", "organization_uuid", "group_id", + "component_uuid", "role"); + + underTest.execute(); + + db.assertIndexDoesNotExist(TABLE_NAME, "uniq_group_roles"); + } + + @Test + public void migration_is_re_entrant() throws SQLException { + underTest.execute(); + + // re-entrant + underTest.execute(); + + db.assertIndexDoesNotExist(TABLE_NAME, "uniq_group_roles"); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/PopulateGroupRolesGroupUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/PopulateGroupRolesGroupUuidTest.java new file mode 100644 index 00000000000..b06d18d5eab --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/PopulateGroupRolesGroupUuidTest.java @@ -0,0 +1,104 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.grouproles; + +import java.sql.SQLException; +import java.util.List; +import java.util.Map; +import org.assertj.core.groups.Tuple; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.tuple; + +public class PopulateGroupRolesGroupUuidTest { + private static final String TABLE_NAME = "group_roles"; + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulateGroupRolesGroupUuidTest.class, "schema.sql"); + + private DataChange underTest = new PopulateGroupRolesGroupUuid(db.database()); + + @Test + public void populate_uuids() throws SQLException { + insertGroup(1L); + insertGroup(2L); + insertGroup(3L); + + insertGroupRole(4L, 1L); + insertGroupRole(5L, 2L); + insertGroupRole(6L, 3L); + + underTest.execute(); + + assertThatTableContains( + tuple("uuid4", 1L, "uuid1"), + tuple("uuid5", 2L, "uuid2"), + tuple("uuid6", 3L, "uuid3") + ); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertGroup(1L); + insertGroup(2L); + insertGroup(3L); + + insertGroupRole(4L, 1L); + insertGroupRole(5L, 2L); + insertGroupRole(6L, 3L); + + underTest.execute(); + // re-entrant + underTest.execute(); + + assertThatTableContains( + tuple("uuid4", 1L, "uuid1"), + tuple("uuid5", 2L, "uuid2"), + tuple("uuid6", 3L, "uuid3") + ); + } + + private void assertThatTableContains(Tuple... tuples) { + List> select = db.select("select uuid, group_id, group_uuid from " + TABLE_NAME); + assertThat(select).extracting(m -> m.get("UUID"), m -> m.get("GROUP_ID"), m -> m.get("GROUP_UUID")) + .containsExactlyInAnyOrder(tuples); + } + + private void insertGroup(Long id) { + db.executeInsert("groups", + "id", id, + "uuid", "uuid" + id, + "organization_uuid", "org" + id, + "name", "name" + id); + } + + private void insertGroupRole(Long id, Long groupId) { + db.executeInsert(TABLE_NAME, + "uuid", "uuid" + id, + "group_id", groupId, + "role", "role" + id, + "organization_uuid", "org" + id + ); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/AddGroupUuidColumnToGroupsUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/AddGroupUuidColumnToGroupsUsersTest.java new file mode 100644 index 00000000000..15f4c2bdb65 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/AddGroupUuidColumnToGroupsUsersTest.java @@ -0,0 +1,62 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.groupsusers; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddGroupUuidColumnToGroupsUsersTest { + private static final String TABLE_NAME = "groups_users"; + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddGroupUuidColumnToGroupsUsersTest.class, "schema.sql"); + private DdlChange underTest = new AddGroupUuidColumnToGroupsUsers(db.database()); + + @Before + public void setup() { + insertGroupsUser(1L); + insertGroupsUser(2L); + insertGroupsUser(3L); + } + + @Test + public void add_active_rule_uuid_column() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition(TABLE_NAME, "group_uuid", Types.VARCHAR, 40, true); + + assertThat(db.countRowsOfTable(TABLE_NAME)) + .isEqualTo(3); + } + + private void insertGroupsUser(Long id) { + db.executeInsert(TABLE_NAME, + "user_id", id, + "group_id", id + 1 + ); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/AddIndexOnGroupUuidOfGroupsUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/AddIndexOnGroupUuidOfGroupsUsersTableTest.java new file mode 100644 index 00000000000..dfd9750c3da --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/AddIndexOnGroupUuidOfGroupsUsersTableTest.java @@ -0,0 +1,54 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.groupsusers; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +public class AddIndexOnGroupUuidOfGroupsUsersTableTest { + private static final String TABLE_NAME = "groups_users"; + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddIndexOnGroupUuidOfGroupsUsersTableTest.class, "schema.sql"); + + private MigrationStep underTest = new AddIndexOnGroupUuidOfGroupsUsersTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertIndex(TABLE_NAME, "index_groups_users_group_uuid", "group_uuid"); + db.assertUniqueIndex(TABLE_NAME, "groups_users_unique", "group_uuid", "user_id"); + } + + @Test + public void migration_is_re_entrant() throws SQLException { + underTest.execute(); + + // re-entrant + underTest.execute(); + + db.assertIndex(TABLE_NAME, "index_groups_users_group_uuid", "group_uuid"); + db.assertUniqueIndex(TABLE_NAME, "groups_users_unique", "group_uuid", "user_id"); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/DropGroupIdColumnOfGroupsUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/DropGroupIdColumnOfGroupsUsersTableTest.java new file mode 100644 index 00000000000..af3e9ed14b4 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/DropGroupIdColumnOfGroupsUsersTableTest.java @@ -0,0 +1,52 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.groupsusers; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropGroupIdColumnOfGroupsUsersTableTest { + private static final String TABLE_NAME = "groups_users"; + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropGroupIdColumnOfGroupsUsersTableTest.class, "schema.sql"); + + private DdlChange underTest = new DropGroupIdColumnOfGroupsUsersTable(db.database()); + + @Test + public void execute() throws SQLException { + db.assertColumnDefinition(TABLE_NAME, "group_id", Types.BIGINT, null, true); + underTest.execute(); + db.assertColumnDoesNotExist(TABLE_NAME, "group_id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/DropIndexOnGroupIdOfGroupsUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/DropIndexOnGroupIdOfGroupsUsersTableTest.java new file mode 100644 index 00000000000..c9392b6cdf2 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/DropIndexOnGroupIdOfGroupsUsersTableTest.java @@ -0,0 +1,60 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.groupsusers; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +public class DropIndexOnGroupIdOfGroupsUsersTableTest { + private static final String TABLE_NAME = "groups_users"; + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropIndexOnGroupIdOfGroupsUsersTableTest.class, "schema.sql"); + + private MigrationStep underTest = new DropIndexOnGroupIdOfGroupsUsersTable(db.database()); + + @Test + public void execute() throws SQLException { + db.assertTableExists(TABLE_NAME); + db.assertIndex(TABLE_NAME, "index_groups_users_on_group_id", "group_id"); + db.assertUniqueIndex(TABLE_NAME, "groups_users_unique", "group_id", "user_id"); + + underTest.execute(); + + db.assertIndexDoesNotExist(TABLE_NAME, "index_groups_users_on_group_id"); + db.assertIndexDoesNotExist(TABLE_NAME, "groups_users_unique"); + + } + + @Test + public void migration_is_re_entrant() throws SQLException { + underTest.execute(); + + // re-entrant + underTest.execute(); + + db.assertIndexDoesNotExist(TABLE_NAME, "index_groups_users_on_group_id"); + db.assertIndexDoesNotExist(TABLE_NAME, "groups_users_unique"); + + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/MakeGroupsUsersGroupUuidNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/MakeGroupsUsersGroupUuidNotNullableTest.java new file mode 100644 index 00000000000..679319c9b25 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/MakeGroupsUsersGroupUuidNotNullableTest.java @@ -0,0 +1,44 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.groupsusers; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static java.sql.Types.VARCHAR; + +public class MakeGroupsUsersGroupUuidNotNullableTest { + private static final String TABLE_NAME = "groups_users"; + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(MakeGroupsUsersGroupUuidNotNullableTest.class, "schema.sql"); + + private MigrationStep underTest = new MakeGroupsUsersGroupUuidNotNullable(db.database()); + + @Test + public void uuid_column_is_not_null() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition(TABLE_NAME, "group_uuid", VARCHAR, null, false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/PopulateGroupsUsersGroupUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/PopulateGroupsUsersGroupUuidTest.java new file mode 100644 index 00000000000..7f4de0a6a36 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/PopulateGroupsUsersGroupUuidTest.java @@ -0,0 +1,101 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.groupsusers; + +import java.sql.SQLException; +import java.util.List; +import java.util.Map; +import org.assertj.core.groups.Tuple; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.tuple; + +public class PopulateGroupsUsersGroupUuidTest { + private static final String TABLE_NAME = "groups_users"; + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulateGroupsUsersGroupUuidTest.class, "schema.sql"); + + private DataChange underTest = new PopulateGroupsUsersGroupUuid(db.database()); + + @Test + public void populate_uuids() throws SQLException { + insertGroup(1L); + insertGroup(2L); + insertGroup(3L); + + insertGroupsUser(4L, 1L); + insertGroupsUser(5L, 2L); + insertGroupsUser(6L, 3L); + + underTest.execute(); + + assertThatTableContains( + tuple(1L, "uuid1"), + tuple(2L, "uuid2"), + tuple(3L, "uuid3") + ); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertGroup(1L); + insertGroup(2L); + insertGroup(3L); + + insertGroupsUser(4L, 1L); + insertGroupsUser(5L, 2L); + insertGroupsUser(6L, 3L); + + underTest.execute(); + // re-entrant + underTest.execute(); + + assertThatTableContains( + tuple( 1L, "uuid1"), + tuple(2L, "uuid2"), + tuple(3L, "uuid3") + ); + } + + private void assertThatTableContains(Tuple... tuples) { + List> select = db.select("select group_id, group_uuid from " + TABLE_NAME); + assertThat(select).extracting( m -> m.get("GROUP_ID"), m -> m.get("GROUP_UUID")) + .containsExactlyInAnyOrder(tuples); + } + + private void insertGroup(Long id) { + db.executeInsert("groups", + "id", id, + "uuid", "uuid" + id, + "organization_uuid", "org" + id); + } + + private void insertGroupsUser(Long id, Long group) { + db.executeInsert(TABLE_NAME, + "user_id", id, + "group_id", group + ); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/AddDefaultGroupUuidColumnToOrganizationsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/AddDefaultGroupUuidColumnToOrganizationsTest.java new file mode 100644 index 00000000000..8d13e632718 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/AddDefaultGroupUuidColumnToOrganizationsTest.java @@ -0,0 +1,68 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.organizations; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddDefaultGroupUuidColumnToOrganizationsTest { + private static final String TABLE_NAME = "organizations"; + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddDefaultGroupUuidColumnToOrganizationsTest.class, "schema.sql"); + private DdlChange underTest = new AddDefaultGroupUuidColumnToOrganizations(db.database()); + + @Before + public void setup() { + insertOrganization(1L); + insertOrganization(2L); + insertOrganization(3L); + } + + @Test + public void add_active_rule_uuid_column() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition(TABLE_NAME, "default_group_uuid", Types.VARCHAR, 40, true); + + assertThat(db.countRowsOfTable(TABLE_NAME)) + .isEqualTo(3); + } + + private void insertOrganization(Long id) { + db.executeInsert(TABLE_NAME, + "uuid", "uuid" + id, + "kee", "kee" + id, + "name", "name" + id, + "default_quality_gate_uuid", "default_quality_gate_uuid" + id, + "new_project_private", true, + "subscription", "subscription" + id, + "created_at", id + 1, + "updated_at", id + 2 + ); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/DropDefaultGroupIdColumnOfOrganizationsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/DropDefaultGroupIdColumnOfOrganizationsTableTest.java new file mode 100644 index 00000000000..a7e3fc9446d --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/DropDefaultGroupIdColumnOfOrganizationsTableTest.java @@ -0,0 +1,52 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.organizations; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropDefaultGroupIdColumnOfOrganizationsTableTest { + private static final String TABLE_NAME = "organizations"; + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropDefaultGroupIdColumnOfOrganizationsTableTest.class, "schema.sql"); + + private DdlChange underTest = new DropDefaultGroupIdColumnOfOrganizationsTable(db.database()); + + @Test + public void execute() throws SQLException { + db.assertColumnDefinition(TABLE_NAME, "default_group_id", Types.INTEGER, null, true); + underTest.execute(); + db.assertColumnDoesNotExist(TABLE_NAME, "default_group_id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/PopulateOrganizationsDefaultGroupUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/PopulateOrganizationsDefaultGroupUuidTest.java new file mode 100644 index 00000000000..e26033d3882 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/organizations/PopulateOrganizationsDefaultGroupUuidTest.java @@ -0,0 +1,108 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.organizations; + +import java.sql.SQLException; +import java.util.List; +import java.util.Map; +import org.assertj.core.groups.Tuple; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.tuple; + +public class PopulateOrganizationsDefaultGroupUuidTest { + private static final String TABLE_NAME = "organizations"; + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulateOrganizationsDefaultGroupUuidTest.class, "schema.sql"); + + private DataChange underTest = new PopulateOrganizationsDefaultGroupUuid(db.database()); + + @Test + public void populate_uuids() throws SQLException { + insertGroup(1L); + insertGroup(2L); + insertGroup(3L); + + insertOrganization(4L, 1L); + insertOrganization(5L, 2L); + insertOrganization(6L, 3L); + + underTest.execute(); + + assertThatTableContains( + tuple("uuid4", 1L, "uuid1"), + tuple("uuid5", 2L, "uuid2"), + tuple("uuid6", 3L, "uuid3") + ); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertGroup(1L); + insertGroup(2L); + insertGroup(3L); + + insertOrganization(4L, 1L); + insertOrganization(5L, 2L); + insertOrganization(6L, 3L); + + underTest.execute(); + // re-entrant + underTest.execute(); + + assertThatTableContains( + tuple("uuid4", 1L, "uuid1"), + tuple("uuid5", 2L, "uuid2"), + tuple("uuid6", 3L, "uuid3") + ); + } + + private void assertThatTableContains(Tuple... tuples) { + List> select = db.select("select uuid, default_group_id, default_group_uuid from " + TABLE_NAME); + assertThat(select).extracting(m -> m.get("UUID"), m -> m.get("DEFAULT_GROUP_ID"), m -> m.get("DEFAULT_GROUP_UUID")) + .containsExactlyInAnyOrder(tuples); + } + + private void insertGroup(Long id) { + db.executeInsert("groups", + "id", id, + "uuid", "uuid" + id, + "organization_uuid", "org" + id); + } + + private void insertOrganization(Long id, Long groupId) { + db.executeInsert(TABLE_NAME, + "uuid", "uuid" + id, + "kee", "kee" + id, + "name", "name" + id, + "default_group_id", groupId, + "default_quality_gate_uuid", "default_quality_gate_uuid" + id, + "new_project_private", true, + "subscription", "subscription" + id, + "created_at", id + 1, + "updated_at", id + 2 + ); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/AddGroupUuidColumnToPermTemplatesGroupsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/AddGroupUuidColumnToPermTemplatesGroupsTest.java new file mode 100644 index 00000000000..5918f63d1c8 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/AddGroupUuidColumnToPermTemplatesGroupsTest.java @@ -0,0 +1,64 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.permtemplatesgroups; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddGroupUuidColumnToPermTemplatesGroupsTest { + private static final String TABLE_NAME = "perm_templates_groups"; + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddGroupUuidColumnToPermTemplatesGroupsTest.class, "schema.sql"); + private DdlChange underTest = new AddGroupUuidColumnToPermTemplatesGroups(db.database()); + + @Before + public void setup() { + insertPermTemplatesGroup(1L); + insertPermTemplatesGroup(2L); + insertPermTemplatesGroup(3L); + } + + @Test + public void add_active_rule_uuid_column() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition(TABLE_NAME, "group_uuid", Types.VARCHAR, 40, true); + + assertThat(db.countRowsOfTable(TABLE_NAME)) + .isEqualTo(3); + } + + private void insertPermTemplatesGroup(Long id) { + db.executeInsert(TABLE_NAME, + "uuid", "uuid" + id, + "group_id", id + 1, + "permission_reference", "permission_reference" + id, + "template_id", id + 2 + ); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/DropGroupIdColumnOfPermTemplatesGroupsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/DropGroupIdColumnOfPermTemplatesGroupsTableTest.java new file mode 100644 index 00000000000..3a0eb3b2d5c --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/DropGroupIdColumnOfPermTemplatesGroupsTableTest.java @@ -0,0 +1,52 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.permtemplatesgroups; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropGroupIdColumnOfPermTemplatesGroupsTableTest { + private static final String TABLE_NAME = "perm_templates_groups"; + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropGroupIdColumnOfPermTemplatesGroupsTableTest.class, "schema.sql"); + + private DdlChange underTest = new DropGroupIdColumnOfPermTemplatesGroupsTable(db.database()); + + @Test + public void execute() throws SQLException { + db.assertColumnDefinition(TABLE_NAME, "group_id", Types.INTEGER, null, true); + underTest.execute(); + db.assertColumnDoesNotExist(TABLE_NAME, "group_id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/PopulatePermTemplatesGroupsGroupUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/PopulatePermTemplatesGroupsGroupUuidTest.java new file mode 100644 index 00000000000..7a504e88354 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/PopulatePermTemplatesGroupsGroupUuidTest.java @@ -0,0 +1,103 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.permtemplatesgroups; + +import java.sql.SQLException; +import java.util.List; +import java.util.Map; +import org.assertj.core.groups.Tuple; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.tuple; + +public class PopulatePermTemplatesGroupsGroupUuidTest { + private static final String TABLE_NAME = "perm_templates_groups"; + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulatePermTemplatesGroupsGroupUuidTest.class, "schema.sql"); + + private DataChange underTest = new PopulatePermTemplatesGroupsGroupUuid(db.database()); + + @Test + public void populate_uuids() throws SQLException { + insertGroup(1L); + insertGroup(2L); + insertGroup(3L); + + insertPermTemplatesGroup(4L, 1L); + insertPermTemplatesGroup(5L, 2L); + insertPermTemplatesGroup(6L, 3L); + + underTest.execute(); + + assertThatTableContains( + tuple("uuid4", 1L, "uuid1"), + tuple("uuid5", 2L, "uuid2"), + tuple("uuid6", 3L, "uuid3") + ); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertGroup(1L); + insertGroup(2L); + insertGroup(3L); + + insertPermTemplatesGroup(4L, 1L); + insertPermTemplatesGroup(5L, 2L); + insertPermTemplatesGroup(6L, 3L); + + underTest.execute(); + // re-entrant + underTest.execute(); + + assertThatTableContains( + tuple("uuid4", 1L, "uuid1"), + tuple("uuid5", 2L, "uuid2"), + tuple("uuid6", 3L, "uuid3") + ); + } + + private void assertThatTableContains(Tuple... tuples) { + List> select = db.select("select uuid, group_id, group_uuid from " + TABLE_NAME); + assertThat(select).extracting(m -> m.get("UUID"), m -> m.get("GROUP_ID"), m -> m.get("GROUP_UUID")) + .containsExactlyInAnyOrder(tuples); + } + + private void insertGroup(Long id) { + db.executeInsert("groups", + "id", id, + "uuid", "uuid" + id, + "organization_uuid", "org" + id); + } + + private void insertPermTemplatesGroup(Long id, Long groupId) { + db.executeInsert(TABLE_NAME, + "uuid", "uuid" + id, + "group_id", groupId, + "permission_reference", "permission_reference" + id, + "template_id", id + 2 + ); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/AddGroupUuidColumnToQProfileEditGroupsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/AddGroupUuidColumnToQProfileEditGroupsTest.java new file mode 100644 index 00000000000..827cbd311c2 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/AddGroupUuidColumnToQProfileEditGroupsTest.java @@ -0,0 +1,63 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.qprofileeditgroups; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddGroupUuidColumnToQProfileEditGroupsTest { + private static final String TABLE_NAME = "qprofile_edit_groups"; + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddGroupUuidColumnToQProfileEditGroupsTest.class, "schema.sql"); + private DdlChange underTest = new AddGroupUuidColumnToQProfileEditGroups(db.database()); + + @Before + public void setup() { + insertQProfileEditGroup(1L); + insertQProfileEditGroup(2L); + insertQProfileEditGroup(3L); + } + + @Test + public void add_active_rule_uuid_column() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition(TABLE_NAME, "group_uuid", Types.VARCHAR, 40, true); + + assertThat(db.countRowsOfTable(TABLE_NAME)) + .isEqualTo(3); + } + + private void insertQProfileEditGroup(Long id) { + db.executeInsert(TABLE_NAME, + "uuid", "uuid" + id, + "group_id", id + 1, + "qprofile_uuid", "qprofile_uuid" + id, + "created_at", id + 3); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/AddIndexOnGroupUuidOfQProfileEditGroupsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/AddIndexOnGroupUuidOfQProfileEditGroupsTableTest.java new file mode 100644 index 00000000000..acc492dced6 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/AddIndexOnGroupUuidOfQProfileEditGroupsTableTest.java @@ -0,0 +1,53 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.qprofileeditgroups; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +public class AddIndexOnGroupUuidOfQProfileEditGroupsTableTest { + private static final String TABLE_NAME = "qprofile_edit_groups"; + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddIndexOnGroupUuidOfQProfileEditGroupsTableTest.class, "schema.sql"); + + private MigrationStep underTest = new AddIndexOnGroupUuidOfQProfileEditGroupsTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertUniqueIndex(TABLE_NAME, "qprofile_edit_groups_unique", "group_uuid", "qprofile_uuid"); + } + + @Test + public void migration_is_re_entrant() throws SQLException { + underTest.execute(); + + // re-entrant + underTest.execute(); + + db.assertUniqueIndex(TABLE_NAME, "qprofile_edit_groups_unique", "group_uuid", "qprofile_uuid"); + + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/DropGroupIdColumnOfQProfileEditGroupsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/DropGroupIdColumnOfQProfileEditGroupsTableTest.java new file mode 100644 index 00000000000..2ecb6e43e3e --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/DropGroupIdColumnOfQProfileEditGroupsTableTest.java @@ -0,0 +1,52 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.qprofileeditgroups; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropGroupIdColumnOfQProfileEditGroupsTableTest { + private static final String TABLE_NAME = "qprofile_edit_groups"; + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropGroupIdColumnOfQProfileEditGroupsTableTest.class, "schema.sql"); + + private DdlChange underTest = new DropGroupIdColumnOfQProfileEditGroupsTable(db.database()); + + @Test + public void execute() throws SQLException { + db.assertColumnDefinition(TABLE_NAME, "group_id", Types.INTEGER, null, false); + underTest.execute(); + db.assertColumnDoesNotExist(TABLE_NAME, "group_id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/DropIndexOnGroupIdOfQProfileEditGroupsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/DropIndexOnGroupIdOfQProfileEditGroupsTableTest.java new file mode 100644 index 00000000000..321497c9f8a --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/DropIndexOnGroupIdOfQProfileEditGroupsTableTest.java @@ -0,0 +1,56 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.qprofileeditgroups; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +public class DropIndexOnGroupIdOfQProfileEditGroupsTableTest { + private static final String TABLE_NAME = "qprofile_edit_groups"; + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropIndexOnGroupIdOfQProfileEditGroupsTableTest.class, "schema.sql"); + + private MigrationStep underTest = new DropIndexOnGroupIdOfQProfileEditGroupsTable(db.database()); + + @Test + public void execute() throws SQLException { + db.assertTableExists(TABLE_NAME); + db.assertUniqueIndex(TABLE_NAME, "qprofile_edit_groups_unique", "group_id", "qprofile_uuid"); + + + underTest.execute(); + + db.assertIndexDoesNotExist(TABLE_NAME, "qprofile_edit_groups_unique"); + } + + @Test + public void migration_is_re_entrant() throws SQLException { + underTest.execute(); + + // re-entrant + underTest.execute(); + + db.assertIndexDoesNotExist(TABLE_NAME, "qprofile_edit_groups_unique"); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/MakeQProfileEditGroupsGroupUuidNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/MakeQProfileEditGroupsGroupUuidNotNullableTest.java new file mode 100644 index 00000000000..8228c750145 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/MakeQProfileEditGroupsGroupUuidNotNullableTest.java @@ -0,0 +1,44 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.qprofileeditgroups; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static java.sql.Types.VARCHAR; + +public class MakeQProfileEditGroupsGroupUuidNotNullableTest { + private static final String TABLE_NAME = "qprofile_edit_groups"; + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(MakeQProfileEditGroupsGroupUuidNotNullableTest.class, "schema.sql"); + + private MigrationStep underTest = new MakeQProfileEditGroupsGroupUuidNotNullable(db.database()); + + @Test + public void uuid_column_is_not_null() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition(TABLE_NAME, "group_uuid", VARCHAR, null, false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/PopulateQProfileEditGroupsGroupUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/PopulateQProfileEditGroupsGroupUuidTest.java new file mode 100644 index 00000000000..e6d65ba4d97 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/PopulateQProfileEditGroupsGroupUuidTest.java @@ -0,0 +1,102 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.groups.qprofileeditgroups; + +import java.sql.SQLException; +import java.util.List; +import java.util.Map; +import org.assertj.core.groups.Tuple; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.tuple; + +public class PopulateQProfileEditGroupsGroupUuidTest { + private static final String TABLE_NAME = "qprofile_edit_groups"; + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulateQProfileEditGroupsGroupUuidTest.class, "schema.sql"); + + private DataChange underTest = new PopulateQProfileEditGroupsGroupUuid(db.database()); + + @Test + public void populate_uuids() throws SQLException { + insertGroup(1L); + insertGroup(2L); + insertGroup(3L); + + insertQProfileEditGroup(4L, 1L); + insertQProfileEditGroup(5L, 2L); + insertQProfileEditGroup(6L, 3L); + + underTest.execute(); + + assertThatTableContains( + tuple("uuid4", 1L, "uuid1"), + tuple("uuid5", 2L, "uuid2"), + tuple("uuid6", 3L, "uuid3") + ); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertGroup(1L); + insertGroup(2L); + insertGroup(3L); + + insertQProfileEditGroup(4L, 1L); + insertQProfileEditGroup(5L, 2L); + insertQProfileEditGroup(6L, 3L); + + underTest.execute(); + // re-entrant + underTest.execute(); + + assertThatTableContains( + tuple("uuid4", 1L, "uuid1"), + tuple("uuid5", 2L, "uuid2"), + tuple("uuid6", 3L, "uuid3") + ); + } + + private void assertThatTableContains(Tuple... tuples) { + List> select = db.select("select uuid, group_id, group_uuid from " + TABLE_NAME); + assertThat(select).extracting(m -> m.get("UUID"), m -> m.get("GROUP_ID"), m -> m.get("GROUP_UUID")) + .containsExactlyInAnyOrder(tuples); + } + + private void insertGroup(Long id) { + db.executeInsert("groups", + "id", id, + "uuid", "uuid" + id, + "organization_uuid", "org" + id); + } + + private void insertQProfileEditGroup(Long id, Long groupId) { + db.executeInsert(TABLE_NAME, + "uuid", "uuid" + id, + "group_id", groupId, + "qprofile_uuid", "qprofile_uuid" + id, + "created_at", id + 3); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddPrimaryKeyOnUuidColumnOfIssueChangesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddPrimaryKeyOnUuidColumnOfIssueChangesTableTest.java new file mode 100644 index 00000000000..26c598a28ad --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddPrimaryKeyOnUuidColumnOfIssueChangesTableTest.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.issuechanges; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class AddPrimaryKeyOnUuidColumnOfIssueChangesTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfIssueChangesTableTest.class, "schema.sql"); + + private DdlChange underTest = new AddPrimaryKeyOnUuidColumnOfIssueChangesTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertPrimaryKey("issue_changes", "pk_issue_changes", "uuid"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddUuidColumnToIssueChangesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddUuidColumnToIssueChangesTableTest.java new file mode 100644 index 00000000000..3111075056c --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddUuidColumnToIssueChangesTableTest.java @@ -0,0 +1,65 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.issuechanges; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.UuidFactoryFast; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddUuidColumnToIssueChangesTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToIssueChangesTableTest.class, "schema.sql"); + + private DdlChange underTest = new AddUuidColumnToIssueChangesTable(db.database()); + + private UuidFactoryFast uuidFactory = UuidFactoryFast.getInstance(); + + @Before + public void setup() { + insertIssueChange(1L); + insertIssueChange(2L); + insertIssueChange(3L); + } + + @Test + public void add_uuid_column() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("issue_changes", "uuid", Types.VARCHAR, 40, true); + + assertThat(db.countRowsOfTable("issue_changes")) + .isEqualTo(3); + } + + private void insertIssueChange(Long id) { + db.executeInsert("issue_changes", + "id", id, + "issue_key", uuidFactory.create()); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/DropIdColumnOfIssueChangesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/DropIdColumnOfIssueChangesTableTest.java new file mode 100644 index 00000000000..87f32b9338c --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/DropIdColumnOfIssueChangesTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.issuechanges; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropIdColumnOfIssueChangesTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfIssueChangesTableTest.class, "schema.sql"); + + private DdlChange underTest = new DropIdColumnOfIssueChangesTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("issue_changes", "id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/DropPrimaryKeyOnIdColumnOfIssueChangesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/DropPrimaryKeyOnIdColumnOfIssueChangesTableTest.java new file mode 100644 index 00000000000..f72a917f9f9 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/DropPrimaryKeyOnIdColumnOfIssueChangesTableTest.java @@ -0,0 +1,55 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.sonar.server.platform.db.migration.version.v84.issuechanges; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; +import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropPrimaryKeyOnIdColumnOfIssueChangesTableTest { + + private static final String TABLE_NAME = "issue_changes"; + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfIssueChangesTableTest.class, "schema.sql"); + + private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + + private DropPrimaryKeyOnIdColumnOfIssueChangesTable underTest = new DropPrimaryKeyOnIdColumnOfIssueChangesTable(db.database(), dropPrimaryKeySqlGenerator); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertNoPrimaryKey(TABLE_NAME); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/MakeIssueChangesUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/MakeIssueChangesUuidColumnNotNullableTest.java new file mode 100644 index 00000000000..140028755f2 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/MakeIssueChangesUuidColumnNotNullableTest.java @@ -0,0 +1,42 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.issuechanges; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static java.sql.Types.VARCHAR; + +public class MakeIssueChangesUuidColumnNotNullableTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(MakeIssueChangesUuidColumnNotNullableTest.class, "schema.sql"); + + private MigrationStep underTest = new MakeIssueChangesUuidColumnNotNullable(db.database()); + + @Test + public void uuid_column_is_not_nullable() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("issue_changes", "uuid", VARCHAR, null, false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/PopulateIssueChangesUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/PopulateIssueChangesUuidTest.java new file mode 100644 index 00000000000..f1bc28029d6 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/PopulateIssueChangesUuidTest.java @@ -0,0 +1,80 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.issuechanges; + +import java.sql.SQLException; +import java.util.Objects; +import java.util.stream.Collectors; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.UuidFactory; +import org.sonar.core.util.UuidFactoryFast; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulateIssueChangesUuidTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulateIssueChangesUuidTest.class, "schema.sql"); + + private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); + private DataChange underTest = new PopulateIssueChangesUuid(db.database(), uuidFactory); + + @Test + public void populate_uuids() throws SQLException { + insertIssueChange(1L); + insertIssueChange(2L); + insertIssueChange(3L); + + underTest.execute(); + + verifyUuidsAreNotNull(); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertIssueChange(1L); + insertIssueChange(2L); + insertIssueChange(3L); + + underTest.execute(); + // re-entrant + underTest.execute(); + + verifyUuidsAreNotNull(); + } + + private void verifyUuidsAreNotNull() { + assertThat(db.select("select uuid from issue_changes") + .stream() + .map(row -> row.get("UUID")) + .filter(Objects::isNull) + .collect(Collectors.toList())).isEmpty(); + } + + private void insertIssueChange(Long id) { + db.executeInsert("issue_changes", + "id", id, + "uuid", uuidFactory.create(), + "issue_key", uuidFactory.create()); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issues/AddPrimaryKeyOnKeeColumnOfIssuesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issues/AddPrimaryKeyOnKeeColumnOfIssuesTableTest.java new file mode 100644 index 00000000000..4b3a1acd7a3 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issues/AddPrimaryKeyOnKeeColumnOfIssuesTableTest.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.issues; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class AddPrimaryKeyOnKeeColumnOfIssuesTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnKeeColumnOfIssuesTableTest.class, "schema.sql"); + + private AddPrimaryKeyOnKeeColumnOfIssuesTable underTest = new AddPrimaryKeyOnKeeColumnOfIssuesTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertPrimaryKey("issues", "pk_issues", "kee"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issues/DropIdColumnOfIssuesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issues/DropIdColumnOfIssuesTableTest.java new file mode 100644 index 00000000000..2bc4ddb096a --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issues/DropIdColumnOfIssuesTableTest.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.issues; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropIdColumnOfIssuesTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfIssuesTableTest.class, "schema.sql"); + + private DropIdColumnOfIssuesTable underTest = new DropIdColumnOfIssuesTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("issues", "id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issues/DropPrimaryKeyOnIdColumnOfIssuesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issues/DropPrimaryKeyOnIdColumnOfIssuesTableTest.java new file mode 100644 index 00000000000..19d47da9c77 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/issues/DropPrimaryKeyOnIdColumnOfIssuesTableTest.java @@ -0,0 +1,55 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.sonar.server.platform.db.migration.version.v84.issues; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; +import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropPrimaryKeyOnIdColumnOfIssuesTableTest { + + private static final String TABLE_NAME = "issues"; + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfIssuesTableTest.class, "schema.sql"); + + private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + + private DropPrimaryKeyOnIdColumnOfIssuesTable underTest = new DropPrimaryKeyOnIdColumnOfIssuesTable(db.database(), dropPrimaryKeySqlGenerator); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertNoPrimaryKey(TABLE_NAME); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddPrimaryKeyOnUuidColumnOfManualMeasureTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddPrimaryKeyOnUuidColumnOfManualMeasureTableTest.java new file mode 100644 index 00000000000..a0a58b27e07 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddPrimaryKeyOnUuidColumnOfManualMeasureTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.manualmeasures; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class AddPrimaryKeyOnUuidColumnOfManualMeasureTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfManualMeasureTableTest.class, "schema.sql"); + + private MigrationStep underTest = new AddPrimaryKeyOnUuidColumnOfManualMeasuresTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertPrimaryKey("manual_measures", "pk_manual_measures", "uuid"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddUuidToManualMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddUuidToManualMeasuresTest.java new file mode 100644 index 00000000000..4269d504571 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddUuidToManualMeasuresTest.java @@ -0,0 +1,66 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.manualmeasures; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.UuidFactory; +import org.sonar.core.util.UuidFactoryFast; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddUuidToManualMeasuresTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddUuidToManualMeasuresTest.class, "schema.sql"); + + private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); + + private DdlChange underTest = new AddUuidColumnToManualMeasures(db.database()); + + @Before + public void setup() { + insertManualMeasure(1L); + insertManualMeasure(2L); + insertManualMeasure(3L); + } + + @Test + public void add_uuid_column_to_manual_measures() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("manual_measures", "uuid", Types.VARCHAR, 40, true); + + assertThat(db.countSql("select count(id) from manual_measures")) + .isEqualTo(3); + } + + private void insertManualMeasure(Long id) { + db.executeInsert("manual_measures", + "id", id, + "metric_id", id + 100, + "component_uuid", uuidFactory.create()); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropIdColumnOfManualMeasuresTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropIdColumnOfManualMeasuresTableTest.java new file mode 100644 index 00000000000..340f26802c7 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropIdColumnOfManualMeasuresTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.manualmeasures; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropIdColumnOfManualMeasuresTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfManualMeasuresTableTest.class, "schema.sql"); + + private MigrationStep underTest = new DropIdColumnOfManualMeasuresTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("manual_measures", "id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropPrimaryKeyOnIdColumnOfManualMeasuresTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropPrimaryKeyOnIdColumnOfManualMeasuresTableTest.java new file mode 100644 index 00000000000..556e0cf9062 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropPrimaryKeyOnIdColumnOfManualMeasuresTableTest.java @@ -0,0 +1,56 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.manualmeasures; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; +import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropPrimaryKeyOnIdColumnOfManualMeasuresTableTest { + + private static final String TABLE_NAME = "manual_measures"; + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfManualMeasuresTableTest.class, "schema.sql"); + + private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + + private MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfManualMeasuresTable(db.database(), dropPrimaryKeySqlGenerator); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertNoPrimaryKey(TABLE_NAME); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/MakeManualMeasuresUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/MakeManualMeasuresUuidColumnNotNullableTest.java new file mode 100644 index 00000000000..1651ad26bb4 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/MakeManualMeasuresUuidColumnNotNullableTest.java @@ -0,0 +1,43 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.manualmeasures; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static java.sql.Types.VARCHAR; + +public class MakeManualMeasuresUuidColumnNotNullableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(MakeManualMeasuresUuidColumnNotNullableTest.class, "schema.sql"); + + private MigrationStep underTest = new MakeManualMeasuresUuidColumnNotNullable(db.database()); + + @Test + public void uuid_column_is_not_null() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("manual_measures", "uuid", VARCHAR, null, false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/PopulateManualMeasuresUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/PopulateManualMeasuresUuidTest.java new file mode 100644 index 00000000000..d055c51682a --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/PopulateManualMeasuresUuidTest.java @@ -0,0 +1,81 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.manualmeasures; + +import java.sql.SQLException; +import java.util.Objects; +import java.util.stream.Collectors; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.UuidFactory; +import org.sonar.core.util.UuidFactoryFast; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulateManualMeasuresUuidTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulateManualMeasuresUuidTest.class, "schema.sql"); + + private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); + private DataChange underTest = new PopulateManualMeasureUuid(db.database(), uuidFactory); + + @Test + public void populate_uuids_and_created_at() throws SQLException { + insertManualMeasure(1L); + insertManualMeasure(2L); + insertManualMeasure(3L); + + underTest.execute(); + + verifyUuidsAreNotNull(); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertManualMeasure(1L); + insertManualMeasure(2L); + insertManualMeasure(3L); + + underTest.execute(); + // re-entrant + underTest.execute(); + + verifyUuidsAreNotNull(); + } + + private void verifyUuidsAreNotNull() { + assertThat(db.select("select uuid from manual_measures") + .stream() + .map(row -> row.get("UUID")) + .filter(Objects::isNull) + .collect(Collectors.toList())).isEmpty(); + } + + private void insertManualMeasure(Long id) { + db.executeInsert("manual_measures", + "id", id, + "metric_id", id + 100, + "component_uuid", uuidFactory.create()); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/AddPrimaryKeyOnUuidColumnOfMetricsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/AddPrimaryKeyOnUuidColumnOfMetricsTableTest.java new file mode 100644 index 00000000000..06f189aa980 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/AddPrimaryKeyOnUuidColumnOfMetricsTableTest.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class AddPrimaryKeyOnUuidColumnOfMetricsTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfMetricsTableTest.class, "schema.sql"); + + private DdlChange underTest = new AddPrimaryKeyOnUuidColumnOfMetricsTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertPrimaryKey("metrics", "pk_metrics", "uuid"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/AddUuidColumnToMetricsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/AddUuidColumnToMetricsTableTest.java new file mode 100644 index 00000000000..4be6618d421 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/AddUuidColumnToMetricsTableTest.java @@ -0,0 +1,60 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddUuidColumnToMetricsTableTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToMetricsTableTest.class, "schema.sql"); + private DdlChange underTest = new AddUuidColumnToMetricsTable(db.database()); + + @Before + public void setup() { + insertMetric(1L); + insertMetric(2L); + insertMetric(3L); + } + + @Test + public void add_uuid_column() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("metrics", "uuid", Types.VARCHAR, 40, true); + + assertThat(db.countRowsOfTable("metrics")) + .isEqualTo(3); + } + + private void insertMetric(Long id) { + db.executeInsert("metrics", + "id", id, + "name", "name" + id); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/DropIdColumnOfMetricsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/DropIdColumnOfMetricsTableTest.java new file mode 100644 index 00000000000..4f34ed78daf --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/DropIdColumnOfMetricsTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropIdColumnOfMetricsTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfMetricsTableTest.class, "schema.sql"); + + private DdlChange underTest = new DropIdColumnOfMetricsTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("metrics", "id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/DropPrimaryKeyOnIdColumnOfMetricsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/DropPrimaryKeyOnIdColumnOfMetricsTableTest.java new file mode 100644 index 00000000000..35f85e4cc04 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/DropPrimaryKeyOnIdColumnOfMetricsTableTest.java @@ -0,0 +1,56 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.sonar.server.platform.db.migration.version.v84.metrics; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; +import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropPrimaryKeyOnIdColumnOfMetricsTableTest { + + private static final String TABLE_NAME = "metrics"; + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfMetricsTableTest.class, "schema.sql"); + + private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + + private DdlChange underTest = new DropPrimaryKeyOnIdColumnOfMetricsTable(db.database(), dropPrimaryKeySqlGenerator); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertNoPrimaryKey(TABLE_NAME); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/MakeMetricsUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/MakeMetricsUuidColumnNotNullableTest.java new file mode 100644 index 00000000000..fc3a64da7f6 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/MakeMetricsUuidColumnNotNullableTest.java @@ -0,0 +1,42 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static java.sql.Types.VARCHAR; + +public class MakeMetricsUuidColumnNotNullableTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(MakeMetricsUuidColumnNotNullableTest.class, "schema.sql"); + + private MigrationStep underTest = new MakeMetricsUuidColumnNotNullable(db.database()); + + @Test + public void uuid_column_is_not_nullable() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("metrics", "uuid", VARCHAR, null, false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/PopulateMetricsUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/PopulateMetricsUuidTest.java new file mode 100644 index 00000000000..49d55677a45 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/PopulateMetricsUuidTest.java @@ -0,0 +1,79 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics; + +import java.sql.SQLException; +import java.util.Objects; +import java.util.stream.Collectors; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.UuidFactory; +import org.sonar.core.util.UuidFactoryFast; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulateMetricsUuidTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulateMetricsUuidTest.class, "schema.sql"); + + private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); + private DataChange underTest = new PopulateMetricsUuid(db.database(), uuidFactory); + + @Test + public void populate_uuids() throws SQLException { + insertMetric(1L); + insertMetric(2L); + insertMetric(3L); + + underTest.execute(); + + verifyUuidsAreNotNull(); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertMetric(1L); + insertMetric(2L); + insertMetric(3L); + + underTest.execute(); + // re-entrant + underTest.execute(); + + verifyUuidsAreNotNull(); + } + + private void verifyUuidsAreNotNull() { + assertThat(db.select("select uuid from metrics") + .stream() + .map(row -> row.get("UUID")) + .filter(Objects::isNull) + .collect(Collectors.toList())).isEmpty(); + } + + private void insertMetric(Long id) { + db.executeInsert("metrics", + "id", id, + "name", "name" + id); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddIndexOnMetricUuidOfLiveMeasuresTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddIndexOnMetricUuidOfLiveMeasuresTableTest.java new file mode 100644 index 00000000000..16a582fdc2b --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddIndexOnMetricUuidOfLiveMeasuresTableTest.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics.livemeasures; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +public class AddIndexOnMetricUuidOfLiveMeasuresTableTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddIndexOnMetricUuidOfLiveMeasuresTableTest.class, "schema.sql"); + + private MigrationStep underTest = new AddIndexOnMetricUuidOfLiveMeasuresTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertUniqueIndex("live_measures", "live_measures_component", "component_uuid", "metric_uuid"); + } + + @Test + public void migration_is_re_entrant() throws SQLException { + underTest.execute(); + + // re-entrant + underTest.execute(); + + db.assertUniqueIndex("live_measures", "live_measures_component", "component_uuid", "metric_uuid"); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddMetricUuidColumnToLiveMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddMetricUuidColumnToLiveMeasuresTest.java new file mode 100644 index 00000000000..cf2a3298f11 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddMetricUuidColumnToLiveMeasuresTest.java @@ -0,0 +1,64 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics.livemeasures; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddMetricUuidColumnToLiveMeasuresTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddMetricUuidColumnToLiveMeasuresTest.class, "schema.sql"); + private DdlChange underTest = new AddMetricUuidColumnToLiveMeasures(db.database()); + + @Before + public void setup() { + insertLiveMeasure(1L); + insertLiveMeasure(2L); + insertLiveMeasure(3L); + } + + @Test + public void add_active_rule_uuid_column() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("live_measures", "metric_uuid", Types.VARCHAR, 40, true); + + assertThat(db.countRowsOfTable("live_measures")) + .isEqualTo(3); + } + + private void insertLiveMeasure(Long id) { + db.executeInsert("live_measures", + "uuid", "uuid" + id, + "metric_id", id + 1, + "component_uuid", "component" + id, + "project_uuid", "project" + id + 2, + "created_at", id + 3, + "updated_at", id + 4 + ); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/DropIndexOnMetricIdOfLiveMeasuresTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/DropIndexOnMetricIdOfLiveMeasuresTableTest.java new file mode 100644 index 00000000000..042b2045a80 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/DropIndexOnMetricIdOfLiveMeasuresTableTest.java @@ -0,0 +1,54 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics.livemeasures; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +public class DropIndexOnMetricIdOfLiveMeasuresTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropIndexOnMetricIdOfLiveMeasuresTableTest.class, "schema.sql"); + + private MigrationStep underTest = new DropIndexOnMetricIdOfLiveMeasuresTable(db.database()); + + @Test + public void execute() throws SQLException { + db.assertTableExists("live_measures"); + db.assertUniqueIndex("live_measures", "live_measures_component", "component_uuid", "metric_id"); + + underTest.execute(); + + db.assertIndexDoesNotExist("live_measures", "live_measures_component"); + } + + @Test + public void migration_is_re_entrant() throws SQLException { + underTest.execute(); + + // re-entrant + underTest.execute(); + + db.assertIndexDoesNotExist("live_measures", "live_measures_component"); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/DropMetricIdColumnOfLiveMeasuresTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/DropMetricIdColumnOfLiveMeasuresTableTest.java new file mode 100644 index 00000000000..2991811ff20 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/DropMetricIdColumnOfLiveMeasuresTableTest.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics.livemeasures; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropMetricIdColumnOfLiveMeasuresTableTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropMetricIdColumnOfLiveMeasuresTableTest.class, "schema.sql"); + + private DdlChange underTest = new DropMetricIdColumnOfLiveMeasuresTable(db.database()); + + @Test + public void execute() throws SQLException { + db.assertColumnDefinition("live_measures", "metric_id", Types.INTEGER, null, false); + underTest.execute(); + db.assertColumnDoesNotExist("live_measures", "metric_id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/MakeLiveMeasuresMetricUuidNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/MakeLiveMeasuresMetricUuidNotNullableTest.java new file mode 100644 index 00000000000..136d8375fb0 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/MakeLiveMeasuresMetricUuidNotNullableTest.java @@ -0,0 +1,42 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics.livemeasures; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static java.sql.Types.VARCHAR; + +public class MakeLiveMeasuresMetricUuidNotNullableTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(MakeLiveMeasuresMetricUuidNotNullableTest.class, "schema.sql"); + + private MigrationStep underTest = new MakeLiveMeasuresMetricUuidNotNullable(db.database()); + + @Test + public void uuid_column_is_not_null() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("live_measures", "metric_uuid", VARCHAR, null, false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/PopulateLiveMeasuresMetricUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/PopulateLiveMeasuresMetricUuidTest.java new file mode 100644 index 00000000000..656b67ccbfc --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/PopulateLiveMeasuresMetricUuidTest.java @@ -0,0 +1,102 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics.livemeasures; + +import java.sql.SQLException; +import java.util.List; +import java.util.Map; +import org.assertj.core.groups.Tuple; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.tuple; + +public class PopulateLiveMeasuresMetricUuidTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulateLiveMeasuresMetricUuidTest.class, "schema.sql"); + + private DataChange underTest = new PopulateLiveMeasuresMetricUuid(db.database()); + + @Test + public void populate_uuids() throws SQLException { + insertMetric(1L); + insertMetric(2L); + insertMetric(3L); + + insertLiveMeasure(4L, 1L); + insertLiveMeasure(5L, 2L); + insertLiveMeasure(6L, 3L); + + underTest.execute(); + + assertThatTableContains( + tuple("uuid4", 1L, "uuid1"), + tuple("uuid5", 2L, "uuid2"), + tuple("uuid6", 3L, "uuid3") + ); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertMetric(1L); + insertMetric(2L); + insertMetric(3L); + + insertLiveMeasure(4L, 1L); + insertLiveMeasure(5L, 2L); + insertLiveMeasure(6L, 3L); + + underTest.execute(); + // re-entrant + underTest.execute(); + + assertThatTableContains( + tuple("uuid4", 1L, "uuid1"), + tuple("uuid5", 2L, "uuid2"), + tuple("uuid6", 3L, "uuid3") + ); + } + + private void assertThatTableContains(Tuple... tuples) { + List> select = db.select("select uuid, metric_id, metric_uuid from live_measures"); + assertThat(select).extracting(m -> m.get("UUID"), m -> m.get("METRIC_ID"), m -> m.get("METRIC_UUID")) + .containsExactlyInAnyOrder(tuples); + } + + private void insertMetric(Long id) { + db.executeInsert("metrics", + "id", id, + "uuid", "uuid" + id, + "name", "name" + id); + } + + private void insertLiveMeasure(Long id, Long metricId) { + db.executeInsert("live_measures", + "uuid", "uuid" + id, + "metric_id", metricId, + "component_uuid", "component" + id, + "project_uuid", "project" + id + 2, + "created_at", id + 3, + "updated_at", id + 4); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/AddMetricUuidColumnToManualMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/AddMetricUuidColumnToManualMeasuresTest.java new file mode 100644 index 00000000000..1208ffde6ca --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/AddMetricUuidColumnToManualMeasuresTest.java @@ -0,0 +1,60 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics.manualmeasures; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddMetricUuidColumnToManualMeasuresTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddMetricUuidColumnToManualMeasuresTest.class, "schema.sql"); + private DdlChange underTest = new AddMetricUuidColumnToManualMeasures(db.database()); + + @Before + public void setup() { + insertManualMeasure(1L); + insertManualMeasure(2L); + insertManualMeasure(3L); + } + + @Test + public void add_active_rule_uuid_column() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("manual_measures", "metric_uuid", Types.VARCHAR, 40, true); + + assertThat(db.countRowsOfTable("manual_measures")) + .isEqualTo(3); + } + + private void insertManualMeasure(Long id) { + db.executeInsert("manual_measures", + "uuid", "uuid" + id, + "metric_id", id + 1, + "component_uuid", "component" + id); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/DropMetricIdColumnOfManualMeasuresTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/DropMetricIdColumnOfManualMeasuresTableTest.java new file mode 100644 index 00000000000..48f90ee0514 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/DropMetricIdColumnOfManualMeasuresTableTest.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics.manualmeasures; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropMetricIdColumnOfManualMeasuresTableTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropMetricIdColumnOfManualMeasuresTableTest.class, "schema.sql"); + + private DdlChange underTest = new DropMetricIdColumnOfManualMeasuresTable(db.database()); + + @Test + public void execute() throws SQLException { + db.assertColumnDefinition("manual_measures", "metric_id", Types.INTEGER, null, false); + underTest.execute(); + db.assertColumnDoesNotExist("manual_measures", "metric_id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/MakeManualMeasuresMetricUuidNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/MakeManualMeasuresMetricUuidNotNullableTest.java new file mode 100644 index 00000000000..2c7ddc202d0 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/MakeManualMeasuresMetricUuidNotNullableTest.java @@ -0,0 +1,42 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics.manualmeasures; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static java.sql.Types.VARCHAR; + +public class MakeManualMeasuresMetricUuidNotNullableTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(MakeManualMeasuresMetricUuidNotNullableTest.class, "schema.sql"); + + private MigrationStep underTest = new MakeManualMeasuresMetricUuidNotNullable(db.database()); + + @Test + public void uuid_column_is_not_null() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("manual_measures", "metric_uuid", VARCHAR, null, false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/PopulateManualMeasuresMetricUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/PopulateManualMeasuresMetricUuidTest.java new file mode 100644 index 00000000000..f523ab24e6b --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/PopulateManualMeasuresMetricUuidTest.java @@ -0,0 +1,99 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics.manualmeasures; + +import java.sql.SQLException; +import java.util.List; +import java.util.Map; +import org.assertj.core.groups.Tuple; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.tuple; + +public class PopulateManualMeasuresMetricUuidTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulateManualMeasuresMetricUuidTest.class, "schema.sql"); + + private DataChange underTest = new PopulateManualMeasuresMetricUuid(db.database()); + + @Test + public void populate_uuids() throws SQLException { + insertMetric(1L); + insertMetric(2L); + insertMetric(3L); + + insertManualMeasure(4L, 1L); + insertManualMeasure(5L, 2L); + insertManualMeasure(6L, 3L); + + underTest.execute(); + + assertThatTableContains( + tuple("uuid4", 1L, "uuid1"), + tuple("uuid5", 2L, "uuid2"), + tuple("uuid6", 3L, "uuid3") + ); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertMetric(1L); + insertMetric(2L); + insertMetric(3L); + + insertManualMeasure(4L, 1L); + insertManualMeasure(5L, 2L); + insertManualMeasure(6L, 3L); + + underTest.execute(); + // re-entrant + underTest.execute(); + + assertThatTableContains( + tuple("uuid4", 1L, "uuid1"), + tuple("uuid5", 2L, "uuid2"), + tuple("uuid6", 3L, "uuid3") + ); + } + + private void assertThatTableContains(Tuple... tuples) { + List> select = db.select("select uuid, metric_id, metric_uuid from manual_measures"); + assertThat(select).extracting(m -> m.get("UUID"), m -> m.get("METRIC_ID"), m -> m.get("METRIC_UUID")) + .containsExactlyInAnyOrder(tuples); + } + + private void insertMetric(Long id) { + db.executeInsert("metrics", + "id", id, + "uuid", "uuid" + id, + "name", "name" + id); + } + + private void insertManualMeasure(Long id, Long metricId) { + db.executeInsert("manual_measures", + "uuid", "uuid" + id, + "metric_id", metricId, + "component_uuid", "component" + id); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddIndexOnMetricUuidOfProjectMeasuresTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddIndexOnMetricUuidOfProjectMeasuresTableTest.java new file mode 100644 index 00000000000..b4de2ba0979 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddIndexOnMetricUuidOfProjectMeasuresTableTest.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics.projectmeasures; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +public class AddIndexOnMetricUuidOfProjectMeasuresTableTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddIndexOnMetricUuidOfProjectMeasuresTableTest.class, "schema.sql"); + + private MigrationStep underTest = new AddIndexOnMetricUuidOfProjectMeasuresTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertIndex("project_measures", "measures_analysis_metric", "analysis_uuid", "metric_uuid"); + } + + @Test + public void migration_is_re_entrant() throws SQLException { + underTest.execute(); + + // re-entrant + underTest.execute(); + + db.assertIndex("project_measures", "measures_analysis_metric", "analysis_uuid", "metric_uuid"); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddMetricUuidColumnToProjectMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddMetricUuidColumnToProjectMeasuresTest.java new file mode 100644 index 00000000000..8e2435ad9db --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddMetricUuidColumnToProjectMeasuresTest.java @@ -0,0 +1,61 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics.projectmeasures; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddMetricUuidColumnToProjectMeasuresTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddMetricUuidColumnToProjectMeasuresTest.class, "schema.sql"); + private DdlChange underTest = new AddMetricUuidColumnToProjectMeasures(db.database()); + + @Before + public void setup() { + insertProjectMeasure(1L); + insertProjectMeasure(2L); + insertProjectMeasure(3L); + } + + @Test + public void add_active_rule_uuid_column() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("project_measures", "metric_uuid", Types.VARCHAR, 40, true); + + assertThat(db.countRowsOfTable("project_measures")) + .isEqualTo(3); + } + + private void insertProjectMeasure(Long id) { + db.executeInsert("project_measures", + "uuid", "uuid" + id, + "metric_id", id + 1, + "component_uuid", "component" + id, + "analysis_uuid", "analysis" + id + 1); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DropIndexOnMetricIdOfProjectMeasuresTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DropIndexOnMetricIdOfProjectMeasuresTableTest.java new file mode 100644 index 00000000000..77986e74976 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DropIndexOnMetricIdOfProjectMeasuresTableTest.java @@ -0,0 +1,54 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics.projectmeasures; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +public class DropIndexOnMetricIdOfProjectMeasuresTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropIndexOnMetricIdOfProjectMeasuresTableTest.class, "schema.sql"); + + private MigrationStep underTest = new DropIndexOnMetricIdOfProjectMeasuresTable(db.database()); + + @Test + public void execute() throws SQLException { + db.assertTableExists("project_measures"); + db.assertIndex("project_measures", "measures_analysis_metric", "analysis_uuid", "metric_id"); + + underTest.execute(); + + db.assertIndexDoesNotExist("project_measures", "measures_analysis_metric"); + } + + @Test + public void migration_is_re_entrant() throws SQLException { + underTest.execute(); + + // re-entrant + underTest.execute(); + + db.assertIndexDoesNotExist("project_measures", "measures_analysis_metric"); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DropMetricIdColumnOfProjectMeasuresTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DropMetricIdColumnOfProjectMeasuresTableTest.java new file mode 100644 index 00000000000..a934bc8d023 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DropMetricIdColumnOfProjectMeasuresTableTest.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics.projectmeasures; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropMetricIdColumnOfProjectMeasuresTableTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropMetricIdColumnOfProjectMeasuresTableTest.class, "schema.sql"); + + private DdlChange underTest = new DropMetricIdColumnOfProjectMeasuresTable(db.database()); + + @Test + public void execute() throws SQLException { + db.assertColumnDefinition("project_measures", "metric_id", Types.INTEGER, null, false); + underTest.execute(); + db.assertColumnDoesNotExist("project_measures", "metric_id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/MakeProjectMeasuresMetricUuidNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/MakeProjectMeasuresMetricUuidNotNullableTest.java new file mode 100644 index 00000000000..13cbf77716f --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/MakeProjectMeasuresMetricUuidNotNullableTest.java @@ -0,0 +1,42 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics.projectmeasures; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static java.sql.Types.VARCHAR; + +public class MakeProjectMeasuresMetricUuidNotNullableTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(MakeProjectMeasuresMetricUuidNotNullableTest.class, "schema.sql"); + + private MigrationStep underTest = new MakeProjectMeasuresMetricUuidNotNullable(db.database()); + + @Test + public void uuid_column_is_not_null() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("project_measures", "metric_uuid", VARCHAR, null, false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/PopulateProjectMeasuresMetricUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/PopulateProjectMeasuresMetricUuidTest.java new file mode 100644 index 00000000000..0f8ed302bc4 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/PopulateProjectMeasuresMetricUuidTest.java @@ -0,0 +1,100 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics.projectmeasures; + +import java.sql.SQLException; +import java.util.List; +import java.util.Map; +import org.assertj.core.groups.Tuple; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.tuple; + +public class PopulateProjectMeasuresMetricUuidTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulateProjectMeasuresMetricUuidTest.class, "schema.sql"); + + private DataChange underTest = new PopulateProjectMeasuresMetricUuid(db.database()); + + @Test + public void populate_uuids() throws SQLException { + insertMetric(1L); + insertMetric(2L); + insertMetric(3L); + + insertProjectMeasure(4L, 1L); + insertProjectMeasure(5L, 2L); + insertProjectMeasure(6L, 3L); + + underTest.execute(); + + assertThatTableContains( + tuple("uuid4", 1L, "uuid1"), + tuple("uuid5", 2L, "uuid2"), + tuple("uuid6", 3L, "uuid3") + ); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertMetric(1L); + insertMetric(2L); + insertMetric(3L); + + insertProjectMeasure(4L, 1L); + insertProjectMeasure(5L, 2L); + insertProjectMeasure(6L, 3L); + + underTest.execute(); + // re-entrant + underTest.execute(); + + assertThatTableContains( + tuple("uuid4", 1L, "uuid1"), + tuple("uuid5", 2L, "uuid2"), + tuple("uuid6", 3L, "uuid3") + ); + } + + private void assertThatTableContains(Tuple... tuples) { + List> select = db.select("select uuid, metric_id, metric_uuid from project_measures"); + assertThat(select).extracting(m -> m.get("UUID"), m -> m.get("METRIC_ID"), m -> m.get("METRIC_UUID")) + .containsExactlyInAnyOrder(tuples); + } + + private void insertMetric(Long id) { + db.executeInsert("metrics", + "id", id, + "uuid", "uuid" + id, + "name", "name" + id); + } + + private void insertProjectMeasure(Long id, Long metricId) { + db.executeInsert("project_measures", + "uuid", "uuid" + id, + "metric_id", metricId, + "component_uuid", "component" + id, + "analysis_uuid", "analysis" + id + 1); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/AddMetricUuidColumnToQualityGateConditionsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/AddMetricUuidColumnToQualityGateConditionsTest.java new file mode 100644 index 00000000000..4c4d31be075 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/AddMetricUuidColumnToQualityGateConditionsTest.java @@ -0,0 +1,59 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics.qualitygateconditions; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddMetricUuidColumnToQualityGateConditionsTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddMetricUuidColumnToQualityGateConditionsTest.class, "schema.sql"); + private DdlChange underTest = new AddMetricUuidColumnToQualityGateConditions(db.database()); + + @Before + public void setup() { + insertQualityGateConditions(1L); + insertQualityGateConditions(2L); + insertQualityGateConditions(3L); + } + + @Test + public void add_active_rule_uuid_column() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("quality_gate_conditions", "metric_uuid", Types.VARCHAR, 40, true); + + assertThat(db.countRowsOfTable("quality_gate_conditions")) + .isEqualTo(3); + } + + private void insertQualityGateConditions(Long id) { + db.executeInsert("quality_gate_conditions", + "uuid", "uuid" + id, + "metric_id", id + 1); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/DropMetricIdColumnOfQualityGateConditionsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/DropMetricIdColumnOfQualityGateConditionsTableTest.java new file mode 100644 index 00000000000..689194b3cdb --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/DropMetricIdColumnOfQualityGateConditionsTableTest.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics.qualitygateconditions; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropMetricIdColumnOfQualityGateConditionsTableTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropMetricIdColumnOfQualityGateConditionsTableTest.class, "schema.sql"); + + private DdlChange underTest = new DropMetricIdColumnOfQualityGateConditionsTable(db.database()); + + @Test + public void execute() throws SQLException { + db.assertColumnDefinition("quality_gate_conditions", "metric_id", Types.INTEGER, null, true); + underTest.execute(); + db.assertColumnDoesNotExist("quality_gate_conditions", "metric_id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/MakeQualityGateConditionsMetricUuidNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/MakeQualityGateConditionsMetricUuidNotNullableTest.java new file mode 100644 index 00000000000..8efcf46432a --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/MakeQualityGateConditionsMetricUuidNotNullableTest.java @@ -0,0 +1,42 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics.qualitygateconditions; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static java.sql.Types.VARCHAR; + +public class MakeQualityGateConditionsMetricUuidNotNullableTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(MakeQualityGateConditionsMetricUuidNotNullableTest.class, "schema.sql"); + + private MigrationStep underTest = new MakeQualityGateConditionsMetricUuidNotNullable(db.database()); + + @Test + public void uuid_column_is_not_null() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("quality_gate_conditions", "metric_uuid", VARCHAR, null, false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/PopulateQualityGateConditionsMetricUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/PopulateQualityGateConditionsMetricUuidTest.java new file mode 100644 index 00000000000..be80fcac2e7 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/PopulateQualityGateConditionsMetricUuidTest.java @@ -0,0 +1,118 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.metrics.qualitygateconditions; + +import java.sql.SQLException; +import java.util.List; +import java.util.Map; +import org.assertj.core.groups.Tuple; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.tuple; + +public class PopulateQualityGateConditionsMetricUuidTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulateQualityGateConditionsMetricUuidTest.class, "schema.sql"); + + private DataChange underTest = new PopulateQualityGateConditionsMetricUuid(db.database()); + + @Test + public void populate_uuids() throws SQLException { + insertMetric(1L); + insertMetric(2L); + insertMetric(3L); + + insertQualityGateConditions(4L, 1L); + insertQualityGateConditions(5L, 2L); + insertQualityGateConditions(6L, 3L); + + underTest.execute(); + + assertThatTableContains( + tuple("uuid4", 1L, "uuid1"), + tuple("uuid5", 2L, "uuid2"), + tuple("uuid6", 3L, "uuid3") + ); + } + + @Test + public void delete_entries_with_null_id() throws SQLException { + insertMetric(1L); + insertMetric(2L); + insertMetric(3L); + + insertQualityGateConditions(4L, null); + insertQualityGateConditions(5L, 2L); + insertQualityGateConditions(6L, 3L); + + underTest.execute(); + // re-entrant + underTest.execute(); + + assertThatTableContains( + tuple("uuid5", 2L, "uuid2"), + tuple("uuid6", 3L, "uuid3") + ); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertMetric(1L); + insertMetric(2L); + insertMetric(3L); + + insertQualityGateConditions(4L, 1L); + insertQualityGateConditions(5L, 2L); + insertQualityGateConditions(6L, 3L); + + underTest.execute(); + // re-entrant + underTest.execute(); + + assertThatTableContains( + tuple("uuid4", 1L, "uuid1"), + tuple("uuid5", 2L, "uuid2"), + tuple("uuid6", 3L, "uuid3") + ); + } + + private void assertThatTableContains(Tuple... tuples) { + List> select = db.select("select uuid, metric_id, metric_uuid from quality_gate_conditions"); + assertThat(select).extracting(m -> m.get("UUID"), m -> m.get("METRIC_ID"), m -> m.get("METRIC_UUID")) + .containsExactlyInAnyOrder(tuples); + } + + private void insertMetric(Long id) { + db.executeInsert("metrics", + "id", id, + "uuid", "uuid" + id, + "name", "name" + id); + } + + private void insertQualityGateConditions(Long id, Long metricId) { + db.executeInsert("quality_gate_conditions", + "uuid", "uuid" + id, + "metric_id", metricId); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/AddPrimaryKeyOnUuidColumnOfNotificationTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/AddPrimaryKeyOnUuidColumnOfNotificationTableTest.java new file mode 100644 index 00000000000..e88e9b4cbfa --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/AddPrimaryKeyOnUuidColumnOfNotificationTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.notifications; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class AddPrimaryKeyOnUuidColumnOfNotificationTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfNotificationTableTest.class, "schema.sql"); + + private MigrationStep underTest = new AddPrimaryKeyOnUuidColumnOfNotificationTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertPrimaryKey("notifications", "pk_notifications", "uuid"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/AddUuidAndCreatedAtColumnsToNotificationTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/AddUuidAndCreatedAtColumnsToNotificationTest.java new file mode 100644 index 00000000000..02cce0cf85e --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/AddUuidAndCreatedAtColumnsToNotificationTest.java @@ -0,0 +1,83 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.notifications; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectOutputStream; +import java.sql.SQLException; +import java.sql.Types; +import org.apache.commons.io.IOUtils; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.api.utils.SonarException; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static java.sql.Types.BIGINT; +import static org.assertj.core.api.Assertions.assertThat; + +public class AddUuidAndCreatedAtColumnsToNotificationTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddUuidAndCreatedAtColumnsToNotificationTest.class, "schema.sql"); + + private DdlChange underTest = new AddUuidAndCreatedAtColumnsToNotification(db.database()); + + @Before + public void setup() { + insertNotification(1L, "data1"); + insertNotification(2L, "data2"); + insertNotification(3L, "data3"); + } + + @Test + public void add_uuid_and_created_at_columns_to_notification() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("notifications", "uuid", Types.VARCHAR, 40, true); + db.assertColumnDefinition("notifications", "created_at", BIGINT, null, true); + + assertThat(db.countSql("select count(id) from notifications")) + .isEqualTo(3); + } + + private void insertNotification(Long id, String data) { + + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + try { + ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream); + objectOutputStream.writeObject(data); + objectOutputStream.close(); + byte[] byteArray = byteArrayOutputStream.toByteArray(); + + db.executeInsert("notifications", + "id", id, + "data", byteArray); + + } catch (IOException e) { + throw new SonarException("Unable to write notification", e); + + } finally { + IOUtils.closeQuietly(byteArrayOutputStream); + } + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/DropIdColumnOfNotificationTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/DropIdColumnOfNotificationTableTest.java new file mode 100644 index 00000000000..b0690e25faf --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/DropIdColumnOfNotificationTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.notifications; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropIdColumnOfNotificationTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfNotificationTableTest.class, "schema.sql"); + + private MigrationStep underTest = new DropIdColumnOfNotificationTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("notifications", "id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/DropPrimaryKeyOnIdColumnOfNotificationTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/DropPrimaryKeyOnIdColumnOfNotificationTableTest.java new file mode 100644 index 00000000000..c0f1931c4db --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/DropPrimaryKeyOnIdColumnOfNotificationTableTest.java @@ -0,0 +1,56 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.notifications; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; +import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropPrimaryKeyOnIdColumnOfNotificationTableTest { + + private static final String TABLE_NAME = "notifications"; + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfNotificationTableTest.class, "schema.sql"); + + private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + + private MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfNotificationTable(db.database(), dropPrimaryKeySqlGenerator); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertNoPrimaryKey(TABLE_NAME); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/MakeNotificationUuidAndCreatedAtColumnsNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/MakeNotificationUuidAndCreatedAtColumnsNotNullableTest.java new file mode 100644 index 00000000000..57a01aaae49 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/MakeNotificationUuidAndCreatedAtColumnsNotNullableTest.java @@ -0,0 +1,45 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.notifications; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static java.sql.Types.BIGINT; +import static java.sql.Types.VARCHAR; + +public class MakeNotificationUuidAndCreatedAtColumnsNotNullableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(MakeNotificationUuidAndCreatedAtColumnsNotNullableTest.class, "schema.sql"); + + private MigrationStep underTest = new MakeNotificationUuidAndCreatedAtColumnsNotNullable(db.database()); + + @Test + public void created_at_and_uuid_columns_are_not_null() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("notifications", "uuid", VARCHAR, null, false); + db.assertColumnDefinition("notifications", "created_at", BIGINT, null, false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/PopulateNotificationUuidAndCreatedAtTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/PopulateNotificationUuidAndCreatedAtTest.java new file mode 100644 index 00000000000..391fc9ba5f5 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/PopulateNotificationUuidAndCreatedAtTest.java @@ -0,0 +1,110 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.notifications; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectOutputStream; +import java.sql.SQLException; +import java.util.Objects; +import java.util.stream.Collectors; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.api.utils.System2; +import org.sonar.core.util.UuidFactory; +import org.sonar.core.util.UuidFactoryFast; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class PopulateNotificationUuidAndCreatedAtTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulateNotificationUuidAndCreatedAtTest.class, "schema.sql"); + + private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); + private System2 system2 = mock(System2.class); + private DataChange underTest = new PopulateNotificationUuidAndCreatedAt(db.database(), uuidFactory, system2); + + @Before + public void before() { + // exactly one week before now + 1ms, so that ID are exactly equals to timestamp in the tests + when(system2.now()).thenReturn((1000 * 60 * 60 * 24 * 7) + 1L); + } + + @Test + public void populate_uuids_and_created_at() throws IOException, SQLException { + insertNotification(1L, "data1"); + insertNotification(2L, "data2"); + insertNotification(3L, "data3"); + + underTest.execute(); + + verifyUuidsAreNotNull(); + verifyCreatedAt(); + } + + @Test + public void migration_is_reentrant() throws IOException, SQLException { + insertNotification(1L, "data1"); + insertNotification(2L, "data2"); + insertNotification(3L, "data3"); + + underTest.execute(); + // re-entrant + underTest.execute(); + + verifyUuidsAreNotNull(); + verifyCreatedAt(); + } + + private void verifyUuidsAreNotNull() { + assertThat(db.select("select uuid from notifications") + .stream() + .map(row -> row.get("UUID")) + .filter(Objects::isNull) + .collect(Collectors.toList())).isEmpty(); + } + + private void verifyCreatedAt() { + assertThat(db.select("select id, created_at from notifications") + .stream() + .filter(row -> !row.get("CREATED_AT").equals(row.get("ID"))) + .collect(Collectors.toList())).isEmpty(); + + } + + private void insertNotification(Long id, String data) throws IOException { + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream); + objectOutputStream.writeObject(data); + objectOutputStream.close(); + byte[] byteArray = byteArrayOutputStream.toByteArray(); + + db.executeInsert("notifications", + "id", id, + "data", byteArray); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTableTest.java new file mode 100644 index 00000000000..6dfac8cc82c --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permissiontemplates; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTableTest.class, "schema.sql"); + + private MigrationStep underTest = new AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertPrimaryKey("permission_templates", "pk_permission_templates", "uuid"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddUuidColumnToPermissionTemplatesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddUuidColumnToPermissionTemplatesTest.java new file mode 100644 index 00000000000..218b97c3b03 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddUuidColumnToPermissionTemplatesTest.java @@ -0,0 +1,67 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permissiontemplates; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.UuidFactory; +import org.sonar.core.util.UuidFactoryFast; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddUuidColumnToPermissionTemplatesTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToPermissionTemplatesTest.class, "schema.sql"); + + private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); + + private DdlChange underTest = new AddUuidColumnToPermissionTemplates(db.database()); + + @Before + public void setup() { + insertPermissionTemplate(1L); + insertPermissionTemplate(2L); + insertPermissionTemplate(3L); + } + + @Test + public void add_uuid_column_to_permission_templates() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("permission_templates", "uuid", Types.VARCHAR, 40, true); + + assertThat(db.countSql("select count(id) from permission_templates")) + .isEqualTo(3); + } + + private void insertPermissionTemplate(Long id) { + db.executeInsert("permission_templates", + "id", id, + "organization_uuid", id + 100, + "name", uuidFactory.create(), + "kee", uuidFactory.create()); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropIdColumnOfPermissionTemplatesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropIdColumnOfPermissionTemplatesTableTest.java new file mode 100644 index 00000000000..e95a637bb42 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropIdColumnOfPermissionTemplatesTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permissiontemplates; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropIdColumnOfPermissionTemplatesTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfPermissionTemplatesTableTest.class, "schema.sql"); + + private MigrationStep underTest = new DropIdColumnOfPermissionTemplatesTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("permission_templates", "id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropKeeColumnOfPermissionTemplatesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropKeeColumnOfPermissionTemplatesTableTest.java new file mode 100644 index 00000000000..42762428315 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropKeeColumnOfPermissionTemplatesTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permissiontemplates; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropKeeColumnOfPermissionTemplatesTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropKeeColumnOfPermissionTemplatesTableTest.class, "schema.sql"); + + private MigrationStep underTest = new DropKeeColumnOfPermissionTemplatesTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("permission_templates", "kee"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropPrimaryKeyOnIdColumnOfPermissionTemplatesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropPrimaryKeyOnIdColumnOfPermissionTemplatesTableTest.java new file mode 100644 index 00000000000..2a95ef1e95f --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropPrimaryKeyOnIdColumnOfPermissionTemplatesTableTest.java @@ -0,0 +1,56 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permissiontemplates; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; +import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropPrimaryKeyOnIdColumnOfPermissionTemplatesTableTest { + + private static final String TABLE_NAME = "permission_templates"; + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfPermissionTemplatesTableTest.class, "schema.sql"); + + private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + + private MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfPermissionTemplatesTable(db.database(), dropPrimaryKeySqlGenerator); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertNoPrimaryKey(TABLE_NAME); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/MakePermissionTemplateUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/MakePermissionTemplateUuidColumnNotNullableTest.java new file mode 100644 index 00000000000..34b1fec5563 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/MakePermissionTemplateUuidColumnNotNullableTest.java @@ -0,0 +1,43 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permissiontemplates; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static java.sql.Types.VARCHAR; + +public class MakePermissionTemplateUuidColumnNotNullableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(MakePermissionTemplateUuidColumnNotNullableTest.class, "schema.sql"); + + private MigrationStep underTest = new MakePermissionTemplateUuidColumnNotNullable(db.database()); + + @Test + public void uuid_column_is_not_null() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("permission_templates", "uuid", VARCHAR, null, false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/PopulatePermissionTemplatesUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/PopulatePermissionTemplatesUuidTest.java new file mode 100644 index 00000000000..ade750c9c61 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/PopulatePermissionTemplatesUuidTest.java @@ -0,0 +1,87 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permissiontemplates; + +import java.sql.SQLException; +import java.util.Objects; +import java.util.stream.Collectors; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.UuidFactory; +import org.sonar.core.util.UuidFactoryFast; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulatePermissionTemplatesUuidTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulatePermissionTemplatesUuidTest.class, "schema.sql"); + + private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); + private DataChange underTest = new PopulatePermissionTemplatesUuid(db.database(), uuidFactory); + + @Test + public void populate_uuids() throws SQLException { + insertPermissionTemplate(1L); + insertPermissionTemplate(2L); + insertPermissionTemplate(3L); + insertPermissionTemplate(4L, "very_very_very_very_very_very_very_very_very_very_very_long_kee"); + + underTest.execute(); + + verifyUuidsAreNotNull(); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertPermissionTemplate(1L); + insertPermissionTemplate(2L); + insertPermissionTemplate(3L); + + underTest.execute(); + // re-entrant + underTest.execute(); + + verifyUuidsAreNotNull(); + } + + private void verifyUuidsAreNotNull() { + assertThat(db.select("select uuid from permission_templates") + .stream() + .map(row -> row.get("UUID")) + .filter(Objects::isNull) + .collect(Collectors.toList())).isEmpty(); + } + + private void insertPermissionTemplate(Long id) { + insertPermissionTemplate(id, uuidFactory.create()); + } + + private void insertPermissionTemplate(Long id, String kee) { + db.executeInsert("permission_templates", + "id", id, + "organization_uuid", id + 100, + "name", uuidFactory.create(), + "kee", kee); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/AddTemplateUuidColumnToPermTemplatesGroupsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/AddTemplateUuidColumnToPermTemplatesGroupsTest.java new file mode 100644 index 00000000000..0768af987ff --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/AddTemplateUuidColumnToPermTemplatesGroupsTest.java @@ -0,0 +1,66 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesgroups; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.UuidFactory; +import org.sonar.core.util.UuidFactoryFast; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddTemplateUuidColumnToPermTemplatesGroupsTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddTemplateUuidColumnToPermTemplatesGroupsTest.class, "schema.sql"); + + private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); + + private DdlChange underTest = new AddTemplateUuidColumnToPermTemplatesGroups(db.database()); + + @Before + public void setup() { + insertPermissionTemplateGroup("1", 4L); + insertPermissionTemplateGroup("2", 5L); + insertPermissionTemplateGroup("3", 6L); + } + + @Test + public void add_uuid_column_to_permission_templates() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("perm_templates_groups", "template_uuid", Types.VARCHAR, 40, true); + + assertThat(db.countRowsOfTable("perm_templates_groups")) + .isEqualTo(3); + } + + private void insertPermissionTemplateGroup(String uuid, Long templateId) { + db.executeInsert("perm_templates_groups", + "uuid", uuid, + "template_id", templateId, + "permission_reference", uuidFactory.create()); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/DropTemplateIdColumnOfPermTemplatesGroupsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/DropTemplateIdColumnOfPermTemplatesGroupsTableTest.java new file mode 100644 index 00000000000..e7293a6a553 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/DropTemplateIdColumnOfPermTemplatesGroupsTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesgroups; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropTemplateIdColumnOfPermTemplatesGroupsTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropTemplateIdColumnOfPermTemplatesGroupsTableTest.class, "schema.sql"); + + private MigrationStep underTest = new DropTemplateIdColumnOfPermTemplatesGroupsTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("perm_templates_groups", "template_id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/MakePermTemplatesGroupsTemplateUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/MakePermTemplatesGroupsTemplateUuidColumnNotNullableTest.java new file mode 100644 index 00000000000..9d21ceaeb6e --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/MakePermTemplatesGroupsTemplateUuidColumnNotNullableTest.java @@ -0,0 +1,43 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesgroups; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static java.sql.Types.VARCHAR; + +public class MakePermTemplatesGroupsTemplateUuidColumnNotNullableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(MakePermTemplatesGroupsTemplateUuidColumnNotNullableTest.class, "schema.sql"); + + private MigrationStep underTest = new MakePermTemplatesGroupsTemplateUuidColumnNotNullable(db.database()); + + @Test + public void uuid_column_is_not_null() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("perm_templates_groups", "template_uuid", VARCHAR, null, false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/PopulatePermTemplatesGroupsTemplateUuidColumnTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/PopulatePermTemplatesGroupsTemplateUuidColumnTest.java new file mode 100644 index 00000000000..09bf1bae262 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/PopulatePermTemplatesGroupsTemplateUuidColumnTest.java @@ -0,0 +1,116 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesgroups; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.UuidFactory; +import org.sonar.core.util.UuidFactoryFast; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulatePermTemplatesGroupsTemplateUuidColumnTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulatePermTemplatesGroupsTemplateUuidColumnTest.class, "schema.sql"); + + private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); + private DataChange underTest = new PopulatePermTemplatesGroupsTemplateUuidColumn(db.database()); + + @Test + public void populate_uuids() throws SQLException { + long permissionTemplateId_1 = 1L; + String permissionTemplateUuid_1 = "uuid-1"; + insertPermissionTemplate(permissionTemplateId_1, permissionTemplateUuid_1); + + long permissionTemplateId_2 = 2L; + String permissionTemplateUuid_2 = "uuid-2"; + insertPermissionTemplate(permissionTemplateId_2, permissionTemplateUuid_2); + + long permissionTemplateId_3 = 3L; + String permissionTemplateUuid_3 = "uuid-3"; + insertPermissionTemplate(permissionTemplateId_3, permissionTemplateUuid_3); + + insertPermissionTemplateGroup("4", permissionTemplateId_1); + insertPermissionTemplateGroup("5", permissionTemplateId_2); + insertPermissionTemplateGroup("6", permissionTemplateId_3); + + underTest.execute(); + + assertThatPermissionTemplateGroupTemplateUuidIsEqualTo("4", permissionTemplateUuid_1); + assertThatPermissionTemplateGroupTemplateUuidIsEqualTo("5", permissionTemplateUuid_2); + assertThatPermissionTemplateGroupTemplateUuidIsEqualTo("6", permissionTemplateUuid_3); + } + + @Test + public void migration_is_reentrant() throws SQLException { + long permissionTemplateId_1 = 1L; + String permissionTemplateUuid_1 = "uuid-1"; + insertPermissionTemplate(permissionTemplateId_1, permissionTemplateUuid_1); + + long permissionTemplateId_2 = 2L; + String permissionTemplateUuid_2 = "uuid-2"; + insertPermissionTemplate(permissionTemplateId_2, permissionTemplateUuid_2); + + long permissionTemplateId_3 = 3L; + String permissionTemplateUuid_3 = "uuid-3"; + insertPermissionTemplate(permissionTemplateId_3, permissionTemplateUuid_3); + + insertPermissionTemplateGroup("4", permissionTemplateId_1); + insertPermissionTemplateGroup("5", permissionTemplateId_2); + insertPermissionTemplateGroup("6", permissionTemplateId_3); + + underTest.execute(); + // re-entrant + underTest.execute(); + + assertThatPermissionTemplateGroupTemplateUuidIsEqualTo("4", permissionTemplateUuid_1); + assertThatPermissionTemplateGroupTemplateUuidIsEqualTo("5", permissionTemplateUuid_2); + assertThatPermissionTemplateGroupTemplateUuidIsEqualTo("6", permissionTemplateUuid_3); + } + + private void assertThatPermissionTemplateGroupTemplateUuidIsEqualTo(String permissionTemplateGroupUuid, String expectedUuid) { + assertThat(db.select("select template_uuid from perm_templates_groups where uuid = '" + permissionTemplateGroupUuid + "'") + .stream() + .map(row -> row.get("TEMPLATE_UUID")) + .findFirst()) + .hasValue(expectedUuid); + } + + private void insertPermissionTemplateGroup(String uuid, Long templateId) { + db.executeInsert("perm_templates_groups", + "uuid", uuid, + "template_id", templateId, + "permission_reference", uuidFactory.create()); + } + + private void insertPermissionTemplate(Long id, String uuid) { + db.executeInsert("permission_templates", + "id", id, + "uuid", uuid, + "organization_uuid", id + 100, + "name", uuidFactory.create(), + "kee", uuidFactory.create()); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/AddTemplateUuidColumnToPermTemplatesUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/AddTemplateUuidColumnToPermTemplatesUsersTest.java new file mode 100644 index 00000000000..aa1a9e14fed --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/AddTemplateUuidColumnToPermTemplatesUsersTest.java @@ -0,0 +1,67 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesusers; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.UuidFactory; +import org.sonar.core.util.UuidFactoryFast; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddTemplateUuidColumnToPermTemplatesUsersTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddTemplateUuidColumnToPermTemplatesUsersTest.class, "schema.sql"); + + private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); + + private DdlChange underTest = new AddTemplateUuidColumnToPermTemplatesUsers(db.database()); + + @Before + public void setup() { + insertPermTemplatesUsers("1"); + insertPermTemplatesUsers("2"); + insertPermTemplatesUsers("3"); + } + + @Test + public void add_uuid_column_to_permission_templates() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("perm_templates_users", "template_uuid", Types.VARCHAR, 40, true); + + assertThat(db.countRowsOfTable("perm_templates_users")) + .isEqualTo(3); + } + + private void insertPermTemplatesUsers(String uuid) { + db.executeInsert("perm_templates_users", + "uuid", uuid, + "user_id", 100, + "template_id", 200, + "permission_reference", uuidFactory.create()); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/DropTemplateIdColumnOfPermTemplatesUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/DropTemplateIdColumnOfPermTemplatesUsersTableTest.java new file mode 100644 index 00000000000..a151ca7b9be --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/DropTemplateIdColumnOfPermTemplatesUsersTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesusers; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropTemplateIdColumnOfPermTemplatesUsersTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropTemplateIdColumnOfPermTemplatesUsersTableTest.class, "schema.sql"); + + private MigrationStep underTest = new DropTemplateIdColumnOfPermTemplatesUsersTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("perm_templates_users", "template_id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/MakePermTemplatesUsersTemplateUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/MakePermTemplatesUsersTemplateUuidColumnNotNullableTest.java new file mode 100644 index 00000000000..b4cd43c0bec --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/MakePermTemplatesUsersTemplateUuidColumnNotNullableTest.java @@ -0,0 +1,43 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesusers; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static java.sql.Types.VARCHAR; + +public class MakePermTemplatesUsersTemplateUuidColumnNotNullableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(MakePermTemplatesUsersTemplateUuidColumnNotNullableTest.class, "schema.sql"); + + private MigrationStep underTest = new MakePermTemplatesUsersTemplateUuidColumnNotNullable(db.database()); + + @Test + public void uuid_column_is_not_null() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("perm_templates_users", "template_uuid", VARCHAR, null, false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/PopulatePermTemplatesUsersTemplateUuidColumnTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/PopulatePermTemplatesUsersTemplateUuidColumnTest.java new file mode 100644 index 00000000000..d7d3997b466 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/PopulatePermTemplatesUsersTemplateUuidColumnTest.java @@ -0,0 +1,117 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtemplatesusers; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.UuidFactory; +import org.sonar.core.util.UuidFactoryFast; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulatePermTemplatesUsersTemplateUuidColumnTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulatePermTemplatesUsersTemplateUuidColumnTest.class, "schema.sql"); + + private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); + private DataChange underTest = new PopulatePermTemplatesUsersTemplateUuidColumn(db.database()); + + @Test + public void populate_uuids() throws SQLException { + long permissionTemplateId_1 = 1L; + String permissionTemplateUuid_1 = "uuid-1"; + insertPermissionTemplate(permissionTemplateId_1, permissionTemplateUuid_1); + + long permissionTemplateId_2 = 2L; + String permissionTemplateUuid_2 = "uuid-2"; + insertPermissionTemplate(permissionTemplateId_2, permissionTemplateUuid_2); + + long permissionTemplateId_3 = 3L; + String permissionTemplateUuid_3 = "uuid-3"; + insertPermissionTemplate(permissionTemplateId_3, permissionTemplateUuid_3); + + insertPermTemplatesUsers("4", permissionTemplateId_1); + insertPermTemplatesUsers("5", permissionTemplateId_2); + insertPermTemplatesUsers("6", permissionTemplateId_3); + + underTest.execute(); + + assertThatPermTemplatesUsersTemplateUuidIsEqualTo("4", permissionTemplateUuid_1); + assertThatPermTemplatesUsersTemplateUuidIsEqualTo("5", permissionTemplateUuid_2); + assertThatPermTemplatesUsersTemplateUuidIsEqualTo("6", permissionTemplateUuid_3); + } + + @Test + public void migration_is_reentrant() throws SQLException { + long permissionTemplateId_1 = 1L; + String permissionTemplateUuid_1 = "uuid-1"; + insertPermissionTemplate(permissionTemplateId_1, permissionTemplateUuid_1); + + long permissionTemplateId_2 = 2L; + String permissionTemplateUuid_2 = "uuid-2"; + insertPermissionTemplate(permissionTemplateId_2, permissionTemplateUuid_2); + + long permissionTemplateId_3 = 3L; + String permissionTemplateUuid_3 = "uuid-3"; + insertPermissionTemplate(permissionTemplateId_3, permissionTemplateUuid_3); + + insertPermTemplatesUsers("4", permissionTemplateId_1); + insertPermTemplatesUsers("5", permissionTemplateId_2); + insertPermTemplatesUsers("6", permissionTemplateId_3); + + underTest.execute(); + // re-entrant + underTest.execute(); + + assertThatPermTemplatesUsersTemplateUuidIsEqualTo("4", permissionTemplateUuid_1); + assertThatPermTemplatesUsersTemplateUuidIsEqualTo("5", permissionTemplateUuid_2); + assertThatPermTemplatesUsersTemplateUuidIsEqualTo("6", permissionTemplateUuid_3); + } + + private void assertThatPermTemplatesUsersTemplateUuidIsEqualTo(String permTemplatesUsersUuid, String expectedUuid) { + assertThat(db.select("select template_uuid from perm_templates_users where uuid = '" + permTemplatesUsersUuid + "'") + .stream() + .map(row -> row.get("TEMPLATE_UUID")) + .findFirst()) + .hasValue(expectedUuid); + } + + private void insertPermTemplatesUsers(String uuid, Long templateId) { + db.executeInsert("perm_templates_users", + "uuid", uuid, + "user_id", 100, + "template_id", templateId, + "permission_reference", uuidFactory.create()); + } + + private void insertPermissionTemplate(Long id, String uuid) { + db.executeInsert("permission_templates", + "id", id, + "uuid", uuid, + "organization_uuid", id + 100, + "name", uuidFactory.create(), + "kee", uuidFactory.create()); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/AddTemplateUuidColumnToPermTplCharacteristicsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/AddTemplateUuidColumnToPermTplCharacteristicsTest.java new file mode 100644 index 00000000000..f8433782e2c --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/AddTemplateUuidColumnToPermTplCharacteristicsTest.java @@ -0,0 +1,70 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtplcharacteristics; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.UuidFactory; +import org.sonar.core.util.UuidFactoryFast; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddTemplateUuidColumnToPermTplCharacteristicsTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddTemplateUuidColumnToPermTplCharacteristicsTest.class, "schema.sql"); + + private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); + + private DdlChange underTest = new AddTemplateUuidColumnToPermTplCharacteristics(db.database()); + + @Before + public void setup() { + insertPermTplCharacteristics("1"); + insertPermTplCharacteristics("2"); + insertPermTplCharacteristics("3"); + } + + @Test + public void add_uuid_column_to_perm_tpl_characteristics() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("perm_tpl_characteristics", "template_uuid", Types.VARCHAR, 40, true); + + assertThat(db.countRowsOfTable("perm_tpl_characteristics")) + .isEqualTo(3); + } + + private void insertPermTplCharacteristics(String uuid) { + db.executeInsert("perm_tpl_characteristics", + "uuid", uuid, + "template_id", 100, + "permission_key", uuidFactory.create(), + "with_project_creator", false, + "created_at", System.currentTimeMillis(), + "updated_at", System.currentTimeMillis()); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest.java new file mode 100644 index 00000000000..885bdd2a9e4 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest.java @@ -0,0 +1,52 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtplcharacteristics; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +public class AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropTemplateIdColumnOfPermTplCharacteristicsTableTest.class, "schema.sql"); + + private MigrationStep underTest = new AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertUniqueIndex("perm_tpl_characteristics", "uniq_perm_tpl_charac", "template_uuid", "permission_key"); + } + + @Test + public void migration_is_re_entrant() throws SQLException { + underTest.execute(); + + // re-entrant + underTest.execute(); + + db.assertUniqueIndex("perm_tpl_characteristics", "uniq_perm_tpl_charac", "template_uuid", "permission_key"); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/DropTemplateIdColumnOfPermTplCharacteristicsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/DropTemplateIdColumnOfPermTplCharacteristicsTableTest.java new file mode 100644 index 00000000000..f870e67e759 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/DropTemplateIdColumnOfPermTplCharacteristicsTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtplcharacteristics; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropTemplateIdColumnOfPermTplCharacteristicsTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropTemplateIdColumnOfPermTplCharacteristicsTableTest.class, "schema.sql"); + + private MigrationStep underTest = new DropTemplateIdColumnOfPermTplCharacteristicsTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("perm_tpl_characteristics", "template_id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest.java new file mode 100644 index 00000000000..dc1ff5bb71f --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest.java @@ -0,0 +1,52 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtplcharacteristics; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +public class DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropTemplateIdColumnOfPermTplCharacteristicsTableTest.class, "schema.sql"); + + private MigrationStep underTest = new DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertIndexDoesNotExist("perm_tpl_characteristics", "uniq_perm_tpl_charac"); + } + + @Test + public void migration_is_re_entrant() throws SQLException { + underTest.execute(); + + // re-entrant + underTest.execute(); + + db.assertIndexDoesNotExist("perm_tpl_characteristics", "uniq_perm_tpl_charac"); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/MakePermTplCharacteristicsTemplateUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/MakePermTplCharacteristicsTemplateUuidColumnNotNullableTest.java new file mode 100644 index 00000000000..8fe829a17a9 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/MakePermTplCharacteristicsTemplateUuidColumnNotNullableTest.java @@ -0,0 +1,43 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtplcharacteristics; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static java.sql.Types.VARCHAR; + +public class MakePermTplCharacteristicsTemplateUuidColumnNotNullableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(MakePermTplCharacteristicsTemplateUuidColumnNotNullableTest.class, "schema.sql"); + + private MigrationStep underTest = new MakePermTplCharacteristicsTemplateUuidColumnNotNullable(db.database()); + + @Test + public void uuid_column_is_not_null() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("perm_tpl_characteristics", "template_uuid", VARCHAR, null, false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/PopulatePermTplCharacteristicsTemplateUuidColumnTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/PopulatePermTplCharacteristicsTemplateUuidColumnTest.java new file mode 100644 index 00000000000..db54e43e155 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/PopulatePermTplCharacteristicsTemplateUuidColumnTest.java @@ -0,0 +1,118 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permissiontemplates.fk.permtplcharacteristics; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.UuidFactory; +import org.sonar.core.util.UuidFactoryFast; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulatePermTplCharacteristicsTemplateUuidColumnTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulatePermTplCharacteristicsTemplateUuidColumnTest.class, "schema.sql"); + + private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); + private DataChange underTest = new PopulatePermTplCharacteristicsTemplateUuidColumn(db.database()); + + @Test + public void populate_uuids() throws SQLException { + long permissionTemplateId_1 = 1L; + String permissionTemplateUuid_1 = "uuid-1"; + insertPermissionTemplate(permissionTemplateId_1, permissionTemplateUuid_1); + + long permissionTemplateId_2 = 2L; + String permissionTemplateUuid_2 = "uuid-2"; + insertPermissionTemplate(permissionTemplateId_2, permissionTemplateUuid_2); + + long permissionTemplateId_3 = 3L; + String permissionTemplateUuid_3 = "uuid-3"; + insertPermissionTemplate(permissionTemplateId_3, permissionTemplateUuid_3); + + insertPermTplCharacteristics("4", permissionTemplateId_1); + insertPermTplCharacteristics("5", permissionTemplateId_2); + insertPermTplCharacteristics("6", permissionTemplateId_3); + + underTest.execute(); + + assertThatPermTplCharacteristicsTemplateUuidIsEqualTo("4", permissionTemplateUuid_1); + assertThatPermTplCharacteristicsTemplateUuidIsEqualTo("5", permissionTemplateUuid_2); + assertThatPermTplCharacteristicsTemplateUuidIsEqualTo("6", permissionTemplateUuid_3); + } + + @Test + public void migration_is_reentrant() throws SQLException { + long permissionTemplateId_1 = 1L; + String permissionTemplateUuid_1 = "uuid-1"; + insertPermissionTemplate(permissionTemplateId_1, permissionTemplateUuid_1); + + long permissionTemplateId_2 = 2L; + String permissionTemplateUuid_2 = "uuid-2"; + insertPermissionTemplate(permissionTemplateId_2, permissionTemplateUuid_2); + + long permissionTemplateId_3 = 3L; + String permissionTemplateUuid_3 = "uuid-3"; + insertPermissionTemplate(permissionTemplateId_3, permissionTemplateUuid_3); + + insertPermTplCharacteristics("4", permissionTemplateId_1); + insertPermTplCharacteristics("5", permissionTemplateId_2); + insertPermTplCharacteristics("6", permissionTemplateId_3); + + underTest.execute(); + // re-entrant + underTest.execute(); + + assertThatPermTplCharacteristicsTemplateUuidIsEqualTo("4", permissionTemplateUuid_1); + assertThatPermTplCharacteristicsTemplateUuidIsEqualTo("5", permissionTemplateUuid_2); + assertThatPermTplCharacteristicsTemplateUuidIsEqualTo("6", permissionTemplateUuid_3); + } + + private void assertThatPermTplCharacteristicsTemplateUuidIsEqualTo(String permTplCharacteristicsUuid, String expectedUuid) { + assertThat(db.select("select template_uuid from perm_tpl_characteristics where uuid = '" + permTplCharacteristicsUuid + "'") + .stream() + .map(row -> row.get("TEMPLATE_UUID")) + .findFirst()) + .hasValue(expectedUuid); + } + + private void insertPermTplCharacteristics(String uuid, long templateId) { + db.executeInsert("perm_tpl_characteristics", + "uuid", uuid, + "template_id", templateId, + "permission_key", uuidFactory.create(), + "with_project_creator", false, + "created_at", System.currentTimeMillis(), + "updated_at", System.currentTimeMillis()); + } + + private void insertPermissionTemplate(Long id, String uuid) { + db.executeInsert("permission_templates", + "id", id, + "uuid", uuid, + "organization_uuid", id + 100, + "name", uuidFactory.create(), + "kee", uuidFactory.create()); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTableTest.java new file mode 100644 index 00000000000..3c694186564 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permtemplatesgroups; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema( + AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTableTest.class, "schema.sql"); + + private DdlChange underTest = new AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertPrimaryKey("perm_templates_groups", "pk_perm_templates_groups", "uuid"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddUuidColumnToPermTemplatesGroupsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddUuidColumnToPermTemplatesGroupsTableTest.java new file mode 100644 index 00000000000..b0a29b9c8b5 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddUuidColumnToPermTemplatesGroupsTableTest.java @@ -0,0 +1,64 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permtemplatesgroups; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddUuidColumnToPermTemplatesGroupsTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToPermTemplatesGroupsTableTest.class, "schema.sql"); + + private DdlChange underTest = new AddUuidColumnToPermTemplatesGroupsTable(db.database()); + + @Before + public void setup() { + insertPermTemplatesGroups(1L); + insertPermTemplatesGroups(2L); + insertPermTemplatesGroups(3L); + } + + @Test + public void add_uuid_column() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("perm_templates_groups", "uuid", Types.VARCHAR, 40, true); + + assertThat(db.countRowsOfTable("perm_templates_groups")) + .isEqualTo(3); + } + + private void insertPermTemplatesGroups(Long id) { + db.executeInsert("perm_templates_groups", + "id", id, + "group_id", id + 1, + "template_id", id + 2, + "permission_reference", "ref" + id); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropIdColumnOfPermTemplatesGroupsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropIdColumnOfPermTemplatesGroupsTableTest.java new file mode 100644 index 00000000000..e64d24b9ef3 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropIdColumnOfPermTemplatesGroupsTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permtemplatesgroups; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropIdColumnOfPermTemplatesGroupsTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfPermTemplatesGroupsTableTest.class, "schema.sql"); + + private DdlChange underTest = new DropIdColumnOfPermTemplatesGroupsTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("perm_templates_groups", "id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTableTest.java new file mode 100644 index 00000000000..998d78102e2 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTableTest.java @@ -0,0 +1,57 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.sonar.server.platform.db.migration.version.v84.permtemplatesgroups; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; +import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTableTest { + + private static final String TABLE_NAME = "perm_templates_groups"; + @Rule + public CoreDbTester db = CoreDbTester.createForSchema( + DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTableTest.class, "schema.sql"); + + private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + + private DdlChange underTest = new DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTable(db.database(), dropPrimaryKeySqlGenerator); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertNoPrimaryKey(TABLE_NAME); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/MakePermTemplatesGroupsUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/MakePermTemplatesGroupsUuidColumnNotNullableTest.java new file mode 100644 index 00000000000..178de611d69 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/MakePermTemplatesGroupsUuidColumnNotNullableTest.java @@ -0,0 +1,42 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permtemplatesgroups; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static java.sql.Types.VARCHAR; + +public class MakePermTemplatesGroupsUuidColumnNotNullableTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(MakePermTemplatesGroupsUuidColumnNotNullableTest.class, "schema.sql"); + + private MigrationStep underTest = new MakePermTemplatesGroupsUuidColumnNotNullable(db.database()); + + @Test + public void uuid_column_is_not_nullable() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("perm_templates_groups", "uuid", VARCHAR, null, false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/PopulatePermTemplatesGroupsUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/PopulatePermTemplatesGroupsUuidTest.java new file mode 100644 index 00000000000..d77249c5e6d --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/PopulatePermTemplatesGroupsUuidTest.java @@ -0,0 +1,81 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permtemplatesgroups; + +import java.sql.SQLException; +import java.util.Objects; +import java.util.stream.Collectors; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.UuidFactory; +import org.sonar.core.util.UuidFactoryFast; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulatePermTemplatesGroupsUuidTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulatePermTemplatesGroupsUuidTest.class, "schema.sql"); + + private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); + private DataChange underTest = new PopulatePermTemplatesGroupsUuid(db.database(), uuidFactory); + + @Test + public void populate_uuids() throws SQLException { + insertPermTemplatesGroups(1L); + insertPermTemplatesGroups(2L); + insertPermTemplatesGroups(3L); + + underTest.execute(); + + verifyUuidsAreNotNull(); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertPermTemplatesGroups(1L); + insertPermTemplatesGroups(2L); + insertPermTemplatesGroups(3L); + + underTest.execute(); + // re-entrant + underTest.execute(); + + verifyUuidsAreNotNull(); + } + + private void verifyUuidsAreNotNull() { + assertThat(db.select("select uuid from perm_templates_groups") + .stream() + .map(row -> row.get("UUID")) + .filter(Objects::isNull) + .collect(Collectors.toList())).isEmpty(); + } + + private void insertPermTemplatesGroups(Long id) { + db.executeInsert("perm_templates_groups", + "id", id, + "group_id", id + 1, + "template_id", id + 2, + "permission_reference", "ref" + id); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTableTest.java new file mode 100644 index 00000000000..797f73eee36 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permtemplatesusers; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema( + AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTableTest.class, "schema.sql"); + + private DdlChange underTest = new AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertPrimaryKey("perm_templates_users", "pk_perm_templates_users", "uuid"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddUuidColumnToPermTemplatesUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddUuidColumnToPermTemplatesUsersTableTest.java new file mode 100644 index 00000000000..bf036a281cf --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddUuidColumnToPermTemplatesUsersTableTest.java @@ -0,0 +1,64 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permtemplatesusers; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddUuidColumnToPermTemplatesUsersTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToPermTemplatesUsersTableTest.class, "schema.sql"); + + private DdlChange underTest = new AddUuidColumnToPermTemplatesUsersTable(db.database()); + + @Before + public void setup() { + insertPermTemplatesUsers(1L); + insertPermTemplatesUsers(2L); + insertPermTemplatesUsers(3L); + } + + @Test + public void add_uuid_column() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("perm_templates_users", "uuid", Types.VARCHAR, 40, true); + + assertThat(db.countRowsOfTable("perm_templates_users")) + .isEqualTo(3); + } + + private void insertPermTemplatesUsers(Long id) { + db.executeInsert("perm_templates_users", + "id", id, + "user_id", id + 1, + "template_id", id + 2, + "permission_reference", "ref" + id); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropIdColumnOfPermTemplatesUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropIdColumnOfPermTemplatesUsersTableTest.java new file mode 100644 index 00000000000..660f08d392b --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropIdColumnOfPermTemplatesUsersTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permtemplatesusers; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropIdColumnOfPermTemplatesUsersTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfPermTemplatesUsersTableTest.class, "schema.sql"); + + private DdlChange underTest = new DropIdColumnOfPermTemplatesUsersTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("perm_templates_users", "id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTableTest.java new file mode 100644 index 00000000000..90c54aceca4 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTableTest.java @@ -0,0 +1,57 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.sonar.server.platform.db.migration.version.v84.permtemplatesusers; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; +import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTableTest { + + private static final String TABLE_NAME = "perm_templates_users"; + @Rule + public CoreDbTester db = CoreDbTester.createForSchema( + DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTableTest.class, "schema.sql"); + + private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + + private DdlChange underTest = new DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTable(db.database(), dropPrimaryKeySqlGenerator); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertNoPrimaryKey(TABLE_NAME); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/MakePermTemplatesUsersUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/MakePermTemplatesUsersUuidColumnNotNullableTest.java new file mode 100644 index 00000000000..265e3dd88ce --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/MakePermTemplatesUsersUuidColumnNotNullableTest.java @@ -0,0 +1,42 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permtemplatesusers; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static java.sql.Types.VARCHAR; + +public class MakePermTemplatesUsersUuidColumnNotNullableTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(MakePermTemplatesUsersUuidColumnNotNullableTest.class, "schema.sql"); + + private MigrationStep underTest = new MakePermTemplatesUsersUuidColumnNotNullable(db.database()); + + @Test + public void uuid_column_is_not_nullable() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("perm_templates_users", "uuid", VARCHAR, null, false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/PopulatePermTemplatesUsersUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/PopulatePermTemplatesUsersUuidTest.java new file mode 100644 index 00000000000..a77b621259a --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/PopulatePermTemplatesUsersUuidTest.java @@ -0,0 +1,81 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permtemplatesusers; + +import java.sql.SQLException; +import java.util.Objects; +import java.util.stream.Collectors; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.UuidFactory; +import org.sonar.core.util.UuidFactoryFast; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulatePermTemplatesUsersUuidTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulatePermTemplatesUsersUuidTest.class, "schema.sql"); + + private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); + private DataChange underTest = new PopulatePermTemplatesUsersUuid(db.database(), uuidFactory); + + @Test + public void populate_uuids() throws SQLException { + insertPermTemplatesUsers(1L); + insertPermTemplatesUsers(2L); + insertPermTemplatesUsers(3L); + + underTest.execute(); + + verifyUuidsAreNotNull(); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertPermTemplatesUsers(1L); + insertPermTemplatesUsers(2L); + insertPermTemplatesUsers(3L); + + underTest.execute(); + // re-entrant + underTest.execute(); + + verifyUuidsAreNotNull(); + } + + private void verifyUuidsAreNotNull() { + assertThat(db.select("select uuid from perm_templates_users") + .stream() + .map(row -> row.get("UUID")) + .filter(Objects::isNull) + .collect(Collectors.toList())).isEmpty(); + } + + private void insertPermTemplatesUsers(Long id) { + db.executeInsert("perm_templates_users", + "id", id, + "user_id", id + 1, + "template_id", id + 2, + "permission_reference", "ref" + id); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTableTest.java new file mode 100644 index 00000000000..da9b96cb50c --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permtplcharacteristics; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema( + AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTableTest.class, "schema.sql"); + + private DdlChange underTest = new AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertPrimaryKey("perm_tpl_characteristics", "pk_perm_tpl_characteristics", "uuid"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddUuidColumnToPermTplCharacteristicsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddUuidColumnToPermTplCharacteristicsTableTest.java new file mode 100644 index 00000000000..6822a84bc56 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddUuidColumnToPermTplCharacteristicsTableTest.java @@ -0,0 +1,66 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permtplcharacteristics; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddUuidColumnToPermTplCharacteristicsTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToPermTplCharacteristicsTableTest.class, "schema.sql"); + + private DdlChange underTest = new AddUuidColumnToPermTplCharacteristicsTable(db.database()); + + @Before + public void setup() { + insertPermTplCharacteristics(1L); + insertPermTplCharacteristics(2L); + insertPermTplCharacteristics(3L); + } + + @Test + public void add_uuid_column() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("perm_tpl_characteristics", "uuid", Types.VARCHAR, 40, true); + + assertThat(db.countRowsOfTable("perm_tpl_characteristics")) + .isEqualTo(3); + } + + private void insertPermTplCharacteristics(Long id) { + db.executeInsert("perm_tpl_characteristics", + "id", id, + "template_id", id + 1, + "permission_key", "key" + id + 2, + "with_project_creator", true, + "created_at", id + 3, + "updated_at", id + 4); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropIdColumnOfPermTplCharacteristicsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropIdColumnOfPermTplCharacteristicsTableTest.java new file mode 100644 index 00000000000..feb6901eaa4 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropIdColumnOfPermTplCharacteristicsTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permtplcharacteristics; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropIdColumnOfPermTplCharacteristicsTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfPermTplCharacteristicsTableTest.class, "schema.sql"); + + private DdlChange underTest = new DropIdColumnOfPermTplCharacteristicsTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("perm_tpl_characteristics", "id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTableTest.java new file mode 100644 index 00000000000..0a11ab48f98 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTableTest.java @@ -0,0 +1,57 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.sonar.server.platform.db.migration.version.v84.permtplcharacteristics; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; +import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTableTest { + + private static final String TABLE_NAME = "perm_tpl_characteristics"; + @Rule + public CoreDbTester db = CoreDbTester.createForSchema( + DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTableTest.class, "schema.sql"); + + private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + + private DdlChange underTest = new DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTable(db.database(), dropPrimaryKeySqlGenerator); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertNoPrimaryKey(TABLE_NAME); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/MakePermTplCharacteristicsUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/MakePermTplCharacteristicsUuidColumnNotNullableTest.java new file mode 100644 index 00000000000..7c48cfbac3a --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/MakePermTplCharacteristicsUuidColumnNotNullableTest.java @@ -0,0 +1,42 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permtplcharacteristics; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static java.sql.Types.VARCHAR; + +public class MakePermTplCharacteristicsUuidColumnNotNullableTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(MakePermTplCharacteristicsUuidColumnNotNullableTest.class, "schema.sql"); + + private MigrationStep underTest = new MakePermTplCharacteristicsUuidColumnNotNullable(db.database()); + + @Test + public void uuid_column_is_not_nullable() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("perm_tpl_characteristics", "uuid", VARCHAR, null, false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/PopulatePermTplCharacteristicsUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/PopulatePermTplCharacteristicsUuidTest.java new file mode 100644 index 00000000000..a00c62c5259 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/PopulatePermTplCharacteristicsUuidTest.java @@ -0,0 +1,83 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.permtplcharacteristics; + +import java.sql.SQLException; +import java.util.Objects; +import java.util.stream.Collectors; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.UuidFactory; +import org.sonar.core.util.UuidFactoryFast; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulatePermTplCharacteristicsUuidTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulatePermTplCharacteristicsUuidTest.class, "schema.sql"); + + private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); + private DataChange underTest = new PopulatePermTplCharacteristicsUuid(db.database(), uuidFactory); + + @Test + public void populate_uuids() throws SQLException { + insertPermTplCharacteristics(1L); + insertPermTplCharacteristics(2L); + insertPermTplCharacteristics(3L); + + underTest.execute(); + + verifyUuidsAreNotNull(); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertPermTplCharacteristics(1L); + insertPermTplCharacteristics(2L); + insertPermTplCharacteristics(3L); + + underTest.execute(); + // re-entrant + underTest.execute(); + + verifyUuidsAreNotNull(); + } + + private void verifyUuidsAreNotNull() { + assertThat(db.select("select uuid from perm_tpl_characteristics") + .stream() + .map(row -> row.get("UUID")) + .filter(Objects::isNull) + .collect(Collectors.toList())).isEmpty(); + } + + private void insertPermTplCharacteristics(Long id) { + db.executeInsert("perm_tpl_characteristics", + "id", id, + "template_id", id + 1, + "permission_key", "key" + id + 2, + "with_project_creator", true, + "created_at", id + 3, + "updated_at", id + 4); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddPrimaryKeyOnUuidColumnOfProjectMeasureTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddPrimaryKeyOnUuidColumnOfProjectMeasureTableTest.java new file mode 100644 index 00000000000..b0e3006e684 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddPrimaryKeyOnUuidColumnOfProjectMeasureTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.projectmeasures; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class AddPrimaryKeyOnUuidColumnOfProjectMeasureTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfProjectMeasureTableTest.class, "schema.sql"); + + private MigrationStep underTest = new AddPrimaryKeyOnUuidColumnOfProjectMeasuresTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertPrimaryKey("project_measures", "pk_project_measures", "uuid"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddUuidToProjectMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddUuidToProjectMeasuresTest.java new file mode 100644 index 00000000000..f73b857a5b4 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddUuidToProjectMeasuresTest.java @@ -0,0 +1,67 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.projectmeasures; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.UuidFactory; +import org.sonar.core.util.UuidFactoryFast; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddUuidToProjectMeasuresTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddUuidToProjectMeasuresTest.class, "schema.sql"); + + private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); + + private DdlChange underTest = new AddUuidColumnToProjectMeasures(db.database()); + + @Before + public void setup() { + insertProjectMeasure(1L); + insertProjectMeasure(2L); + insertProjectMeasure(3L); + } + + @Test + public void add_uuid_column_to_project_measures() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("project_measures", "uuid", Types.VARCHAR, 40, true); + + assertThat(db.countSql("select count(id) from project_measures")) + .isEqualTo(3); + } + + private void insertProjectMeasure(Long id) { + db.executeInsert("project_measures", + "id", id, + "metric_id", id + 100, + "analysis_uuid", uuidFactory.create(), + "component_uuid", uuidFactory.create()); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropIdColumnOfProjectMeasuresTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropIdColumnOfProjectMeasuresTableTest.java new file mode 100644 index 00000000000..d9158271d97 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropIdColumnOfProjectMeasuresTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.projectmeasures; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropIdColumnOfProjectMeasuresTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfProjectMeasuresTableTest.class, "schema.sql"); + + private MigrationStep underTest = new DropIdColumnOfProjectMeasuresTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("project_measures", "id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropPrimaryKeyOnIdColumnOfProjectMeasuresTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropPrimaryKeyOnIdColumnOfProjectMeasuresTableTest.java new file mode 100644 index 00000000000..b8f895d6842 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropPrimaryKeyOnIdColumnOfProjectMeasuresTableTest.java @@ -0,0 +1,56 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.projectmeasures; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; +import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropPrimaryKeyOnIdColumnOfProjectMeasuresTableTest { + + private static final String TABLE_NAME = "project_measures"; + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfProjectMeasuresTableTest.class, "schema.sql"); + + private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + + private MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfProjectMeasuresTable(db.database(), dropPrimaryKeySqlGenerator); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertNoPrimaryKey(TABLE_NAME); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/MakeProjectMeasuresUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/MakeProjectMeasuresUuidColumnNotNullableTest.java new file mode 100644 index 00000000000..3de5931e682 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/MakeProjectMeasuresUuidColumnNotNullableTest.java @@ -0,0 +1,43 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.projectmeasures; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static java.sql.Types.VARCHAR; + +public class MakeProjectMeasuresUuidColumnNotNullableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(MakeProjectMeasuresUuidColumnNotNullableTest.class, "schema.sql"); + + private MigrationStep underTest = new MakeProjectMeasuresUuidColumnNotNullable(db.database()); + + @Test + public void uuid_column_is_not_null() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("project_measures", "uuid", VARCHAR, null, false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/PopulateProjectMeasuresUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/PopulateProjectMeasuresUuidTest.java new file mode 100644 index 00000000000..1277ded583b --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/PopulateProjectMeasuresUuidTest.java @@ -0,0 +1,82 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.projectmeasures; + +import java.sql.SQLException; +import java.util.Objects; +import java.util.stream.Collectors; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.UuidFactory; +import org.sonar.core.util.UuidFactoryFast; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulateProjectMeasuresUuidTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulateProjectMeasuresUuidTest.class, "schema.sql"); + + private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); + private DataChange underTest = new PopulateProjectMeasureUuid(db.database(), uuidFactory); + + @Test + public void populate_uuids() throws SQLException { + insertProjectMeasure(1L); + insertProjectMeasure(2L); + insertProjectMeasure(3L); + + underTest.execute(); + + verifyUuidsAreNotNull(); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertProjectMeasure(1L); + insertProjectMeasure(2L); + insertProjectMeasure(3L); + + underTest.execute(); + // re-entrant + underTest.execute(); + + verifyUuidsAreNotNull(); + } + + private void verifyUuidsAreNotNull() { + assertThat(db.select("select uuid from project_measures") + .stream() + .map(row -> row.get("UUID")) + .filter(Objects::isNull) + .collect(Collectors.toList())).isEmpty(); + } + + private void insertProjectMeasure(Long id) { + db.executeInsert("project_measures", + "id", id, + "metric_id", id + 100, + "analysis_uuid", uuidFactory.create(), + "component_uuid", uuidFactory.create()); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTableTest.java new file mode 100644 index 00000000000..e41d6f53fc0 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTableTest.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.projectqprofiles; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class AddPrimaryKeyOnUuidColumnOfProjectQProfilesTableTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfProjectQProfilesTableTest.class, "schema.sql"); + + private DdlChange underTest = new AddPrimaryKeyOnUuidColumnOfProjectQProfilesTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertPrimaryKey("project_qprofiles", "pk_project_qprofiles", "uuid"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddUuidColumnToProjectQProfilesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddUuidColumnToProjectQProfilesTableTest.java new file mode 100644 index 00000000000..bb941bffe9a --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddUuidColumnToProjectQProfilesTableTest.java @@ -0,0 +1,66 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.projectqprofiles; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.UuidFactory; +import org.sonar.core.util.UuidFactoryFast; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddUuidColumnToProjectQProfilesTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToProjectQProfilesTableTest.class, "schema.sql"); + + private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); + + private DdlChange underTest = new AddUuidColumnToProjectQProfilesTable(db.database()); + + @Before + public void setup() { + insertProjectQProfile(1L); + insertProjectQProfile(2L); + insertProjectQProfile(3L); + } + + @Test + public void add_uuid_column_to_project_qprofiles() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("project_qprofiles", "uuid", Types.VARCHAR, 40, true); + + assertThat(db.countSql("select count(id) from project_qprofiles")) + .isEqualTo(3); + } + + private void insertProjectQProfile(Long id) { + db.executeInsert("project_qprofiles", + "id", id, + "project_uuid", uuidFactory.create(), + "profile_key", uuidFactory.create()); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropIdColumnOfProjectQProfilesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropIdColumnOfProjectQProfilesTableTest.java new file mode 100644 index 00000000000..718910479c3 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropIdColumnOfProjectQProfilesTableTest.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.projectqprofiles; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropIdColumnOfProjectQProfilesTableTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfProjectQProfilesTableTest.class, "schema.sql"); + + private DdlChange underTest = new DropIdColumnOfProjectQProfilesTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("project_qprofiles", "id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest.java new file mode 100644 index 00000000000..9e464b57dd0 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest.java @@ -0,0 +1,54 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.projectqprofiles; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; +import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest { + private static final String TABLE_NAME = "project_qprofiles"; + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest.class, "schema.sql"); + + private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + + private DdlChange underTest = new DropPrimaryKeyOnIdColumnOfProjectQProfilesTable(db.database(), dropPrimaryKeySqlGenerator); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertNoPrimaryKey(TABLE_NAME); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/MakeProjectQProfilesUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/MakeProjectQProfilesUuidColumnNotNullableTest.java new file mode 100644 index 00000000000..56fb22daad4 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/MakeProjectQProfilesUuidColumnNotNullableTest.java @@ -0,0 +1,43 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.projectqprofiles; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static java.sql.Types.VARCHAR; + +public class MakeProjectQProfilesUuidColumnNotNullableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(MakeProjectQProfilesUuidColumnNotNullableTest.class, "schema.sql"); + + private MigrationStep underTest = new MakeProjectQProfilesUuidColumnNotNullable(db.database()); + + @Test + public void uuid_column_is_not_null() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("project_qprofiles", "uuid", VARCHAR, null, false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/PopulateProjectQProfilesUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/PopulateProjectQProfilesUuidTest.java new file mode 100644 index 00000000000..a421c410a7e --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/PopulateProjectQProfilesUuidTest.java @@ -0,0 +1,80 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.projectqprofiles; + +import java.sql.SQLException; +import java.util.Objects; +import java.util.stream.Collectors; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.UuidFactory; +import org.sonar.core.util.UuidFactoryFast; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulateProjectQProfilesUuidTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulateProjectQProfilesUuidTest.class, "schema.sql"); + + private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); + private DataChange underTest = new PopulateProjectQProfilesUuid(db.database(), uuidFactory); + + @Test + public void populate_uuids() throws SQLException { + insertProjectQProfile(1L); + insertProjectQProfile(2L); + insertProjectQProfile(3L); + + underTest.execute(); + + verifyUuidsAreNotNull(); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertProjectQProfile(1L); + insertProjectQProfile(2L); + insertProjectQProfile(3L); + + underTest.execute(); + // re-entrant + underTest.execute(); + + verifyUuidsAreNotNull(); + } + + private void verifyUuidsAreNotNull() { + assertThat(db.select("select uuid from project_qprofiles") + .stream() + .map(row -> row.get("UUID")) + .filter(Objects::isNull) + .collect(Collectors.toList())).isEmpty(); + } + + private void insertProjectQProfile(Long id) { + db.executeInsert("project_qprofiles", + "id", id, + "project_uuid", uuidFactory.create(), + "profile_key", uuidFactory.create()); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/AddPrimaryKeyOnUuidColumnOfPropertiesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/AddPrimaryKeyOnUuidColumnOfPropertiesTableTest.java new file mode 100644 index 00000000000..5605124e5fb --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/AddPrimaryKeyOnUuidColumnOfPropertiesTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.properties; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class AddPrimaryKeyOnUuidColumnOfPropertiesTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfPropertiesTableTest.class, "schema.sql"); + + private MigrationStep underTest = new AddPrimaryKeyOnUuidColumnOfPropertiesTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertPrimaryKey("properties", "pk_properties", "uuid"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/AddUuidColumnToPropertiesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/AddUuidColumnToPropertiesTest.java new file mode 100644 index 00000000000..299ecd080ea --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/AddUuidColumnToPropertiesTest.java @@ -0,0 +1,64 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.properties; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddUuidColumnToPropertiesTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToPropertiesTest.class, "schema.sql"); + + private DdlChange underTest = new AddUuidColumnToProperties(db.database()); + + @Before + public void setup() { + insertProperties(1L, "uuid1", "key1"); + insertProperties(2L, "uuid2", "key2"); + insertProperties(3L, "uuid3", "key3"); + } + + @Test + public void add_uuid_to_properties() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("properties", "uuid", Types.VARCHAR, 40, true); + + assertThat(db.countSql("select count(id) from properties")) + .isEqualTo(3); + } + + private void insertProperties(Long id, String uuid, String propKey) { + + db.executeInsert("properties", + "id", id, + "prop_key", propKey, + "is_empty", false, + "created_at", 0); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/DropIdColumnOfPropertiesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/DropIdColumnOfPropertiesTableTest.java new file mode 100644 index 00000000000..f7f1feccf99 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/DropIdColumnOfPropertiesTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.properties; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropIdColumnOfPropertiesTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfPropertiesTableTest.class, "schema.sql"); + + private MigrationStep underTest = new DropIdColumnOfPropertiesTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("properties", "id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/DropPrimaryKeyOnIdColumnOfPropertiesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/DropPrimaryKeyOnIdColumnOfPropertiesTableTest.java new file mode 100644 index 00000000000..0e3b583bec2 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/DropPrimaryKeyOnIdColumnOfPropertiesTableTest.java @@ -0,0 +1,56 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.properties; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; +import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropPrimaryKeyOnIdColumnOfPropertiesTableTest { + + private static final String TABLE_NAME = "properties"; + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfPropertiesTableTest.class, "schema.sql"); + + private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + + private MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfPropertiesTable(db.database(), dropPrimaryKeySqlGenerator); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertNoPrimaryKey(TABLE_NAME); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/MakeNotificationUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/MakeNotificationUuidColumnNotNullableTest.java new file mode 100644 index 00000000000..8f0ea9c64cb --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/MakeNotificationUuidColumnNotNullableTest.java @@ -0,0 +1,43 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.properties; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static java.sql.Types.VARCHAR; + +public class MakeNotificationUuidColumnNotNullableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(MakeNotificationUuidColumnNotNullableTest.class, "schema.sql"); + + private MigrationStep underTest = new MakePropertiesUuidColumnNotNullable(db.database()); + + @Test + public void created_at_and_uuid_columns_are_not_null() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("properties", "uuid", VARCHAR, null, false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/PopulatePropertiesUuidAndCreatedAtTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/PopulatePropertiesUuidAndCreatedAtTest.java new file mode 100644 index 00000000000..6a4ac3cc356 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/PopulatePropertiesUuidAndCreatedAtTest.java @@ -0,0 +1,84 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.properties; + +import java.sql.SQLException; +import java.util.Objects; +import java.util.stream.Collectors; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.UuidFactory; +import org.sonar.core.util.UuidFactoryFast; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulatePropertiesUuidAndCreatedAtTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulatePropertiesUuidAndCreatedAtTest.class, "schema.sql"); + + private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); + private DataChange underTest = new PopulatePropertiesUuid(db.database(), uuidFactory); + + @Test + public void populate_uuids() throws SQLException { + insertProperties(1L, "uuid1", "key1"); + insertProperties(2L, "uuid2", "key2"); + insertProperties(3L, "uuid3", "key3"); + + + underTest.execute(); + + verifyUuidsAreNotNull(); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertProperties(1L, "uuid1", "key1"); + insertProperties(2L, "uuid2", "key2"); + insertProperties(3L, "uuid3", "key3"); + + underTest.execute(); + // re-entrant + underTest.execute(); + + verifyUuidsAreNotNull(); + } + + private void verifyUuidsAreNotNull() { + assertThat(db.select("select uuid from properties") + .stream() + .map(row -> row.get("UUID")) + .filter(Objects::isNull) + .collect(Collectors.toList())).isEmpty(); + } + + private void insertProperties(Long id, String uuid, String propKey) { + + db.executeInsert("properties", + "id", id, + "prop_key", propKey, + "uuid", uuid, + "is_empty", false, + "created_at", 0); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTableTest.java new file mode 100644 index 00000000000..1e1e8962949 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTableTest.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.qualitygateconditions; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTableTest.class, "schema.sql"); + + private DdlChange underTest = new AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertPrimaryKey("quality_gate_conditions", "pk_quality_gate_conditions", "uuid"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddUuidColumnToQualityGateConditionsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddUuidColumnToQualityGateConditionsTableTest.java new file mode 100644 index 00000000000..da9e2159006 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddUuidColumnToQualityGateConditionsTableTest.java @@ -0,0 +1,66 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.qualitygateconditions; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.UuidFactoryFast; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddUuidColumnToQualityGateConditionsTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToQualityGateConditionsTableTest.class, "schema.sql"); + + private DdlChange underTest = new AddUuidColumnToQualityGateConditionsTable(db.database()); + + private UuidFactoryFast uuidFactory = UuidFactoryFast.getInstance(); + + @Before + public void setup() { + insertQualityGateCondition(1L); + insertQualityGateCondition(2L); + insertQualityGateCondition(3L); + } + + @Test + public void add_uuid_column() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("quality_gate_conditions", "uuid", Types.VARCHAR, 40, true); + + assertThat(db.countRowsOfTable("quality_gate_conditions")) + .isEqualTo(3); + } + + private void insertQualityGateCondition(Long id) { + db.executeInsert("quality_gate_conditions", + "id", id, + "qgate_id", id + 1, + "period", id + 2); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropIdColumnOfQualityGateConditionsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropIdColumnOfQualityGateConditionsTableTest.java new file mode 100644 index 00000000000..c79509a3b45 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropIdColumnOfQualityGateConditionsTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.qualitygateconditions; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropIdColumnOfQualityGateConditionsTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfQualityGateConditionsTableTest.class, "schema.sql"); + + private DdlChange underTest = new DropIdColumnOfQualityGateConditionsTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("quality_gate_conditions", "id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropPrimaryKeyOnIdColumnOfQualityGateConditionsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropPrimaryKeyOnIdColumnOfQualityGateConditionsTableTest.java new file mode 100644 index 00000000000..1b84fde48e5 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropPrimaryKeyOnIdColumnOfQualityGateConditionsTableTest.java @@ -0,0 +1,56 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.sonar.server.platform.db.migration.version.v84.qualitygateconditions; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; +import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropPrimaryKeyOnIdColumnOfQualityGateConditionsTableTest { + + private static final String TABLE_NAME = "quality_gate_conditions"; + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfQualityGateConditionsTableTest.class, "schema.sql"); + + private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + + private DdlChange underTest = new DropPrimaryKeyOnIdColumnOfQualityGateConditionsTable(db.database(), dropPrimaryKeySqlGenerator); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertNoPrimaryKey(TABLE_NAME); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/MakeQualityGateConditionsUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/MakeQualityGateConditionsUuidColumnNotNullableTest.java new file mode 100644 index 00000000000..24c768ba45b --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/MakeQualityGateConditionsUuidColumnNotNullableTest.java @@ -0,0 +1,42 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.qualitygateconditions; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static java.sql.Types.VARCHAR; + +public class MakeQualityGateConditionsUuidColumnNotNullableTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(MakeQualityGateConditionsUuidColumnNotNullableTest.class, "schema.sql"); + + private MigrationStep underTest = new MakeQualityGateConditionsUuidColumnNotNullable(db.database()); + + @Test + public void uuid_column_is_not_nullable() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("quality_gate_conditions", "uuid", VARCHAR, null, false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/PopulateQualityGateConditionsUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/PopulateQualityGateConditionsUuidTest.java new file mode 100644 index 00000000000..0f36846b4be --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/PopulateQualityGateConditionsUuidTest.java @@ -0,0 +1,81 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.qualitygateconditions; + +import java.sql.SQLException; +import java.util.Objects; +import java.util.stream.Collectors; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.UuidFactory; +import org.sonar.core.util.UuidFactoryFast; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulateQualityGateConditionsUuidTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulateQualityGateConditionsUuidTest.class, "schema.sql"); + + private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); + private DataChange underTest = new PopulateQualityGateConditionsUuid(db.database(), uuidFactory); + + @Test + public void populate_uuids() throws SQLException { + insertQualityGateCondition(1L); + insertQualityGateCondition(2L); + insertQualityGateCondition(3L); + + underTest.execute(); + + verifyUuidsAreNotNull(); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertQualityGateCondition(1L); + insertQualityGateCondition(2L); + insertQualityGateCondition(3L); + + underTest.execute(); + // re-entrant + underTest.execute(); + + verifyUuidsAreNotNull(); + } + + private void verifyUuidsAreNotNull() { + assertThat(db.select("select uuid from quality_gate_conditions") + .stream() + .map(row -> row.get("UUID")) + .filter(Objects::isNull) + .collect(Collectors.toList())).isEmpty(); + } + + private void insertQualityGateCondition(Long id) { + db.executeInsert("quality_gate_conditions", + "id", id, + "uuid", uuidFactory.create(), + "qgate_id", id + 1, + "period", id + 2); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddPrimaryKeyOnUuidColumnOfQGatesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddPrimaryKeyOnUuidColumnOfQGatesTableTest.java new file mode 100644 index 00000000000..447a782ec3c --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddPrimaryKeyOnUuidColumnOfQGatesTableTest.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.qualitygates; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class AddPrimaryKeyOnUuidColumnOfQGatesTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfQGatesTableTest.class, "schema.sql"); + + private MigrationStep underTest = new AddPrimaryKeyOnUuidColumnOfQGatesTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertPrimaryKey("quality_gates", "pk_quality_gates", "uuid"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddQGateUuidColumnForQGateConditionsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddQGateUuidColumnForQGateConditionsTest.java new file mode 100644 index 00000000000..74fab1fcb25 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddQGateUuidColumnForQGateConditionsTest.java @@ -0,0 +1,52 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.qualitygates; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class AddQGateUuidColumnForQGateConditionsTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddQGateUuidColumnForQGateConditionsTest.class, "schema.sql"); + + private MigrationStep underTest = new AddQGateUuidColumnForQGateConditions(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("quality_gate_conditions", "qgate_uuid", Types.VARCHAR, 40, true); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropIdColumnOfQGateTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropIdColumnOfQGateTableTest.java new file mode 100644 index 00000000000..33806309cf9 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropIdColumnOfQGateTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.qualitygates; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropIdColumnOfQGateTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfQGateTableTest.class, "schema.sql"); + + private MigrationStep underTest = new DropIdColumnOfQGateTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("quality_gates", "id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropOrphansQGateConditionsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropOrphansQGateConditionsTest.java new file mode 100644 index 00000000000..0d183108227 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropOrphansQGateConditionsTest.java @@ -0,0 +1,73 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.qualitygates; + +import java.sql.SQLException; +import java.util.stream.Collectors; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static org.assertj.core.api.Assertions.assertThat; + +public class DropOrphansQGateConditionsTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropOrphansQGateConditionsTest.class, "schema.sql"); + + private MigrationStep underTest = new DropOrphansQGateConditions(db.database()); + + @Test + public void deleteOrphanQGConditions() throws SQLException { + insertQualityGate(1L, "uuid1", "qualityGate1"); + insertQualityGateCondition("condition_uuid_1", "uuid1"); + insertQualityGateCondition("condition_uuid_2", "uuid1"); + insertQualityGateCondition("condition_uuid_3", null); + + underTest.execute(); + + verifyConditionExist("condition_uuid_1", true); + verifyConditionExist("condition_uuid_2", true); + verifyConditionExist("condition_uuid_3", false); + } + + private void verifyConditionExist(String uuid, boolean exist) { + assertThat(db.select("select count(uuid) as C from quality_gate_conditions where uuid='" + uuid + "'") + .stream() + .map(row -> (Long) row.get("C")) + .collect(Collectors.toList())).containsOnly(exist ? 1L : 0L); + } + + private void insertQualityGate(Long id, String uuid, String name) { + db.executeInsert("quality_gates", + "id", id, + "uuid", uuid, + "name", name, + "is_built_in", true); + } + + private void insertQualityGateCondition(String uuid, String qualityGateUuid) { + db.executeInsert("quality_gate_conditions", + "uuid", uuid, + "qgate_uuid", qualityGateUuid); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropPrimaryKeyOnIdColumnOfQGatesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropPrimaryKeyOnIdColumnOfQGatesTableTest.java new file mode 100644 index 00000000000..3b47c7cf239 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropPrimaryKeyOnIdColumnOfQGatesTableTest.java @@ -0,0 +1,56 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.qualitygates; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; +import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropPrimaryKeyOnIdColumnOfQGatesTableTest { + + private static final String TABLE_NAME = "quality_gates"; + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfQGatesTableTest.class, "schema.sql"); + + private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + + private MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfQGatesTable(db.database(), dropPrimaryKeySqlGenerator); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertNoPrimaryKey(TABLE_NAME); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropQGateIdColumnForQGateConditionsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropQGateIdColumnForQGateConditionsTest.java new file mode 100644 index 00000000000..f426eb15c40 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropQGateIdColumnForQGateConditionsTest.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.qualitygates; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropQGateIdColumnForQGateConditionsTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropQGateIdColumnForQGateConditionsTest.class, "schema.sql"); + + private MigrationStep underTest = new DropQGateIdColumnForQGateConditions(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("quality_gate_conditions", "qgate_id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropUniqueIndexOnUuidColumnOfQualityGatesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropUniqueIndexOnUuidColumnOfQualityGatesTableTest.java new file mode 100644 index 00000000000..5706de2ee1d --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropUniqueIndexOnUuidColumnOfQualityGatesTableTest.java @@ -0,0 +1,43 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.qualitygates; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +public class DropUniqueIndexOnUuidColumnOfQualityGatesTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropUniqueIndexOnUuidColumnOfQualityGatesTableTest.class, "schema.sql"); + + private MigrationStep underTest = new DropUniqueIndexOnUuidColumnOfQualityGatesTable(db.database()); + + @Test + public void execute_drop_index() throws SQLException { + db.assertUniqueIndex("quality_gates", "uniq_quality_gates_uuid", "uuid"); + + underTest.execute(); + + db.assertIndexDoesNotExist("quality_gates", "uniq_quality_gates_uuid"); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/MakeQGateUuidColumnNotNullableForQGateConditionsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/MakeQGateUuidColumnNotNullableForQGateConditionsTest.java new file mode 100644 index 00000000000..d3ca822d89a --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/MakeQGateUuidColumnNotNullableForQGateConditionsTest.java @@ -0,0 +1,43 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.qualitygates; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static java.sql.Types.VARCHAR; + +public class MakeQGateUuidColumnNotNullableForQGateConditionsTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(MakeQGateUuidColumnNotNullableForQGateConditionsTest.class, "schema.sql"); + + private MigrationStep underTest = new MakeQGateUuidColumnNotNullableForQGateConditions(db.database()); + + @Test + public void created_at_and_uuid_columns_are_not_null() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("quality_gate_conditions", "qgate_uuid", VARCHAR, null, false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/PopulateQGateUuidColumnForQGateConditionsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/PopulateQGateUuidColumnForQGateConditionsTest.java new file mode 100644 index 00000000000..e5a88b0d3c5 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/PopulateQGateUuidColumnForQGateConditionsTest.java @@ -0,0 +1,93 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.qualitygates; + +import java.sql.SQLException; +import java.util.stream.Collectors; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulateQGateUuidColumnForQGateConditionsTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulateQGateUuidColumnForQGateConditionsTest.class, "schema.sql"); + + private DataChange underTest = new PopulateQGateUuidColumnForQGateConditions(db.database()); + + @Test + public void populate_qgate_uuids() throws SQLException { + insertQualityGate(1L, "uuid1", "qualityGate1"); + insertQualityGate(2L, "uuid2", "qualityGate2"); + insertQualityGate(3L, "uuid3", "qualityGate3"); + insertQualityGateCondition("condition_uuid_1", "uuid1"); + insertQualityGateCondition("condition_uuid_2", "uuid1"); + insertQualityGateCondition("condition_uuid_3", "uuid2"); + + underTest.execute(); + + verifyUuid("condition_uuid_1", "uuid1"); + verifyUuid("condition_uuid_2", "uuid1"); + verifyUuid("condition_uuid_3", "uuid2"); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertQualityGate(1L, "uuid1", "qualityGate1"); + insertQualityGate(2L, "uuid2", "qualityGate2"); + insertQualityGate(3L, "uuid3", "qualityGate3"); + insertQualityGateCondition("condition_uuid_1", "uuid1"); + insertQualityGateCondition("condition_uuid_2", "uuid1"); + insertQualityGateCondition("condition_uuid_3", "uuid2"); + + underTest.execute(); + // re-entrant + underTest.execute(); + + verifyUuid("condition_uuid_1", "uuid1"); + verifyUuid("condition_uuid_2", "uuid1"); + verifyUuid("condition_uuid_3", "uuid2"); + } + + private void verifyUuid(String conditionUuid, String expectedUuid) { + assertThat(db.select("select QGATE_UUID from quality_gate_conditions where uuid='" + conditionUuid+"'") + .stream() + .map(row -> row.get("QGATE_UUID")) + .collect(Collectors.toList())).containsOnly(expectedUuid); + } + + private void insertQualityGate(Long id, String uuid, String name) { + db.executeInsert("quality_gates", + "id", id, + "uuid", uuid, + "name", name, + "is_built_in", true); + } + + private void insertQualityGateCondition(String uuid, String qualityGateUuid) { + db.executeInsert("quality_gate_conditions", + "uuid", uuid, + "qgate_uuid", qualityGateUuid); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/AddPrimaryKeyOnUuidColumnOfRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/AddPrimaryKeyOnUuidColumnOfRulesTableTest.java new file mode 100644 index 00000000000..58eab6e5dd7 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/AddPrimaryKeyOnUuidColumnOfRulesTableTest.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class AddPrimaryKeyOnUuidColumnOfRulesTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfRulesTableTest.class, "schema.sql"); + + private MigrationStep underTest = new AddPrimaryKeyOnUuidColumnOfRulesTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertPrimaryKey("rules", "pk_rules", "uuid"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/AddUuidAndTemplateUuidColumnsToRulesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/AddUuidAndTemplateUuidColumnsToRulesTest.java new file mode 100644 index 00000000000..c96c0f57819 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/AddUuidAndTemplateUuidColumnsToRulesTest.java @@ -0,0 +1,66 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddUuidAndTemplateUuidColumnsToRulesTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddUuidAndTemplateUuidColumnsToRulesTest.class, "schema.sql"); + + private DdlChange underTest = new AddUuidAndTemplateUuidColumnsToRules(db.database()); + + @Before + public void setup() { + insertRule(1L); + insertRule(2L); + insertRule(3L); + insertRule(4L); + } + + @Test + public void add_uuid_column() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("rules", "uuid", Types.VARCHAR, 40, true); + + assertThat(db.countSql("select count(*) from rules")) + .isEqualTo(4); + } + + private void insertRule(long id) { + db.executeInsert("rules", + "id", id, + "plugin_rule_key", "rk" + id, + "plugin_name", "rn" + id, + "scope", "MAIN", + "is_ad_hoc", false, + "is_external", false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/DropIdColumnOfRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/DropIdColumnOfRulesTableTest.java new file mode 100644 index 00000000000..ced8483368a --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/DropIdColumnOfRulesTableTest.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropIdColumnOfRulesTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfRulesTableTest.class, "schema.sql"); + + private DdlChange underTest = new DropIdColumnOfRulesTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("rules", "id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/DropPrimaryKeyOnIdColumnOfRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/DropPrimaryKeyOnIdColumnOfRulesTableTest.java new file mode 100644 index 00000000000..b54648c5e6d --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/DropPrimaryKeyOnIdColumnOfRulesTableTest.java @@ -0,0 +1,56 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; +import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropPrimaryKeyOnIdColumnOfRulesTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfRulesTableTest.class, "schema.sql"); + + private MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfRulesTable(db.database(), + new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database()))); + + @Test + public void execute() throws SQLException { + db.assertTableExists("rules"); + db.assertPrimaryKey("rules", "pk_rules", "id"); + + underTest.execute(); + + db.assertNoPrimaryKey("rules"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/DropTemplateIdColumnOfRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/DropTemplateIdColumnOfRulesTableTest.java new file mode 100644 index 00000000000..753101a5174 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/DropTemplateIdColumnOfRulesTableTest.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropTemplateIdColumnOfRulesTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropTemplateIdColumnOfRulesTableTest.class, "schema.sql"); + + private DdlChange underTest = new DropTemplateIdColumnOfRulesTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("rules", "template_id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/MakeRulesUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/MakeRulesUuidColumnNotNullableTest.java new file mode 100644 index 00000000000..ab65bbe0aaf --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/MakeRulesUuidColumnNotNullableTest.java @@ -0,0 +1,43 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static java.sql.Types.VARCHAR; + +public class MakeRulesUuidColumnNotNullableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(MakeRulesUuidColumnNotNullableTest.class, "schema.sql"); + + private MigrationStep underTest = new MakeRulesUuidColumnNotNullable(db.database()); + + @Test + public void uuid_column_is_not_null() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("rules", "uuid", VARCHAR, null, false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/PopulateRulesTemplateUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/PopulateRulesTemplateUuidTest.java new file mode 100644 index 00000000000..2828136ce2b --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/PopulateRulesTemplateUuidTest.java @@ -0,0 +1,74 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules; + +import java.sql.SQLException; +import javax.annotation.Nullable; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.tuple; + +public class PopulateRulesTemplateUuidTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulateRulesTemplateUuidTest.class, "schema.sql"); + + private DataChange underTest = new PopulateRulesTemplateUuid(db.database()); + + @Before + public void setup() { + insertRule(1L, "uuid-1", 1L); + insertRule(2L, "uuid-2", 1L); + insertRule(3L, "uuid-3", null); + insertRule(4L, "uuid-4", 2L); + } + + @Test + public void add_rule_uuid_column() throws SQLException { + underTest.execute(); + + assertThat(db.countSql("select count(*) from rules")) + .isEqualTo(4); + assertThat(db.select("select uuid, template_id, template_uuid from rules")) + .extracting(m -> m.get("UUID"), m -> m.get("TEMPLATE_ID"), m -> m.get("TEMPLATE_UUID")) + .containsExactlyInAnyOrder( + tuple("uuid-1", 1L, "uuid-1"), + tuple("uuid-2", 1L, "uuid-1"), + tuple("uuid-3", null, null), + tuple("uuid-4", 2L, "uuid-2")); + } + + private void insertRule(long id, String uuid, @Nullable Long templateId) { + db.executeInsert("rules", + "id", id, + "uuid", uuid, + "template_id", templateId, + "plugin_rule_key", "rk" + id, + "plugin_name", "rn" + id, + "scope", "MAIN", + "is_ad_hoc", false, + "is_external", false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/PopulateRulesUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/PopulateRulesUuidTest.java new file mode 100644 index 00000000000..332b18315bd --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/PopulateRulesUuidTest.java @@ -0,0 +1,73 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules; + +import java.sql.SQLException; +import java.util.Objects; +import java.util.stream.Collectors; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.UuidFactory; +import org.sonar.core.util.UuidFactoryFast; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulateRulesUuidTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulateRulesUuidTest.class, "schema.sql"); + + private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); + private DataChange underTest = new PopulateRulesUuid(db.database(), uuidFactory); + + @Before + public void setup() { + insertRule(1L); + insertRule(2L); + insertRule(3L); + insertRule(4L); + } + + @Test + public void add_rule_uuid_column() throws SQLException { + underTest.execute(); + + assertThat(db.countSql("select count(*) from rules")) + .isEqualTo(4); + assertThat(db.select("select uuid from rules") + .stream() + .map(row -> row.get("UUID")) + .filter(Objects::isNull) + .collect(Collectors.toList())).isEmpty(); + } + + private void insertRule(long id) { + db.executeInsert("rules", + "id", id, + "plugin_rule_key", "rk" + id, + "plugin_name", "rn" + id, + "scope", "MAIN", + "is_ad_hoc", false, + "is_external", false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/AddIndexToActiveRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/AddIndexToActiveRulesTableTest.java new file mode 100644 index 00000000000..7cc08603c66 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/AddIndexToActiveRulesTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.activerules; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +public class AddIndexToActiveRulesTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddIndexToActiveRulesTableTest.class, "schema.sql"); + + private MigrationStep underTest = new AddIndexToActiveRulesTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertUniqueIndex("active_rules", "uniq_profile_rule_uuids", "profile_uuid", "rule_uuid"); + } + + @Test + public void migration_is_re_entrant() throws SQLException { + underTest.execute(); + + // re-entrant + underTest.execute(); + + db.assertUniqueIndex("active_rules", "uniq_profile_rule_uuids", "profile_uuid", "rule_uuid"); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/AddRuleUuidColumnToActiveRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/AddRuleUuidColumnToActiveRulesTableTest.java new file mode 100644 index 00000000000..a9b3a851d85 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/AddRuleUuidColumnToActiveRulesTableTest.java @@ -0,0 +1,79 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.activerules; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddRuleUuidColumnToActiveRulesTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddRuleUuidColumnToActiveRulesTableTest.class, "schema.sql"); + + private DdlChange underTest = new AddRuleUuidColumnToActiveRulesTable(db.database()); + + @Before + public void setup() { + insertRule(1L, "uuid-rule-1"); + insertRule(2L, "uuid-rule-2"); + insertRule(3L, "uuid-rule-3"); + insertRule(4L, "uuid-rule-4"); + + insertActiveRule("uuid-ar-1", 1L, "uuid-profile-1"); + insertActiveRule("uuid-ar-2", 1L, "uuid-profile-2"); + insertActiveRule("uuid-ar-3", 2L, "uuid-profile-1"); + } + + @Test + public void add_rule_uuid_column() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("active_rules", "rule_uuid", Types.VARCHAR, 40, true); + assertThat(db.countSql("select count(*) from active_rules")) + .isEqualTo(3); + } + + private void insertRule(long id, String uuid) { + db.executeInsert("rules", + "id", id, + "uuid", uuid, + "plugin_rule_key", "rk" + id, + "plugin_name", "rn" + id, + "scope", "MAIN", + "is_ad_hoc", false, + "is_external", false); + } + + private void insertActiveRule(String uuid, long ruleId, String profileUuid) { + db.executeInsert("active_rules", + "uuid", uuid, + "rule_id", ruleId, + "profile_uuid", profileUuid, + "failure_level", 1); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/DropIndexOnRuleIdColumnOfActiveRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/DropIndexOnRuleIdColumnOfActiveRulesTableTest.java new file mode 100644 index 00000000000..3b93f7029f6 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/DropIndexOnRuleIdColumnOfActiveRulesTableTest.java @@ -0,0 +1,54 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.activerules; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +public class DropIndexOnRuleIdColumnOfActiveRulesTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropIndexOnRuleIdColumnOfActiveRulesTableTest.class, "schema.sql"); + + private MigrationStep underTest = new DropIndexOnRuleIdColumnOfActiveRulesTable(db.database()); + + @Test + public void execute() throws SQLException { + db.assertTableExists("active_rules"); + db.assertUniqueIndex("active_rules", "uniq_profile_rule_ids", "profile_uuid", "rule_id"); + + underTest.execute(); + + db.assertIndexDoesNotExist("active_rules", "uniq_profile_rule_ids"); + } + + @Test + public void migration_is_re_entrant() throws SQLException { + underTest.execute(); + + // re-entrant + underTest.execute(); + + db.assertIndexDoesNotExist("active_rules", "uniq_profile_rule_ids"); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/DropRuleIdColumnOfActiveRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/DropRuleIdColumnOfActiveRulesTableTest.java new file mode 100644 index 00000000000..b2c9ae6b4ea --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/DropRuleIdColumnOfActiveRulesTableTest.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.activerules; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropRuleIdColumnOfActiveRulesTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropRuleIdColumnOfActiveRulesTableTest.class, "schema.sql"); + + private DdlChange underTest = new DropRuleIdColumnOfActiveRulesTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("active_rules", "id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/MakeActiveRulesRuleUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/MakeActiveRulesRuleUuidColumnNotNullableTest.java new file mode 100644 index 00000000000..1a4c49d10b0 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/MakeActiveRulesRuleUuidColumnNotNullableTest.java @@ -0,0 +1,43 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.activerules; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static java.sql.Types.VARCHAR; + +public class MakeActiveRulesRuleUuidColumnNotNullableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(MakeActiveRulesRuleUuidColumnNotNullableTest.class, "schema.sql"); + + private MigrationStep underTest = new MakeActiveRulesRuleUuidColumnNotNullable(db.database()); + + @Test + public void uuid_column_is_not_null() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("active_rules", "rule_uuid", VARCHAR, null, false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/PopulateActiveRulesRuleUuidColumnTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/PopulateActiveRulesRuleUuidColumnTest.java new file mode 100644 index 00000000000..7591b9e6cc8 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/activerules/PopulateActiveRulesRuleUuidColumnTest.java @@ -0,0 +1,84 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.activerules; + +import java.sql.SQLException; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.tuple; + +public class PopulateActiveRulesRuleUuidColumnTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulateActiveRulesRuleUuidColumnTest.class, "schema.sql"); + + private DataChange underTest = new PopulateActiveRulesRuleUuidColumn(db.database()); + + @Before + public void setup() { + insertRule(1L, "uuid-rule-1"); + insertRule(2L, "uuid-rule-2"); + insertRule(3L, "uuid-rule-3"); + insertRule(4L, "uuid-rule-4"); + + insertActiveRule("uuid-ar-1", 1L, "uuid-profile-1"); + insertActiveRule("uuid-ar-2", 1L, "uuid-profile-2"); + insertActiveRule("uuid-ar-3", 2L, "uuid-profile-1"); + } + + @Test + public void add_rule_uuid_column() throws SQLException { + underTest.execute(); + + assertThat(db.countSql("select count(*) from active_rules")) + .isEqualTo(3); + assertThat(db.select("select uuid, rule_id, rule_uuid from active_rules")) + .extracting(m -> m.get("UUID"), m -> m.get("RULE_ID"), m -> m.get("RULE_UUID")) + .containsExactlyInAnyOrder( + tuple("uuid-ar-1", 1L, "uuid-rule-1"), + tuple("uuid-ar-2", 1L, "uuid-rule-1"), + tuple("uuid-ar-3", 2L, "uuid-rule-2")); + } + + private void insertRule(long id, String uuid) { + db.executeInsert("rules", + "id", id, + "uuid", uuid, + "plugin_rule_key", "rk" + id, + "plugin_name", "rn" + id, + "scope", "MAIN", + "is_ad_hoc", false, + "is_external", false); + } + + private void insertActiveRule(String uuid, long ruleId, String profileUuid) { + db.executeInsert("active_rules", + "uuid", uuid, + "rule_id", ruleId, + "profile_uuid", profileUuid, + "failure_level", 1); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/AddIndexToDeprecatedRuleKeysTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/AddIndexToDeprecatedRuleKeysTableTest.java new file mode 100644 index 00000000000..441206616f8 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/AddIndexToDeprecatedRuleKeysTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.deprecatedrulekeys; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +public class AddIndexToDeprecatedRuleKeysTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddIndexToDeprecatedRuleKeysTableTest.class, "schema.sql"); + + private MigrationStep underTest = new AddIndexToDeprecatedRuleKeysTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertIndex("deprecated_rule_keys", "rule_uuid_deprecated_rule_keys", "rule_uuid"); + } + + @Test + public void migration_is_re_entrant() throws SQLException { + underTest.execute(); + + // re-entrant + underTest.execute(); + + db.assertIndex("deprecated_rule_keys", "rule_uuid_deprecated_rule_keys", "rule_uuid"); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/AddRuleUuidColumnToDeprecatedRuleKeysTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/AddRuleUuidColumnToDeprecatedRuleKeysTableTest.java new file mode 100644 index 00000000000..b76911debb1 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/AddRuleUuidColumnToDeprecatedRuleKeysTableTest.java @@ -0,0 +1,80 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.deprecatedrulekeys; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.api.utils.System2; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddRuleUuidColumnToDeprecatedRuleKeysTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddRuleUuidColumnToDeprecatedRuleKeysTableTest.class, "schema.sql"); + + private DdlChange underTest = new AddRuleUuidColumnToDeprecatedRuleKeysTable(db.database()); + + @Before + public void setup() { + insertRule(1L, "uuid-rule-1"); + insertRule(2L, "uuid-rule-2"); + insertRule(3L, "uuid-rule-3"); + + insertDeprecatedRuleKeyRow("uuid-drk-1", 1L); + insertDeprecatedRuleKeyRow("uuid-drk-2", 1L); + insertDeprecatedRuleKeyRow("uuid-drk-3", 2L); + } + + @Test + public void add_rule_uuid_column() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("deprecated_rule_keys", "rule_uuid", Types.VARCHAR, 40, true); + assertThat(db.countSql("select count(*) from deprecated_rule_keys")) + .isEqualTo(3); + } + + private void insertRule(long id, String uuid) { + db.executeInsert("rules", + "id", id, + "uuid", uuid, + "plugin_rule_key", "rk" + id, + "plugin_name", "rn" + id, + "scope", "MAIN", + "is_ad_hoc", false, + "is_external", false); + } + + private void insertDeprecatedRuleKeyRow(String uuid, long ruleId) { + db.executeInsert("deprecated_rule_keys", + "uuid", uuid, + "rule_id", ruleId, + "old_repository_key", "old-repo-key" + uuid, + "old_rule_key", "old-rule-key" + uuid, + "created_at", System2.INSTANCE.now()); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTableTest.java new file mode 100644 index 00000000000..062b485e64b --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTableTest.java @@ -0,0 +1,54 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.deprecatedrulekeys; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +public class DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTableTest.class, "schema.sql"); + + private MigrationStep underTest = new DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTable(db.database()); + + @Test + public void execute() throws SQLException { + db.assertTableExists("deprecated_rule_keys"); + db.assertIndex("deprecated_rule_keys", "rule_id_deprecated_rule_keys", "rule_id"); + + underTest.execute(); + + db.assertIndexDoesNotExist("deprecated_rule_keys", "rule_id_deprecated_rule_keys"); + } + + @Test + public void migration_is_re_entrant() throws SQLException { + underTest.execute(); + + // re-entrant + underTest.execute(); + + db.assertIndexDoesNotExist("deprecated_rule_keys", "rule_id_deprecated_rule_keys"); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/DropRuleIdColumnOfDeprecatedRuleKeysTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/DropRuleIdColumnOfDeprecatedRuleKeysTableTest.java new file mode 100644 index 00000000000..0873ebddeb3 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/DropRuleIdColumnOfDeprecatedRuleKeysTableTest.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.deprecatedrulekeys; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropRuleIdColumnOfDeprecatedRuleKeysTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropRuleIdColumnOfDeprecatedRuleKeysTableTest.class, "schema.sql"); + + private DdlChange underTest = new DropRuleIdColumnOfDeprecatedRuleKeysTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("deprecated_rule_keys", "id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/MakeDeprecatedRuleKeysRuleUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/MakeDeprecatedRuleKeysRuleUuidColumnNotNullableTest.java new file mode 100644 index 00000000000..d4f942b39dd --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/MakeDeprecatedRuleKeysRuleUuidColumnNotNullableTest.java @@ -0,0 +1,43 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.deprecatedrulekeys; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static java.sql.Types.VARCHAR; + +public class MakeDeprecatedRuleKeysRuleUuidColumnNotNullableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(MakeDeprecatedRuleKeysRuleUuidColumnNotNullableTest.class, "schema.sql"); + + private MigrationStep underTest = new MakeDeprecatedRuleKeysRuleUuidColumnNotNullable(db.database()); + + @Test + public void uuid_column_is_not_null() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("deprecated_rule_keys", "rule_uuid", VARCHAR, null, false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/PopulateDeprecatedRuleKeysRuleUuidColumnTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/PopulateDeprecatedRuleKeysRuleUuidColumnTest.java new file mode 100644 index 00000000000..7f9c48b61c0 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/PopulateDeprecatedRuleKeysRuleUuidColumnTest.java @@ -0,0 +1,86 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.deprecatedrulekeys; + +import java.sql.SQLException; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.api.utils.System2; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.tuple; + +public class PopulateDeprecatedRuleKeysRuleUuidColumnTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulateDeprecatedRuleKeysRuleUuidColumnTest.class, "schema.sql"); + + private DataChange underTest = new PopulateDeprecatedRuleKeysRuleUuidColumn(db.database()); + + @Before + public void setup() { + insertRule(1L, "uuid-rule-1"); + insertRule(2L, "uuid-rule-2"); + insertRule(3L, "uuid-rule-3"); + insertRule(4L, "uuid-rule-4"); + + insertDeprecatedRuleKeyRow("uuid-drk-1", 1L); + insertDeprecatedRuleKeyRow("uuid-drk-2", 1L); + insertDeprecatedRuleKeyRow("uuid-drk-3", 2L); + } + + @Test + public void add_rule_uuid_column() throws SQLException { + underTest.execute(); + + assertThat(db.countSql("select count(*) from deprecated_rule_keys")) + .isEqualTo(3); + assertThat(db.select("select uuid, rule_id, rule_uuid from deprecated_rule_keys")) + .extracting(m -> m.get("UUID"), m -> m.get("RULE_ID"), m -> m.get("RULE_UUID")) + .containsExactlyInAnyOrder( + tuple("uuid-drk-1", 1L, "uuid-rule-1"), + tuple("uuid-drk-2", 1L, "uuid-rule-1"), + tuple("uuid-drk-3", 2L, "uuid-rule-2")); + } + + private void insertRule(long id, String uuid) { + db.executeInsert("rules", + "id", id, + "uuid", uuid, + "plugin_rule_key", "rk" + id, + "plugin_name", "rn" + id, + "scope", "MAIN", + "is_ad_hoc", false, + "is_external", false); + } + + private void insertDeprecatedRuleKeyRow(String uuid, long ruleId) { + db.executeInsert("deprecated_rule_keys", + "uuid", uuid, + "rule_id", ruleId, + "old_repository_key", "old-repo-key" + uuid, + "old_rule_key", "old-rule-key" + uuid, + "created_at", System2.INSTANCE.now()); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/AddIndexToIssuesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/AddIndexToIssuesTableTest.java new file mode 100644 index 00000000000..5e132b4c0b5 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/AddIndexToIssuesTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.issues; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +public class AddIndexToIssuesTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddIndexToIssuesTableTest.class, "schema.sql"); + + private MigrationStep underTest = new AddIndexToIssuesTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertIndex("issues", "issues_rule_uuid", "rule_uuid"); + } + + @Test + public void migration_is_re_entrant() throws SQLException { + underTest.execute(); + + // re-entrant + underTest.execute(); + + db.assertIndex("issues", "issues_rule_uuid", "rule_uuid"); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/AddRuleUuidColumnToIssuesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/AddRuleUuidColumnToIssuesTableTest.java new file mode 100644 index 00000000000..11648e1d21e --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/AddRuleUuidColumnToIssuesTableTest.java @@ -0,0 +1,81 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.issues; + +import java.sql.SQLException; +import java.sql.Types; +import javax.annotation.Nullable; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddRuleUuidColumnToIssuesTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddRuleUuidColumnToIssuesTableTest.class, "schema.sql"); + + private DdlChange underTest = new AddRuleUuidColumnToIssuesTable(db.database()); + + @Before + public void setup() { + insertRule(1L, "uuid-rule-1"); + insertRule(2L, "uuid-rule-2"); + insertRule(3L, "uuid-rule-3"); + insertRule(4L, "uuid-rule-4"); + + insertIssue("kee-iss-1", 1L); + insertIssue("kee-iss-2", 1L); + insertIssue("kee-iss-3", 2L); + insertIssue("kee-iss-4", null); + insertIssue("kee-iss-5", null); + } + + @Test + public void add_rule_uuid_column() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("issues", "rule_uuid", Types.VARCHAR, 40, true); + assertThat(db.countSql("select count(*) from issues")) + .isEqualTo(5); + } + + private void insertRule(long id, String uuid) { + db.executeInsert("rules", + "id", id, + "uuid", uuid, + "plugin_rule_key", "rk" + id, + "plugin_name", "rn" + id, + "scope", "MAIN", + "is_ad_hoc", false, + "is_external", false); + } + + private void insertIssue(String kee, @Nullable Long ruleId) { + db.executeInsert("issues", + "kee", kee, + "rule_id", ruleId, + "manual_severity", false); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/DropIndexOnRuleIdColumnOfIssuesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/DropIndexOnRuleIdColumnOfIssuesTableTest.java new file mode 100644 index 00000000000..0838ca20372 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/DropIndexOnRuleIdColumnOfIssuesTableTest.java @@ -0,0 +1,54 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.issues; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +public class DropIndexOnRuleIdColumnOfIssuesTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropIndexOnRuleIdColumnOfIssuesTableTest.class, "schema.sql"); + + private MigrationStep underTest = new DropIndexOnRuleIdColumnOfIssuesTable(db.database()); + + @Test + public void execute() throws SQLException { + db.assertTableExists("issues"); + db.assertIndex("issues", "issues_rule_id", "rule_id"); + + underTest.execute(); + + db.assertIndexDoesNotExist("issues", "issues_rule_id"); + } + + @Test + public void migration_is_re_entrant() throws SQLException { + underTest.execute(); + + // re-entrant + underTest.execute(); + + db.assertIndexDoesNotExist("issues", "issues_rule_id"); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/DropRuleIdColumnOfIssuesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/DropRuleIdColumnOfIssuesTableTest.java new file mode 100644 index 00000000000..66d175380c1 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/DropRuleIdColumnOfIssuesTableTest.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.issues; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropRuleIdColumnOfIssuesTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropRuleIdColumnOfIssuesTableTest.class, "schema.sql"); + + private DdlChange underTest = new DropRuleIdColumnOfIssuesTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("issues", "id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/PopulateIssuesRuleUuidColumnTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/PopulateIssuesRuleUuidColumnTest.java new file mode 100644 index 00000000000..cc796467624 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/issues/PopulateIssuesRuleUuidColumnTest.java @@ -0,0 +1,87 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.issues; + +import java.sql.SQLException; +import javax.annotation.Nullable; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.tuple; + +public class PopulateIssuesRuleUuidColumnTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulateIssuesRuleUuidColumnTest.class, "schema.sql"); + + private DataChange underTest = new PopulateIssuesRuleUuidColumn(db.database()); + + @Before + public void setup() { + insertRule(1L, "uuid-rule-1"); + insertRule(2L, "uuid-rule-2"); + insertRule(3L, "uuid-rule-3"); + insertRule(4L, "uuid-rule-4"); + + insertIssue("kee-iss-1", 1L); + insertIssue("kee-iss-2", 1L); + insertIssue("kee-iss-3", 2L); + insertIssue("kee-iss-4", null); + insertIssue("kee-iss-5", null); + } + + @Test + public void add_rule_uuid_column() throws SQLException { + underTest.execute(); + + assertThat(db.countSql("select count(*) from issues")).isEqualTo(5); + assertThat(db.select("select kee, rule_id, rule_uuid from issues")) + .extracting(m -> m.get("KEE"), m -> m.get("RULE_ID"), m -> m.get("RULE_UUID")) + .containsExactlyInAnyOrder( + tuple("kee-iss-1", 1L, "uuid-rule-1"), + tuple("kee-iss-2", 1L, "uuid-rule-1"), + tuple("kee-iss-3", 2L, "uuid-rule-2"), + tuple("kee-iss-4", null, null), + tuple("kee-iss-5", null, null)); + } + + private void insertRule(long id, String uuid) { + db.executeInsert("rules", + "id", id, + "uuid", uuid, + "plugin_rule_key", "rk" + id, + "plugin_name", "rn" + id, + "scope", "MAIN", + "is_ad_hoc", false, + "is_external", false); + } + + private void insertIssue(String kee, @Nullable Long ruleId) { + db.executeInsert("issues", + "kee", kee, + "rule_id", ruleId, + "manual_severity", false); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTableTest.java new file mode 100644 index 00000000000..73171e13bb0 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTableTest.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.rulesmetadata; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTableTest.class, "schema.sql"); + + private MigrationStep underTest = new AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertPrimaryKey("rules_metadata", "pk_rules_metadata", "rule_uuid", "organization_uuid"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddRuleUuidColumnToRulesMetadataTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddRuleUuidColumnToRulesMetadataTableTest.java new file mode 100644 index 00000000000..e03995ac850 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddRuleUuidColumnToRulesMetadataTableTest.java @@ -0,0 +1,80 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.rulesmetadata; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.api.utils.System2; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddRuleUuidColumnToRulesMetadataTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddRuleUuidColumnToRulesMetadataTableTest.class, "schema.sql"); + + private DdlChange underTest = new AddRuleUuidColumnToRulesMetadataTable(db.database()); + + @Before + public void setup() { + insertRule(1L, "uuid-rule-1"); + insertRule(2L, "uuid-rule-2"); + insertRule(3L, "uuid-rule-3"); + insertRule(4L, "uuid-rule-4"); + + insertRuleMetadata(1L, "org-1"); + insertRuleMetadata(1L, "org-2"); + insertRuleMetadata(2L, "org-1"); + } + + @Test + public void add_rule_uuid_column() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("rules_metadata", "rule_uuid", Types.VARCHAR, 40, true); + assertThat(db.countSql("select count(*) from rules_metadata")) + .isEqualTo(3); + } + + private void insertRule(long id, String uuid) { + db.executeInsert("rules", + "id", id, + "uuid", uuid, + "plugin_rule_key", "rk" + id, + "plugin_name", "rn" + id, + "scope", "MAIN", + "is_ad_hoc", false, + "is_external", false); + } + + private void insertRuleMetadata(long ruleId, String organizationUuid) { + db.executeInsert("rules_metadata", + "rule_id", ruleId, + "organization_uuid", organizationUuid, + "created_at", System2.INSTANCE.now(), + "updated_at", System2.INSTANCE.now()); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropPrimaryKeyOnIdColumnOfRulesMetadataTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropPrimaryKeyOnIdColumnOfRulesMetadataTableTest.java new file mode 100644 index 00000000000..371079a6713 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropPrimaryKeyOnIdColumnOfRulesMetadataTableTest.java @@ -0,0 +1,56 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.rulesmetadata; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; +import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropPrimaryKeyOnIdColumnOfRulesMetadataTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfRulesMetadataTableTest.class, "schema.sql"); + + private MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfRulesMetadataTable(db.database(), + new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database()))); + + @Test + public void execute() throws SQLException { + db.assertTableExists("rules_metadata"); + db.assertPrimaryKey("rules_metadata", "pk_rules_metadata", "rule_id", "organization_uuid"); + + underTest.execute(); + + db.assertNoPrimaryKey("rules_metadata"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropRuleIdColumnOfRulesMetadataTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropRuleIdColumnOfRulesMetadataTableTest.java new file mode 100644 index 00000000000..d82ae463dbc --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropRuleIdColumnOfRulesMetadataTableTest.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.rulesmetadata; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropRuleIdColumnOfRulesMetadataTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropRuleIdColumnOfRulesMetadataTableTest.class, "schema.sql"); + + private DdlChange underTest = new DropRuleIdColumnOfRulesMetadataTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("rules_metadata", "id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/MakeRulesMetadataRuleUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/MakeRulesMetadataRuleUuidColumnNotNullableTest.java new file mode 100644 index 00000000000..ec712f207e7 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/MakeRulesMetadataRuleUuidColumnNotNullableTest.java @@ -0,0 +1,43 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.rulesmetadata; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static java.sql.Types.VARCHAR; + +public class MakeRulesMetadataRuleUuidColumnNotNullableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(MakeRulesMetadataRuleUuidColumnNotNullableTest.class, "schema.sql"); + + private MigrationStep underTest = new MakeRulesMetadataRuleUuidColumnNotNullable(db.database()); + + @Test + public void uuid_column_is_not_null() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("rules_metadata", "rule_uuid", VARCHAR, null, false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/PopulateRulesMetadataRuleUuidColumnTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/PopulateRulesMetadataRuleUuidColumnTest.java new file mode 100644 index 00000000000..22f0b0c47c6 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/PopulateRulesMetadataRuleUuidColumnTest.java @@ -0,0 +1,85 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.rulesmetadata; + +import java.sql.SQLException; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.api.utils.System2; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.tuple; + +public class PopulateRulesMetadataRuleUuidColumnTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulateRulesMetadataRuleUuidColumnTest.class, "schema.sql"); + + private DataChange underTest = new PopulateRulesMetadataRuleUuidColumn(db.database()); + + @Before + public void setup() { + insertRule(1L, "uuid-rule-1"); + insertRule(2L, "uuid-rule-2"); + insertRule(3L, "uuid-rule-3"); + insertRule(4L, "uuid-rule-4"); + + insertRuleMetadata(1L, "org-1"); + insertRuleMetadata(1L, "org-2"); + insertRuleMetadata(2L, "org-1"); + } + + @Test + public void add_rule_uuid_column() throws SQLException { + underTest.execute(); + + assertThat(db.countSql("select count(*) from rules_metadata")) + .isEqualTo(3); + assertThat(db.select("select rule_id, organization_uuid, rule_uuid from rules_metadata")) + .extracting(m -> m.get("RULE_ID"), m -> m.get("ORGANIZATION_UUID"), m -> m.get("RULE_UUID")) + .containsExactlyInAnyOrder( + tuple(1L, "org-1", "uuid-rule-1"), + tuple(1L, "org-2", "uuid-rule-1"), + tuple(2L, "org-1", "uuid-rule-2")); + } + + private void insertRule(long id, String uuid) { + db.executeInsert("rules", + "id", id, + "uuid", uuid, + "plugin_rule_key", "rk" + id, + "plugin_name", "rn" + id, + "scope", "MAIN", + "is_ad_hoc", false, + "is_external", false); + } + + private void insertRuleMetadata(long ruleId, String organizationUuid) { + db.executeInsert("rules_metadata", + "rule_id", ruleId, + "organization_uuid", organizationUuid, + "created_at", System2.INSTANCE.now(), + "updated_at", System2.INSTANCE.now()); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/AddIndexesToRulesParametersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/AddIndexesToRulesParametersTableTest.java new file mode 100644 index 00000000000..4008547a467 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/AddIndexesToRulesParametersTableTest.java @@ -0,0 +1,53 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.rulesparameters; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +public class AddIndexesToRulesParametersTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddIndexesToRulesParametersTableTest.class, "schema.sql"); + + private MigrationStep underTest = new AddIndexesToRulesParametersTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertIndex("rules_parameters", "rules_parameters_rule_uuid", "rule_uuid"); + db.assertUniqueIndex("rules_parameters", "rules_parameters_unique", "rule_uuid", "name"); + } + + @Test + public void migration_is_re_entrant() throws SQLException { + underTest.execute(); + + // re-entrant + underTest.execute(); + + db.assertIndex("rules_parameters", "rules_parameters_rule_uuid", "rule_uuid"); + db.assertUniqueIndex("rules_parameters", "rules_parameters_unique", "rule_uuid", "name"); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/AddRuleUuidColumnToRulesParametersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/AddRuleUuidColumnToRulesParametersTableTest.java new file mode 100644 index 00000000000..f1247cbc4ff --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/AddRuleUuidColumnToRulesParametersTableTest.java @@ -0,0 +1,78 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.rulesparameters; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddRuleUuidColumnToRulesParametersTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddRuleUuidColumnToRulesParametersTableTest.class, "schema.sql"); + + private DdlChange underTest = new AddRuleUuidColumnToRulesParametersTable(db.database()); + + @Before + public void setup() { + insertRule(1L, "uuid-rule-1"); + insertRule(2L, "uuid-rule-2"); + insertRule(3L, "uuid-rule-3"); + + insertRulesParametersEntry("uuid-rp-1", 1L); + insertRulesParametersEntry("uuid-rp-2", 1L); + insertRulesParametersEntry("uuid-rp-3", 2L); + } + + @Test + public void add_rule_uuid_column() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("rules_parameters", "rule_uuid", Types.VARCHAR, 40, true); + assertThat(db.countSql("select count(*) from rules_parameters")) + .isEqualTo(3); + } + + private void insertRule(long id, String uuid) { + db.executeInsert("rules", + "id", id, + "uuid", uuid, + "plugin_rule_key", "rk" + id, + "plugin_name", "rn" + id, + "scope", "MAIN", + "is_ad_hoc", false, + "is_external", false); + } + + private void insertRulesParametersEntry(String uuid, long ruleId) { + db.executeInsert("rules_parameters", + "uuid", uuid, + "rule_id", ruleId, + "name", "name-" + uuid, + "param_type", "STRING"); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/DropIndexesOnRuleIdColumnOfRulesParametersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/DropIndexesOnRuleIdColumnOfRulesParametersTableTest.java new file mode 100644 index 00000000000..04eb1cb4113 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/DropIndexesOnRuleIdColumnOfRulesParametersTableTest.java @@ -0,0 +1,57 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.rulesparameters; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +public class DropIndexesOnRuleIdColumnOfRulesParametersTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropIndexesOnRuleIdColumnOfRulesParametersTableTest.class, "schema.sql"); + + private MigrationStep underTest = new DropIndexesOnRuleIdColumnOfRulesParametersTable(db.database()); + + @Test + public void execute() throws SQLException { + db.assertTableExists("rules_parameters"); + db.assertIndex("rules_parameters", "rules_parameters_rule_id", "rule_id"); + db.assertUniqueIndex("rules_parameters", "rules_parameters_unique", "rule_id", "name"); + + underTest.execute(); + + db.assertIndexDoesNotExist("rules_parameters", "rules_parameters_rule_id"); + db.assertIndexDoesNotExist("rules_parameters", "rules_parameters_unique"); + } + + @Test + public void migration_is_re_entrant() throws SQLException { + underTest.execute(); + + // re-entrant + underTest.execute(); + + db.assertIndexDoesNotExist("rules_parameters", "rules_parameters_rule_id"); + db.assertIndexDoesNotExist("rules_parameters", "rules_parameters_unique"); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/DropRuleIdColumnOfRulesParametersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/DropRuleIdColumnOfRulesParametersTableTest.java new file mode 100644 index 00000000000..e697a558c05 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/DropRuleIdColumnOfRulesParametersTableTest.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.rulesparameters; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropRuleIdColumnOfRulesParametersTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropRuleIdColumnOfRulesParametersTableTest.class, "schema.sql"); + + private DdlChange underTest = new DropRuleIdColumnOfRulesParametersTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("rules_parameters", "id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/MakeRulesParametersRuleUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/MakeRulesParametersRuleUuidColumnNotNullableTest.java new file mode 100644 index 00000000000..6b6a5773fca --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/MakeRulesParametersRuleUuidColumnNotNullableTest.java @@ -0,0 +1,43 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.rulesparameters; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static java.sql.Types.VARCHAR; + +public class MakeRulesParametersRuleUuidColumnNotNullableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(MakeRulesParametersRuleUuidColumnNotNullableTest.class, "schema.sql"); + + private MigrationStep underTest = new MakeRulesParametersRuleUuidColumnNotNullable(db.database()); + + @Test + public void uuid_column_is_not_null() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("rules_parameters", "rule_uuid", VARCHAR, null, false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/PopulateRulesParametersRuleUuidColumnTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/PopulateRulesParametersRuleUuidColumnTest.java new file mode 100644 index 00000000000..3c85f13992d --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/PopulateRulesParametersRuleUuidColumnTest.java @@ -0,0 +1,83 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rules.rulesparameters; + +import java.sql.SQLException; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.tuple; + +public class PopulateRulesParametersRuleUuidColumnTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulateRulesParametersRuleUuidColumnTest.class, "schema.sql"); + + private DataChange underTest = new PopulateRulesParametersRuleUuidColumn(db.database()); + + @Before + public void setup() { + insertRule(1L, "uuid-rule-1"); + insertRule(2L, "uuid-rule-2"); + insertRule(3L, "uuid-rule-3"); + + insertRulesParametersEntry("uuid-rp-1", 1L); + insertRulesParametersEntry("uuid-rp-2", 1L); + insertRulesParametersEntry("uuid-rp-3", 2L); + } + + @Test + public void add_rule_uuid_column() throws SQLException { + underTest.execute(); + + assertThat(db.countSql("select count(*) from rules_parameters")) + .isEqualTo(3); + assertThat(db.select("select uuid, rule_id, rule_uuid from rules_parameters")) + .extracting(m -> m.get("UUID"), m -> m.get("RULE_ID"), m -> m.get("RULE_UUID")) + .containsExactlyInAnyOrder( + tuple("uuid-rp-1", 1L, "uuid-rule-1"), + tuple("uuid-rp-2", 1L, "uuid-rule-1"), + tuple("uuid-rp-3", 2L, "uuid-rule-2")); + } + + private void insertRule(long id, String uuid) { + db.executeInsert("rules", + "id", id, + "uuid", uuid, + "plugin_rule_key", "rk" + id, + "plugin_name", "rn" + id, + "scope", "MAIN", + "is_ad_hoc", false, + "is_external", false); + } + + private void insertRulesParametersEntry(String uuid, long ruleId) { + db.executeInsert("rules_parameters", + "uuid", uuid, + "rule_id", ruleId, + "name", "name-" + uuid, + "param_type", "STRING"); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddPrimaryKeyOnUuidColumnOfRulesParametersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddPrimaryKeyOnUuidColumnOfRulesParametersTableTest.java new file mode 100644 index 00000000000..944fff9cd9a --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddPrimaryKeyOnUuidColumnOfRulesParametersTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesparameters; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class AddPrimaryKeyOnUuidColumnOfRulesParametersTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfRulesParametersTableTest.class, "schema.sql"); + + private MigrationStep underTest = new AddPrimaryKeyOnUuidColumnOfRulesParametersTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertPrimaryKey("rules_parameters", "pk_rules_parameters", "uuid"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddUuidColumnToRulesParametersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddUuidColumnToRulesParametersTest.java new file mode 100644 index 00000000000..82cef37204e --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddUuidColumnToRulesParametersTest.java @@ -0,0 +1,67 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesparameters; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.UuidFactory; +import org.sonar.core.util.UuidFactoryFast; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddUuidColumnToRulesParametersTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToRulesParametersTest.class, "schema.sql"); + + private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); + + private DdlChange underTest = new AddUuidColumnToRulesParameters(db.database()); + + @Before + public void setup() { + insertRuleParameter(1L); + insertRuleParameter(2L); + insertRuleParameter(3L); + } + + @Test + public void add_uuid_column_to_project_measures() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("rules_parameters", "uuid", Types.VARCHAR, 40, true); + + assertThat(db.countSql("select count(id) from rules_parameters")) + .isEqualTo(3); + } + + private void insertRuleParameter(Long id) { + db.executeInsert("rules_parameters", + "id", id, + "rule_id", id + 100, + "name", uuidFactory.create(), + "param_type", uuidFactory.create()); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropIdColumnOfRulesParametersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropIdColumnOfRulesParametersTableTest.java new file mode 100644 index 00000000000..c3ed4c5d3a1 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropIdColumnOfRulesParametersTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesparameters; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropIdColumnOfRulesParametersTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfRulesParametersTableTest.class, "schema.sql"); + + private MigrationStep underTest = new DropIdColumnOfRulesParametersTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("rules_parameters", "id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropPrimaryKeyOnIdColumnOfRulesParametersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropPrimaryKeyOnIdColumnOfRulesParametersTableTest.java new file mode 100644 index 00000000000..6cf0cdab750 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropPrimaryKeyOnIdColumnOfRulesParametersTableTest.java @@ -0,0 +1,56 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesparameters; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; +import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropPrimaryKeyOnIdColumnOfRulesParametersTableTest { + + private static final String TABLE_NAME = "rules_parameters"; + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfRulesParametersTableTest.class, "schema.sql"); + + private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + + private MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfRulesParametersTable(db.database(), dropPrimaryKeySqlGenerator); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertNoPrimaryKey(TABLE_NAME); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/MakeRulesParametersUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/MakeRulesParametersUuidColumnNotNullableTest.java new file mode 100644 index 00000000000..4cdd324feb0 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/MakeRulesParametersUuidColumnNotNullableTest.java @@ -0,0 +1,43 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesparameters; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static java.sql.Types.VARCHAR; + +public class MakeRulesParametersUuidColumnNotNullableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(MakeRulesParametersUuidColumnNotNullableTest.class, "schema.sql"); + + private MigrationStep underTest = new MakeRulesParametersUuidColumnNotNullable(db.database()); + + @Test + public void uuid_column_is_not_null() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("rules_parameters", "uuid", VARCHAR, null, false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/PopulateRulesParametersUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/PopulateRulesParametersUuidTest.java new file mode 100644 index 00000000000..8e837ebea46 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/PopulateRulesParametersUuidTest.java @@ -0,0 +1,82 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesparameters; + +import java.sql.SQLException; +import java.util.Objects; +import java.util.stream.Collectors; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.UuidFactory; +import org.sonar.core.util.UuidFactoryFast; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulateRulesParametersUuidTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulateRulesParametersUuidTest.class, "schema.sql"); + + private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); + private DataChange underTest = new PopulateRulesParametersUuid(db.database(), uuidFactory); + + @Test + public void populate_uuids_and_created_at() throws SQLException { + insertRuleParameter(1L); + insertRuleParameter(2L); + insertRuleParameter(3L); + + underTest.execute(); + + verifyUuidsAreNotNull(); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertRuleParameter(1L); + insertRuleParameter(2L); + insertRuleParameter(3L); + + underTest.execute(); + // re-entrant + underTest.execute(); + + verifyUuidsAreNotNull(); + } + + private void verifyUuidsAreNotNull() { + assertThat(db.select("select uuid from rules_parameters") + .stream() + .map(row -> row.get("UUID")) + .filter(Objects::isNull) + .collect(Collectors.toList())).isEmpty(); + } + + private void insertRuleParameter(Long id) { + db.executeInsert("rules_parameters", + "id", id, + "rule_id", id + 100, + "name", uuidFactory.create(), + "param_type", uuidFactory.create()); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/AddRulesParameterUuidColumnToActiveRuleParametersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/AddRulesParameterUuidColumnToActiveRuleParametersTest.java new file mode 100644 index 00000000000..a3b9674a6b4 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/AddRulesParameterUuidColumnToActiveRuleParametersTest.java @@ -0,0 +1,66 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesparameters.fk; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.UuidFactory; +import org.sonar.core.util.UuidFactoryFast; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddRulesParameterUuidColumnToActiveRuleParametersTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddRulesParameterUuidColumnToActiveRuleParametersTest.class, "schema.sql"); + + private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); + + private DdlChange underTest = new AddRulesParameterUuidColumnToActiveRuleParameters(db.database()); + + @Before + public void setup() { + insertActiveRuleParameter(uuidFactory.create(), 1L, 4L); + insertActiveRuleParameter(uuidFactory.create(), 2L, 5L); + insertActiveRuleParameter(uuidFactory.create(), 3L, 6L); + } + + @Test + public void add_rules_parameter_uuid_column_to_active_rule_parameters() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("active_rule_parameters", "rules_parameter_uuid", Types.VARCHAR, 40, true); + + assertThat(db.countRowsOfTable("active_rule_parameters")) + .isEqualTo(3); + } + + private void insertActiveRuleParameter(String uuid, Long ruleId, Long rulesParameterId) { + db.executeInsert("active_rule_parameters", + "uuid", uuid, + "active_rule_id", ruleId, + "rules_parameter_id", rulesParameterId); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/DropRulesParameterIdColumnOfActiveRuleParametersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/DropRulesParameterIdColumnOfActiveRuleParametersTableTest.java new file mode 100644 index 00000000000..a1a7c32019c --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/DropRulesParameterIdColumnOfActiveRuleParametersTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesparameters.fk; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropRulesParameterIdColumnOfActiveRuleParametersTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropRulesParameterIdColumnOfActiveRuleParametersTableTest.class, "schema.sql"); + + private MigrationStep underTest = new DropRulesParameterIdColumnOfActiveRuleParametersTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("active_rule_parameters", "rules_parameter_id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/MakeActiveRuleParametersRulesParameterUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/MakeActiveRuleParametersRulesParameterUuidColumnNotNullableTest.java new file mode 100644 index 00000000000..a6de662fe9e --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/MakeActiveRuleParametersRulesParameterUuidColumnNotNullableTest.java @@ -0,0 +1,43 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesparameters.fk; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static java.sql.Types.VARCHAR; + +public class MakeActiveRuleParametersRulesParameterUuidColumnNotNullableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(MakeActiveRuleParametersRulesParameterUuidColumnNotNullableTest.class, "schema.sql"); + + private MigrationStep underTest = new MakeActiveRuleParametersRulesParameterUuidColumnNotNullable(db.database()); + + @Test + public void uuid_column_is_not_null() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("active_rule_parameters", "rules_parameter_uuid", VARCHAR, null, false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/PopulateActiveRuleParametersRulesParameterUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/PopulateActiveRuleParametersRulesParameterUuidTest.java new file mode 100644 index 00000000000..e22eedcccc4 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/PopulateActiveRuleParametersRulesParameterUuidTest.java @@ -0,0 +1,127 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesparameters.fk; + +import java.sql.SQLException; +import java.util.Objects; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.UuidFactory; +import org.sonar.core.util.UuidFactoryFast; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static java.lang.String.format; +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulateActiveRuleParametersRulesParameterUuidTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulateActiveRuleParametersRulesParameterUuidTest.class, "schema.sql"); + + private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); + private DataChange underTest = new PopulateActiveRuleParametersRulesParameterUuid(db.database()); + + @Test + public void populate_rules_parameter_uuids() throws SQLException { + String ruleParamUuid1 = uuidFactory.create(); + long ruleParamId1 = 1L; + insertRuleParameter(ruleParamId1, ruleParamUuid1, 101L); + String activeRuleParameter11 = insertActiveRuleParameter(101L, ruleParamId1); + String activeRuleParameter12 = insertActiveRuleParameter(101L, ruleParamId1); + String activeRuleParameter13 = insertActiveRuleParameter(101L, ruleParamId1); + + String ruleParamUuid2 = uuidFactory.create(); + long ruleParamId2 = 2L; + insertRuleParameter(ruleParamId2, ruleParamUuid2, 101L); + String activeRuleParameter21 = insertActiveRuleParameter(101L, ruleParamId2); + String activeRuleParameter22 = insertActiveRuleParameter(101L, ruleParamId2); + + insertRuleParameter(3L, uuidFactory.create(), 101L); + + underTest.execute(); + + assertRulesParameterUuidsAreNotNull(); + assertThatRulesParametersUuidAreSet(ruleParamUuid1, activeRuleParameter11, activeRuleParameter12, activeRuleParameter13); + assertThatRulesParametersUuidAreSet(ruleParamUuid2, activeRuleParameter21, activeRuleParameter22); + } + + @Test + public void migration_is_reentrant() throws SQLException { + String ruleParamUuid1 = uuidFactory.create(); + long ruleParamId1 = 1L; + insertRuleParameter(ruleParamId1, ruleParamUuid1, 101L); + String activeRuleParameter11 = insertActiveRuleParameter(101L, ruleParamId1); + String activeRuleParameter12 = insertActiveRuleParameter(101L, ruleParamId1); + String activeRuleParameter13 = insertActiveRuleParameter(101L, ruleParamId1); + + underTest.execute(); + + String ruleParamUuid2 = uuidFactory.create(); + long ruleParamId2 = 2L; + insertRuleParameter(ruleParamId2, ruleParamUuid2, 101L); + String activeRuleParameter21 = insertActiveRuleParameter(101L, ruleParamId2); + String activeRuleParameter22 = insertActiveRuleParameter(101L, ruleParamId2); + // re-entrant + underTest.execute(); + + assertRulesParameterUuidsAreNotNull(); + assertThatRulesParametersUuidAreSet(ruleParamUuid1, activeRuleParameter11, activeRuleParameter12, activeRuleParameter13); + assertThatRulesParametersUuidAreSet(ruleParamUuid2, activeRuleParameter21, activeRuleParameter22); + } + + private void assertThatRulesParametersUuidAreSet(String ruleParameterUuid, String... activeRuleParameters) { + assertThat(db.select("select rules_parameter_uuid from active_rule_parameters where uuid in (" + + Stream.of(activeRuleParameters).map(s -> format("'%s'", s)).collect(Collectors.joining(",")) + ")") + .stream() + .map(row -> row.get("RULES_PARAMETER_UUID")) + .filter(o -> !Objects.equals(o, ruleParameterUuid)) + .collect(Collectors.toList())).isEmpty(); + } + + private void assertRulesParameterUuidsAreNotNull() { + assertThat(db.select("select rules_parameter_uuid from active_rule_parameters") + .stream() + .map(row -> row.get("RULES_PARAMETER_UUID")) + .filter(Objects::isNull) + .collect(Collectors.toList())).isEmpty(); + } + + private void insertRuleParameter(Long id, String uuid, Long ruleId) { + db.executeInsert("rules_parameters", + "id", id, + "uuid", uuid, + "rule_id", ruleId, + "name", uuidFactory.create(), + "param_type", uuidFactory.create()); + } + + private String insertActiveRuleParameter(Long ruleId, Long rulesParameterId) { + String uuid = uuidFactory.create(); + db.executeInsert("active_rule_parameters", + "uuid", uuid, + "active_rule_id", ruleId, + "rules_parameter_id", rulesParameterId); + return uuid; + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddPrimaryKeyOnUuidColumnOfRulesProfilesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddPrimaryKeyOnUuidColumnOfRulesProfilesTableTest.java new file mode 100644 index 00000000000..3a6b7152946 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddPrimaryKeyOnUuidColumnOfRulesProfilesTableTest.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesprofiles; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class AddPrimaryKeyOnUuidColumnOfRulesProfilesTableTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfRulesProfilesTableTest.class, "schema.sql"); + + private DdlChange underTest = new AddPrimaryKeyOnUuidColumnOfRulesProfilesTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertPrimaryKey("rules_profiles", "pk_rules_profiles", "uuid"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddUuidColumnToRulesProfilesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddUuidColumnToRulesProfilesTableTest.java new file mode 100644 index 00000000000..2b12f3e0356 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddUuidColumnToRulesProfilesTableTest.java @@ -0,0 +1,67 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesprofiles; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.UuidFactory; +import org.sonar.core.util.UuidFactoryFast; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddUuidColumnToRulesProfilesTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToRulesProfilesTableTest.class, "schema.sql"); + + private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); + + private DdlChange underTest = new AddUuidColumnToRulesProfilesTable(db.database()); + + @Before + public void setup() { + insertRuleProfile(1L); + insertRuleProfile(2L); + insertRuleProfile(3L); + } + + @Test + public void add_uuid_column_to_rules_profiles() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("rules_profiles", "uuid", Types.VARCHAR, 40, true); + + assertThat(db.countSql("select count(id) from rules_profiles")) + .isEqualTo(3); + } + + private void insertRuleProfile(Long id) { + db.executeInsert("rules_profiles", + "id", id, + "name", "name" + id, + "kee", "kee" + id, + "is_built_in", false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropIdColumnOfRulesProfilesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropIdColumnOfRulesProfilesTableTest.java new file mode 100644 index 00000000000..3d480f69d1f --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropIdColumnOfRulesProfilesTableTest.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesprofiles; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropIdColumnOfRulesProfilesTableTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfRulesProfilesTableTest.class, "schema.sql"); + + private DdlChange underTest = new DropIdColumnOfRulesProfilesTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("rules_profiles", "id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropKeeColumnOfRulesProfilesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropKeeColumnOfRulesProfilesTableTest.java new file mode 100644 index 00000000000..ac060eeb559 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropKeeColumnOfRulesProfilesTableTest.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesprofiles; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropKeeColumnOfRulesProfilesTableTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropKeeColumnOfRulesProfilesTableTest.class, "schema.sql"); + + private DdlChange underTest = new DropKeeColumnOfRulesProfilesTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("rules_profiles", "kee"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropPrimaryKeyOnIdColumnOfRulesProfilesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropPrimaryKeyOnIdColumnOfRulesProfilesTableTest.java new file mode 100644 index 00000000000..ad2dbeed17d --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropPrimaryKeyOnIdColumnOfRulesProfilesTableTest.java @@ -0,0 +1,54 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesprofiles; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; +import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropPrimaryKeyOnIdColumnOfRulesProfilesTableTest { + private static final String TABLE_NAME = "rules_profiles"; + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfRulesProfilesTableTest.class, "schema.sql"); + + private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + + private DdlChange underTest = new DropPrimaryKeyOnIdColumnOfRulesProfilesTable(db.database(), dropPrimaryKeySqlGenerator); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertNoPrimaryKey(TABLE_NAME); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropUniqueIndexOnKeeColumnOfRulesProfilesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropUniqueIndexOnKeeColumnOfRulesProfilesTableTest.java new file mode 100644 index 00000000000..681db474027 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropUniqueIndexOnKeeColumnOfRulesProfilesTableTest.java @@ -0,0 +1,54 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesprofiles; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropUniqueIndexOnKeeColumnOfRulesProfilesTableTest { + + private static final String TABLE_NAME = "rules_profiles"; + private static final String INDEX_NAME = "uniq_qprof_key"; + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropUniqueIndexOnKeeColumnOfRulesProfilesTableTest.class, "schema.sql"); + + private DdlChange underTest = new DropUniqueIndexOnKeeColumnOfRulesProfilesTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); + } + + @Test + public void migration_is_re_entrant() throws SQLException { + underTest.execute(); + // migration is re-entrant + underTest.execute(); + + db.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/MakeRulesProfilesUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/MakeRulesProfilesUuidColumnNotNullableTest.java new file mode 100644 index 00000000000..c8603b62922 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/MakeRulesProfilesUuidColumnNotNullableTest.java @@ -0,0 +1,43 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesprofiles; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static java.sql.Types.VARCHAR; + +public class MakeRulesProfilesUuidColumnNotNullableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(MakeRulesProfilesUuidColumnNotNullableTest.class, "schema.sql"); + + private MigrationStep underTest = new MakeRulesProfilesUuidColumnNotNullable(db.database()); + + @Test + public void uuid_column_is_not_null() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("rules_profiles", "uuid", VARCHAR, null, false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/PopulateRulesProfilesUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/PopulateRulesProfilesUuidTest.java new file mode 100644 index 00000000000..89ee33c8dfb --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/PopulateRulesProfilesUuidTest.java @@ -0,0 +1,81 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesprofiles; + +import java.sql.SQLException; +import java.util.Objects; +import java.util.stream.Collectors; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.UuidFactory; +import org.sonar.core.util.UuidFactoryFast; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulateRulesProfilesUuidTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulateRulesProfilesUuidTest.class, "schema.sql"); + + private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); + private DataChange underTest = new PopulateRulesProfilesUuid(db.database(), uuidFactory); + + @Test + public void populate_uuids() throws SQLException { + insertRuleProfile(1L); + insertRuleProfile(2L); + insertRuleProfile(3L); + + underTest.execute(); + + verifyUuidsAreNotNull(); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertRuleProfile(1L); + insertRuleProfile(2L); + insertRuleProfile(3L); + + underTest.execute(); + // re-entrant + underTest.execute(); + + verifyUuidsAreNotNull(); + } + + private void verifyUuidsAreNotNull() { + assertThat(db.select("select uuid from rules_profiles") + .stream() + .map(row -> row.get("UUID")) + .filter(Objects::isNull) + .collect(Collectors.toList())).isEmpty(); + } + + private void insertRuleProfile(Long id) { + db.executeInsert("rules_profiles", + "id", id, + "name", "name" + id, + "kee", "kee" + id, + "is_built_in", false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/AddProfileUuidColumnToActiveRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/AddProfileUuidColumnToActiveRulesTableTest.java new file mode 100644 index 00000000000..03033605c22 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/AddProfileUuidColumnToActiveRulesTableTest.java @@ -0,0 +1,63 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.activerules; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddProfileUuidColumnToActiveRulesTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddProfileUuidColumnToActiveRulesTableTest.class, "schema.sql"); + + private DdlChange underTest = new AddProfileUuidColumnToActiveRulesTable(db.database()); + + @Before + public void setup() { + insertActiveRule("1", 1L, 2L); + insertActiveRule("2", 3L, 4L); + insertActiveRule("3", 5L, 6L); + } + + @Test + public void add_uuid_column_to_rules_profiles() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("active_rules", "profile_uuid", Types.VARCHAR, 40, true); + + assertThat(db.countRowsOfTable("active_rules")) + .isEqualTo(3); + } + + private void insertActiveRule(String uuid, long profileId, long rule_id) { + db.executeInsert("active_rules", + "uuid", uuid, + "profile_id", profileId, + "rule_id", rule_id, + "failure_level", 3); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/AddUniqueIndexOnProfileUuidColumnOfActiveRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/AddUniqueIndexOnProfileUuidColumnOfActiveRulesTableTest.java new file mode 100644 index 00000000000..c6916f94089 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/AddUniqueIndexOnProfileUuidColumnOfActiveRulesTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.activerules; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +public class AddUniqueIndexOnProfileUuidColumnOfActiveRulesTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddUniqueIndexOnProfileUuidColumnOfActiveRulesTableTest.class, "schema.sql"); + + private MigrationStep underTest = new AddUniqueIndexOnProfileUuidColumnOfActiveRulesTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertUniqueIndex("active_rules", "uniq_profile_rule_ids", "profile_uuid", "rule_id"); + } + + @Test + public void migration_is_re_entrant() throws SQLException { + underTest.execute(); + // re-entrant + underTest.execute(); + + db.assertUniqueIndex("active_rules", "uniq_profile_rule_ids", "profile_uuid", "rule_id"); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/DropProfileIdColumnOfActiveRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/DropProfileIdColumnOfActiveRulesTableTest.java new file mode 100644 index 00000000000..a9134033e58 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/DropProfileIdColumnOfActiveRulesTableTest.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.activerules; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropProfileIdColumnOfActiveRulesTableTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropProfileIdColumnOfActiveRulesTableTest.class, "schema.sql"); + + private DdlChange underTest = new DropProfileIdColumnOfActiveRulesTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("active_rules", "profile_id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/DropUniqueIndexOnProfileIdColumnOfActiveRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/DropUniqueIndexOnProfileIdColumnOfActiveRulesTableTest.java new file mode 100644 index 00000000000..e029e54093d --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/DropUniqueIndexOnProfileIdColumnOfActiveRulesTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.activerules; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +public class DropUniqueIndexOnProfileIdColumnOfActiveRulesTableTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropUniqueIndexOnProfileIdColumnOfActiveRulesTableTest.class, "schema.sql"); + + private MigrationStep underTest = new DropUniqueIndexOnProfileIdColumnOfActiveRulesTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertIndexDoesNotExist("perm_tpl_characteristics", "uniq_perm_tpl_charac"); + } + + @Test + public void migration_is_re_entrant() throws SQLException { + underTest.execute(); + + // re-entrant + underTest.execute(); + + db.assertIndexDoesNotExist("perm_tpl_characteristics", "uniq_perm_tpl_charac"); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/MakeActiveRulesProfileUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/MakeActiveRulesProfileUuidColumnNotNullableTest.java new file mode 100644 index 00000000000..ec0db0a37a5 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/MakeActiveRulesProfileUuidColumnNotNullableTest.java @@ -0,0 +1,43 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.activerules; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static java.sql.Types.VARCHAR; + +public class MakeActiveRulesProfileUuidColumnNotNullableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(MakeActiveRulesProfileUuidColumnNotNullableTest.class, "schema.sql"); + + private MigrationStep underTest = new MakeActiveRulesProfileUuidColumnNotNullable(db.database()); + + @Test + public void uuid_column_is_not_null() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("active_rules", "profile_uuid", VARCHAR, null, false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/PopulateActiveRulesProfileUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/PopulateActiveRulesProfileUuidTest.java new file mode 100644 index 00000000000..f4721800f4b --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/PopulateActiveRulesProfileUuidTest.java @@ -0,0 +1,113 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.activerules; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulateActiveRulesProfileUuidTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulateActiveRulesProfileUuidTest.class, "schema.sql"); + + private DataChange underTest = new PopulateActiveRulesProfileUuid(db.database()); + + @Test + public void populate_uuids() throws SQLException { + long ruleProfileId_1 = 1L; + String ruleProfileUuid_1 = "uuid-1"; + insertRuleProfile(ruleProfileId_1, ruleProfileUuid_1); + + long ruleProfileId_2 = 2L; + String ruleProfileUuid_2 = "uuid-2"; + insertRuleProfile(ruleProfileId_2, ruleProfileUuid_2); + + long ruleProfileId_3 = 3L; + String ruleProfileUuid_3 = "uuid-3"; + insertRuleProfile(ruleProfileId_3, ruleProfileUuid_3); + + insertActiveRule("4", ruleProfileId_1); + insertActiveRule("5", ruleProfileId_2); + insertActiveRule("6", ruleProfileId_3); + + underTest.execute(); + + assertThatActiveRulesProfileUuidIsEqualTo("4", ruleProfileUuid_1); + assertThatActiveRulesProfileUuidIsEqualTo("5", ruleProfileUuid_2); + assertThatActiveRulesProfileUuidIsEqualTo("6", ruleProfileUuid_3); + } + + @Test + public void migration_is_reentrant() throws SQLException { + long ruleProfileId_1 = 1L; + String ruleProfileUuid_1 = "uuid-1"; + insertRuleProfile(ruleProfileId_1, ruleProfileUuid_1); + + long ruleProfileId_2 = 2L; + String ruleProfileUuid_2 = "uuid-2"; + insertRuleProfile(ruleProfileId_2, ruleProfileUuid_2); + + long ruleProfileId_3 = 3L; + String ruleProfileUuid_3 = "uuid-3"; + insertRuleProfile(ruleProfileId_3, ruleProfileUuid_3); + + insertActiveRule("4", ruleProfileId_1); + insertActiveRule("5", ruleProfileId_2); + insertActiveRule("6", ruleProfileId_3); + + underTest.execute(); + // re-entrant + underTest.execute(); + + assertThatActiveRulesProfileUuidIsEqualTo("4", ruleProfileUuid_1); + assertThatActiveRulesProfileUuidIsEqualTo("5", ruleProfileUuid_2); + assertThatActiveRulesProfileUuidIsEqualTo("6", ruleProfileUuid_3); + } + + private void assertThatActiveRulesProfileUuidIsEqualTo(String uuid, String expectedUuid) { + assertThat(db.select("select profile_uuid from active_rules where uuid = '" + uuid + "'") + .stream() + .map(row -> row.get("PROFILE_UUID")) + .findFirst()) + .hasValue(expectedUuid); + } + + private void insertActiveRule(String uuid, Long profileId) { + db.executeInsert("active_rules", + "uuid", uuid, + "profile_id", profileId, + "rule_id", 1, + "failure_level", 2); + } + + private void insertRuleProfile(Long id, String uuid) { + db.executeInsert("rules_profiles", + "id", id, + "uuid", uuid, + "name", "name" + id, + "kee", "kee" + id, + "is_built_in", false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/orgqprofiles/PopulateOrgQProfilesRulesProfileUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/orgqprofiles/PopulateOrgQProfilesRulesProfileUuidTest.java new file mode 100644 index 00000000000..4bd1182a8e3 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/orgqprofiles/PopulateOrgQProfilesRulesProfileUuidTest.java @@ -0,0 +1,137 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.orgqprofiles; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.Uuids; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulateOrgQProfilesRulesProfileUuidTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulateOrgQProfilesRulesProfileUuidTest.class, "schema.sql"); + + private DataChange underTest = new PopulateOrgQProfilesRulesProfileUuid(db.database()); + + @Test + public void populate_uuids() throws SQLException { + long ruleProfileId_1 = 1L; + String ruleProfileUuid_1 = "uuid-1"; + String ruleProfileKee_1 = "kee-1"; + insertRuleProfile(ruleProfileId_1, ruleProfileUuid_1, ruleProfileKee_1); + + long ruleProfileId_2 = 2L; + String ruleProfileUuid_2 = "uuid-2"; + String ruleProfileKee_2 = "kee-2"; + insertRuleProfile(ruleProfileId_2, ruleProfileUuid_2, ruleProfileKee_2); + + long ruleProfileId_3 = 3L; + String ruleProfileUuid_3 = "uuid-3"; + String ruleProfileKee_3 = "kee-3"; + insertRuleProfile(ruleProfileId_3, ruleProfileUuid_3, ruleProfileKee_3); + + String orgQProfileUuid_1 = "orgQProfileUuid_1"; + insertOrgQProfiles(orgQProfileUuid_1, ruleProfileKee_1); + String orgQProfileUuid_2 = "orgQProfileUuid_2"; + insertOrgQProfiles(orgQProfileUuid_2, ruleProfileKee_2); + String orgQProfileUuid_3 = "orgQProfileUuid_3"; + insertOrgQProfiles(orgQProfileUuid_3, ruleProfileKee_3); + + underTest.execute(); + + assertThatOrgQprofileRulesProfileUuidIsEqualTo(orgQProfileUuid_1, ruleProfileUuid_1); + assertThatOrgQprofileRulesProfileUuidIsEqualTo(orgQProfileUuid_2, ruleProfileUuid_2); + assertThatOrgQprofileRulesProfileUuidIsEqualTo(orgQProfileUuid_3, ruleProfileUuid_3); + } + + @Test + public void migration_is_reentrant() throws SQLException { + long ruleProfileId_1 = 1L; + String ruleProfileUuid_1 = "uuid-1"; + String ruleProfileKee_1 = "kee-1"; + insertRuleProfile(ruleProfileId_1, ruleProfileUuid_1, ruleProfileKee_1); + + long ruleProfileId_2 = 2L; + String ruleProfileUuid_2 = "uuid-2"; + String ruleProfileKee_2 = "kee-2"; + insertRuleProfile(ruleProfileId_2, ruleProfileUuid_2, ruleProfileKee_2); + + long ruleProfileId_3 = 3L; + String ruleProfileUuid_3 = "uuid-3"; + String ruleProfileKee_3 = "kee-3"; + insertRuleProfile(ruleProfileId_3, ruleProfileUuid_3, ruleProfileKee_3); + + String orgQProfileUuid_1 = "orgQProfileUuid_1"; + insertOrgQProfiles(orgQProfileUuid_1, ruleProfileKee_1); + String orgQProfileUuid_2 = "orgQProfileUuid_2"; + insertOrgQProfiles(orgQProfileUuid_2, ruleProfileKee_2); + String orgQProfileUuid_3 = "orgQProfileUuid_3"; + insertOrgQProfiles(orgQProfileUuid_3, ruleProfileKee_3); + + underTest.execute(); + + long ruleProfileId_4 = 4L; + String ruleProfileUuid_4 = "uuid-4"; + String ruleProfileKee_4 = "kee-4"; + insertRuleProfile(ruleProfileId_4, ruleProfileUuid_4, ruleProfileKee_4); + + String orgQProfileUuid_4 = "orgQProfileUuid_4"; + insertOrgQProfiles(orgQProfileUuid_4, ruleProfileKee_4); + + // re-entrant + underTest.execute(); + + assertThatOrgQprofileRulesProfileUuidIsEqualTo(orgQProfileUuid_1, ruleProfileUuid_1); + assertThatOrgQprofileRulesProfileUuidIsEqualTo(orgQProfileUuid_2, ruleProfileUuid_2); + assertThatOrgQprofileRulesProfileUuidIsEqualTo(orgQProfileUuid_3, ruleProfileUuid_3); + assertThatOrgQprofileRulesProfileUuidIsEqualTo(orgQProfileUuid_4, ruleProfileUuid_4); + } + + private void assertThatOrgQprofileRulesProfileUuidIsEqualTo(String orgQprofileUuid, String expectedUuid) { + assertThat(db.select("select rules_profile_uuid from org_qprofiles where uuid = '" + orgQprofileUuid + "'") + .stream() + .map(row -> row.get("RULES_PROFILE_UUID")) + .findFirst()) + .hasValue(expectedUuid); + } + + private void insertOrgQProfiles(String uuid, String rulesProfileUuid) { + db.executeInsert("org_qprofiles", + "uuid", uuid, + "organization_uuid", Uuids.createFast(), + "rules_profile_uuid", rulesProfileUuid, + "created_at", System.currentTimeMillis(), + "updated_at", System.currentTimeMillis()); + } + + private void insertRuleProfile(Long id, String uuid, String kee) { + db.executeInsert("rules_profiles", + "id", id, + "uuid", uuid, + "name", "name" + id, + "kee", kee, + "is_built_in", false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/qprofilechanges/PopulateQProfileChangesRulesProfileUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/qprofilechanges/PopulateQProfileChangesRulesProfileUuidTest.java new file mode 100644 index 00000000000..b7b17a8d757 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/qprofilechanges/PopulateQProfileChangesRulesProfileUuidTest.java @@ -0,0 +1,136 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.rulesprofiles.fk.qprofilechanges; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.Uuids; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulateQProfileChangesRulesProfileUuidTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulateQProfileChangesRulesProfileUuidTest.class, "schema.sql"); + + private DataChange underTest = new PopulateQProfileChangesRulesProfileUuid(db.database()); + + @Test + public void populate_uuids() throws SQLException { + long ruleProfileId_1 = 1L; + String ruleProfileUuid_1 = "uuid-1"; + String ruleProfileKee_1 = "kee-1"; + insertRuleProfile(ruleProfileId_1, ruleProfileUuid_1, ruleProfileKee_1); + + long ruleProfileId_2 = 2L; + String ruleProfileUuid_2 = "uuid-2"; + String ruleProfileKee_2 = "kee-2"; + insertRuleProfile(ruleProfileId_2, ruleProfileUuid_2, ruleProfileKee_2); + + long ruleProfileId_3 = 3L; + String ruleProfileUuid_3 = "uuid-3"; + String ruleProfileKee_3 = "kee-3"; + insertRuleProfile(ruleProfileId_3, ruleProfileUuid_3, ruleProfileKee_3); + + String qProfileChangeUuid_1 = "qProfileChangeUuid_1"; + insertQProfileChange(qProfileChangeUuid_1, ruleProfileKee_1); + String qProfileChangeUuid_2 = "qProfileChangeUuid_2"; + insertQProfileChange(qProfileChangeUuid_2, ruleProfileKee_2); + String qProfileChangeUuid_3 = "qProfileChangeUuid_3"; + insertQProfileChange(qProfileChangeUuid_3, ruleProfileKee_3); + + underTest.execute(); + + assertThatQProfileChangeRulesProfileUuidIsEqualTo(qProfileChangeUuid_1, ruleProfileUuid_1); + assertThatQProfileChangeRulesProfileUuidIsEqualTo(qProfileChangeUuid_2, ruleProfileUuid_2); + assertThatQProfileChangeRulesProfileUuidIsEqualTo(qProfileChangeUuid_3, ruleProfileUuid_3); + } + + @Test + public void migration_is_reentrant() throws SQLException { + long ruleProfileId_1 = 1L; + String ruleProfileUuid_1 = "uuid-1"; + String ruleProfileKee_1 = "kee-1"; + insertRuleProfile(ruleProfileId_1, ruleProfileUuid_1, ruleProfileKee_1); + + long ruleProfileId_2 = 2L; + String ruleProfileUuid_2 = "uuid-2"; + String ruleProfileKee_2 = "kee-2"; + insertRuleProfile(ruleProfileId_2, ruleProfileUuid_2, ruleProfileKee_2); + + long ruleProfileId_3 = 3L; + String ruleProfileUuid_3 = "uuid-3"; + String ruleProfileKee_3 = "kee-3"; + insertRuleProfile(ruleProfileId_3, ruleProfileUuid_3, ruleProfileKee_3); + + String qProfileChangeUuid_1 = "qProfileChangeUuid_1"; + insertQProfileChange(qProfileChangeUuid_1, ruleProfileKee_1); + String qProfileChangeUuid_2 = "qProfileChangeUuid_2"; + insertQProfileChange(qProfileChangeUuid_2, ruleProfileKee_2); + String qProfileChangeUuid_3 = "qProfileChangeUuid_3"; + insertQProfileChange(qProfileChangeUuid_3, ruleProfileKee_3); + + underTest.execute(); + + long ruleProfileId_4 = 4L; + String ruleProfileUuid_4 = "uuid-4"; + String ruleProfileKee_4 = "kee-4"; + insertRuleProfile(ruleProfileId_4, ruleProfileUuid_4, ruleProfileKee_4); + + String qProfileChangeUuid_4 = "qProfileChangeUuid_4"; + insertQProfileChange(qProfileChangeUuid_4, ruleProfileKee_4); + + // re-entrant + underTest.execute(); + + assertThatQProfileChangeRulesProfileUuidIsEqualTo(qProfileChangeUuid_1, ruleProfileUuid_1); + assertThatQProfileChangeRulesProfileUuidIsEqualTo(qProfileChangeUuid_2, ruleProfileUuid_2); + assertThatQProfileChangeRulesProfileUuidIsEqualTo(qProfileChangeUuid_3, ruleProfileUuid_3); + assertThatQProfileChangeRulesProfileUuidIsEqualTo(qProfileChangeUuid_4, ruleProfileUuid_4); + } + + private void assertThatQProfileChangeRulesProfileUuidIsEqualTo(String qProfileChangeKee, String expectedUuid) { + assertThat(db.select("select rules_profile_uuid from qprofile_changes where kee = '" + qProfileChangeKee + "'") + .stream() + .map(row -> row.get("RULES_PROFILE_UUID")) + .findFirst()) + .hasValue(expectedUuid); + } + + private void insertQProfileChange(String kee, String rulesProfileUuid) { + db.executeInsert("qprofile_changes", + "kee", kee, + "change_type", Uuids.createFast(), + "rules_profile_uuid", rulesProfileUuid, + "created_at", System.currentTimeMillis()); + } + + private void insertRuleProfile(Long id, String uuid, String kee) { + db.executeInsert("rules_profiles", + "id", id, + "uuid", uuid, + "name", "name" + id, + "kee", kee, + "is_built_in", false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/snapshots/AddPrimaryKeyOnUuidColumnOfSnapshotsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/snapshots/AddPrimaryKeyOnUuidColumnOfSnapshotsTableTest.java new file mode 100644 index 00000000000..f852f4b5629 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/snapshots/AddPrimaryKeyOnUuidColumnOfSnapshotsTableTest.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.snapshots; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.version.v84.snapshots.issues.AddPrimaryKeyOnUuidColumnOfSnapshotsTable; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class AddPrimaryKeyOnUuidColumnOfSnapshotsTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfSnapshotsTableTest.class, "schema.sql"); + + private AddPrimaryKeyOnUuidColumnOfSnapshotsTable underTest = new AddPrimaryKeyOnUuidColumnOfSnapshotsTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertPrimaryKey("snapshots", "pk_snapshots", "uuid"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/snapshots/DropIdColumnOfSnapshotsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/snapshots/DropIdColumnOfSnapshotsTableTest.java new file mode 100644 index 00000000000..23c972a758c --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/snapshots/DropIdColumnOfSnapshotsTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.snapshots; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.version.v84.snapshots.issues.DropIdColumnOfSnapshotsTable; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropIdColumnOfSnapshotsTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfSnapshotsTableTest.class, "schema.sql"); + + private DropIdColumnOfSnapshotsTable underTest = new DropIdColumnOfSnapshotsTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("snapshots", "id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/snapshots/DropPrimaryKeyOnIdColumnOfSnapshotsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/snapshots/DropPrimaryKeyOnIdColumnOfSnapshotsTableTest.java new file mode 100644 index 00000000000..d2cb5ad5419 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/snapshots/DropPrimaryKeyOnIdColumnOfSnapshotsTableTest.java @@ -0,0 +1,56 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.sonar.server.platform.db.migration.version.v84.snapshots; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.version.v84.snapshots.issues.DropPrimaryKeyOnIdColumnOfSnapshotsTable; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; +import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropPrimaryKeyOnIdColumnOfSnapshotsTableTest { + + private static final String TABLE_NAME = "snapshots"; + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfSnapshotsTableTest.class, "schema.sql"); + + private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + + private DropPrimaryKeyOnIdColumnOfSnapshotsTable underTest = new DropPrimaryKeyOnIdColumnOfSnapshotsTable(db.database(), dropPrimaryKeySqlGenerator); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertNoPrimaryKey(TABLE_NAME); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/AddPrimaryKeyOnUuidColumnOfUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/AddPrimaryKeyOnUuidColumnOfUsersTableTest.java new file mode 100644 index 00000000000..ecf04de6a28 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/AddPrimaryKeyOnUuidColumnOfUsersTableTest.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class AddPrimaryKeyOnUuidColumnOfUsersTableTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfUsersTableTest.class, "schema.sql"); + + private DdlChange underTest = new AddPrimaryKeyOnUuidColumnOfUsersTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertPrimaryKey("users", "pk_users", "uuid"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/DropIdColumnOfUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/DropIdColumnOfUsersTableTest.java new file mode 100644 index 00000000000..ffc6a129bc2 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/DropIdColumnOfUsersTableTest.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropIdColumnOfUsersTableTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfUsersTableTest.class, "schema.sql"); + + private DdlChange underTest = new DropIdColumnOfUsersTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("users", "id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/DropPrimaryKeyOnIdColumnOfUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/DropPrimaryKeyOnIdColumnOfUsersTableTest.java new file mode 100644 index 00000000000..dc53112e842 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/DropPrimaryKeyOnIdColumnOfUsersTableTest.java @@ -0,0 +1,54 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; +import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropPrimaryKeyOnIdColumnOfUsersTableTest { + private static final String TABLE_NAME = "users"; + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfUsersTableTest.class, "schema.sql"); + + private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + + private DdlChange underTest = new DropPrimaryKeyOnIdColumnOfUsersTable(db.database(), dropPrimaryKeySqlGenerator); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertNoPrimaryKey(TABLE_NAME); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/DropUniqueIndexOnUuidColumnOfUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/DropUniqueIndexOnUuidColumnOfUsersTableTest.java new file mode 100644 index 00000000000..aacb4336ea4 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/DropUniqueIndexOnUuidColumnOfUsersTableTest.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropUniqueIndexOnUuidColumnOfUsersTableTest { + private static final String TABLE_NAME = "users"; + private static final String INDEX_NAME = "users_uuid"; + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropUniqueIndexOnUuidColumnOfUsersTableTest.class, "schema.sql"); + + private DdlChange underTest = new DropUniqueIndexOnUuidColumnOfUsersTable(db.database()); + + @Test + public void remove_index_if_exists() throws SQLException { + underTest.execute(); + db.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); + } + + @Test + public void migration_is_reentrant() throws SQLException { + underTest.execute(); + // re-entrant + underTest.execute(); + db.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddIndexOnUserUuidOfGroupsUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddIndexOnUserUuidOfGroupsUsersTableTest.java new file mode 100644 index 00000000000..6ff023f5cc5 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddIndexOnUserUuidOfGroupsUsersTableTest.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class AddIndexOnUserUuidOfGroupsUsersTableTest { + + private static final String TABLE_NAME = "groups_users"; + private static final String INDEX_NAME = "index_groups_users_user_uuid"; + + @Rule + public CoreDbTester dbTester = CoreDbTester.createForSchema(AddIndexOnUserUuidOfGroupsUsersTableTest.class, "schema.sql"); + + DdlChange underTest = new AddIndexOnUserUuidOfGroupsUsersTable(dbTester.database()); + + @Test + public void add_index() throws SQLException { + underTest.execute(); + dbTester.assertIndex(TABLE_NAME, INDEX_NAME, "user_uuid"); + } + + @Test + public void migration_is_reentrant() throws SQLException { + underTest.execute(); + dbTester.assertIndex(TABLE_NAME, INDEX_NAME, "user_uuid"); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTableTest.java new file mode 100644 index 00000000000..71cc5a6e448 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTableTest { + + private static final String TABLE_NAME = "groups_users"; + private static final String INDEX_NAME = "groups_users_unique"; + + @Rule + public CoreDbTester dbTester = CoreDbTester.createForSchema(AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTableTest.class, "schema.sql"); + + DdlChange underTest = new AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTable(dbTester.database()); + + @Test + public void add_index() throws SQLException { + underTest.execute(); + dbTester.assertUniqueIndex(TABLE_NAME, INDEX_NAME, "user_uuid", "group_uuid"); + } + + @Test + public void migration_is_reentrant() throws SQLException { + underTest.execute(); + // re-entrant + underTest.execute(); + dbTester.assertUniqueIndex(TABLE_NAME, INDEX_NAME, "user_uuid", "group_uuid"); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddUserUuidColumnToGroupsUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddUserUuidColumnToGroupsUsersTest.java new file mode 100644 index 00000000000..ff442d1dae8 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddUserUuidColumnToGroupsUsersTest.java @@ -0,0 +1,62 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.Uuids; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddUserUuidColumnToGroupsUsersTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddUserUuidColumnToGroupsUsersTest.class, "schema.sql"); + + private DdlChange underTest = new AddUserUuidColumnToGroupsUsers(db.database()); + + @Before + public void setup() { + insertGroupUser(Uuids.createFast(), 1L); + insertGroupUser(Uuids.createFast(), 2L); + insertGroupUser(Uuids.createFast(), 3L); + } + + @Test + public void add_uuid_column() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("groups_users", "user_uuid", Types.VARCHAR, 40, true); + + assertThat(db.countSql("select count(*) from groups_users")) + .isEqualTo(3); + } + + private void insertGroupUser(String uuid, Long userId) { + db.executeInsert("groups_users", + "group_uuid", uuid, + "user_id", userId + 1); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropIndexOnUserIdOfGroupsUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropIndexOnUserIdOfGroupsUsersTableTest.java new file mode 100644 index 00000000000..d364ad1e200 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropIndexOnUserIdOfGroupsUsersTableTest.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropIndexOnUserIdOfGroupsUsersTableTest { + + private static final String TABLE_NAME = "users_groups"; + private static final String INDEX_NAME = "index_groups_users_on_user_id"; + + @Rule + public CoreDbTester dbTester = CoreDbTester.createForSchema(DropIndexOnUserIdOfGroupsUsersTableTest.class, "schema.sql"); + + DdlChange underTest = new DropIndexOnUserIdOfGroupsUsersTable(dbTester.database()); + + @Test + public void add_index() throws SQLException { + underTest.execute(); + dbTester.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); + } + + @Test + public void migration_is_reentrant() throws SQLException { + underTest.execute(); + dbTester.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTableTest.java new file mode 100644 index 00000000000..980b03ef504 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTableTest.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTableTest { + + private static final String TABLE_NAME = "groups_users"; + private static final String INDEX_NAME = "groups_users_unique"; + + @Rule + public CoreDbTester dbTester = CoreDbTester.createForSchema(DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTableTest.class, "schema.sql"); + + DdlChange underTest = new DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTable(dbTester.database()); + + @Test + public void add_index() throws SQLException { + underTest.execute(); + dbTester.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); + } + + @Test + public void migration_is_reentrant() throws SQLException { + underTest.execute(); + dbTester.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropUserIdColumnOfGroupsUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropUserIdColumnOfGroupsUsersTableTest.java new file mode 100644 index 00000000000..b15f2c5c5fb --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropUserIdColumnOfGroupsUsersTableTest.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropUserIdColumnOfGroupsUsersTableTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropUserIdColumnOfGroupsUsersTableTest.class, "schema.sql"); + + private DdlChange underTest = new DropUserIdColumnOfGroupsUsersTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("groups_users", "user_id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/MakeGroupsUsersUserUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/MakeGroupsUsersUserUuidColumnNotNullableTest.java new file mode 100644 index 00000000000..9cc33a56b11 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/MakeGroupsUsersUserUuidColumnNotNullableTest.java @@ -0,0 +1,43 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static java.sql.Types.VARCHAR; + +public class MakeGroupsUsersUserUuidColumnNotNullableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(MakeGroupsUsersUserUuidColumnNotNullableTest.class, "schema.sql"); + + private MigrationStep underTest = new MakeGroupsUsersUserUuidColumnNotNullable(db.database()); + + @Test + public void uuid_column_is_not_null() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("groups_users", "user_uuid", VARCHAR, null, false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/PopulateGroupsUsersUserUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/PopulateGroupsUsersUserUuidTest.java new file mode 100644 index 00000000000..aa1217b9387 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/PopulateGroupsUsersUserUuidTest.java @@ -0,0 +1,139 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.groupsusers; + +import java.sql.SQLException; +import java.util.Objects; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.Uuids; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulateGroupsUsersUserUuidTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulateGroupsUsersUserUuidTest.class, "schema.sql"); + + private DataChange underTest = new PopulateGroupsUsersUserUuid(db.database()); + + @Test + public void populate_uuids() throws SQLException { + long userId_1 = 1L; + String userUuid_1 = "uuid-1"; + insertUser(userId_1, userUuid_1); + + long userId_2 = 2L; + String userUuid_2 = "uuid-2"; + insertUser(userId_2, userUuid_2); + + long userId_3 = 3L; + String userUuid_3 = "uuid-3"; + insertUser(userId_3, userUuid_3); + + long userId_4 = 4L; + String userUuid_4 = "uuid-4"; + insertUser(userId_4, userUuid_4); + + String groupUuid_1 = Uuids.createFast(); + insertGroupUser(userId_1, groupUuid_1); + String groupUuid_2 = Uuids.createFast(); + insertGroupUser(userId_2, groupUuid_2); + String groupUuid_3 = Uuids.createFast(); + insertGroupUser(userId_3, groupUuid_3); + String groupUuid_4 = Uuids.createFast(); + insertGroupUser(userId_1, groupUuid_4); + + underTest.execute(); + + assertThatGroupsUserUserUuidIsEqualTo(userId_1, groupUuid_1, userUuid_1); + assertThatGroupsUserUserUuidIsEqualTo(userId_2, groupUuid_2, userUuid_2); + assertThatGroupsUserUserUuidIsEqualTo(userId_3, groupUuid_3, userUuid_3); + assertThatGroupsUserUserUuidIsEqualTo(userId_1, groupUuid_4, userUuid_1); + } + + @Test + public void migration_is_reentrant() throws SQLException { + long userId_1 = 1L; + String userUuid_1 = "uuid-1"; + insertUser(userId_1, userUuid_1); + + long userId_2 = 2L; + String userUuid_2 = "uuid-2"; + insertUser(userId_2, userUuid_2); + + long userId_3 = 3L; + String userUuid_3 = "uuid-3"; + insertUser(userId_3, userUuid_3); + + long userId_4 = 4L; + String userUuid_4 = "uuid-4"; + insertUser(userId_4, userUuid_4); + + String groupUuid_1 = Uuids.createFast(); + insertGroupUser(userId_1, groupUuid_1); + String groupUuid_2 = Uuids.createFast(); + insertGroupUser(userId_2, groupUuid_2); + String groupUuid_3 = Uuids.createFast(); + insertGroupUser(userId_3, groupUuid_3); + + underTest.execute(); + + String groupUuid_4 = Uuids.createFast(); + insertGroupUser(userId_1, groupUuid_4); + + // re-entrant + underTest.execute(); + + assertThatGroupsUserUserUuidIsEqualTo(userId_1, groupUuid_1, userUuid_1); + assertThatGroupsUserUserUuidIsEqualTo(userId_2, groupUuid_2, userUuid_2); + assertThatGroupsUserUserUuidIsEqualTo(userId_3, groupUuid_3, userUuid_3); + assertThatGroupsUserUserUuidIsEqualTo(userId_1, groupUuid_4, userUuid_1); + } + + private void assertThatGroupsUserUserUuidIsEqualTo(Long userId, String groupUuid, String expectedUuid) { + assertThat(db.select(String.format("select user_uuid from groups_users where user_id = %d and group_uuid = '%s'", userId, groupUuid)) + .stream() + .map(row -> row.get("USER_UUID")) + .filter(Objects::nonNull) + .findFirst()) + .hasValue(expectedUuid); + } + + private void insertGroupUser(Long userId, String groupUuid) { + db.executeInsert("groups_users", + "user_id", userId, + "group_uuid", groupUuid); + } + + private void insertUser(Long id, String uuid) { + db.executeInsert("users", + "id", id, + "uuid", uuid, + "login", "login" + id, + "external_login", "ex-login" + id, + "external_identity_provider", "ex-provider" + id, + "external_id", id + 1, + "is_root", false, + "onboarded", false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddIndexOnUserUuidOfOrganizationMembersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddIndexOnUserUuidOfOrganizationMembersTableTest.java new file mode 100644 index 00000000000..3ff8e593388 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddIndexOnUserUuidOfOrganizationMembersTableTest.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class AddIndexOnUserUuidOfOrganizationMembersTableTest { + + private static final String TABLE_NAME = "organization_members"; + private static final String INDEX_NAME = "org_members_user_uuid"; + + @Rule + public CoreDbTester dbTester = CoreDbTester.createForSchema(AddIndexOnUserUuidOfOrganizationMembersTableTest.class, "schema.sql"); + + DdlChange underTest = new AddIndexOnUserUuidOfOrganizationMembersTable(dbTester.database()); + + @Test + public void add_index() throws SQLException { + underTest.execute(); + dbTester.assertIndex(TABLE_NAME, INDEX_NAME, "user_uuid"); + } + + @Test + public void migration_is_reentrant() throws SQLException { + underTest.execute(); + dbTester.assertIndex(TABLE_NAME, INDEX_NAME, "user_uuid"); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTableTest.java new file mode 100644 index 00000000000..e8f00809d30 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTableTest.class, "schema.sql"); + + private DdlChange underTest = new AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertPrimaryKey("organization_members", "pk_organization_members", "user_uuid", "organization_uuid"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddUserUuidColumnToOrganizationMembersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddUserUuidColumnToOrganizationMembersTest.java new file mode 100644 index 00000000000..f1cc49b8d12 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddUserUuidColumnToOrganizationMembersTest.java @@ -0,0 +1,61 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddUserUuidColumnToOrganizationMembersTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddUserUuidColumnToOrganizationMembersTest.class, "schema.sql"); + + private DdlChange underTest = new AddUserUuidColumnToOrganizationMembers(db.database()); + + @Before + public void setup() { + insertGroupUser(1L); + insertGroupUser(2L); + insertGroupUser(3L); + } + + @Test + public void add_uuid_column() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("organization_members", "user_uuid", Types.VARCHAR, 40, true); + + assertThat(db.countSql("select count(*) from organization_members")) + .isEqualTo(3); + } + + private void insertGroupUser(Long id) { + db.executeInsert("organization_members", + "user_id", id, + "organization_uuid", "uuid-" + id); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropIndexOnUserIdOfOrganizationMembersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropIndexOnUserIdOfOrganizationMembersTableTest.java new file mode 100644 index 00000000000..baf45e99985 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropIndexOnUserIdOfOrganizationMembersTableTest.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropIndexOnUserIdOfOrganizationMembersTableTest { + + private static final String TABLE_NAME = "organization_members"; + private static final String INDEX_NAME = "ix_org_members_on_user_id"; + + @Rule + public CoreDbTester dbTester = CoreDbTester.createForSchema(DropIndexOnUserIdOfOrganizationMembersTableTest.class, "schema.sql"); + + DdlChange underTest = new DropIndexOnUserIdOfOrganizationMembersTable(dbTester.database()); + + @Test + public void add_index() throws SQLException { + underTest.execute(); + dbTester.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); + } + + @Test + public void migration_is_reentrant() throws SQLException { + underTest.execute(); + dbTester.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTableTest.java new file mode 100644 index 00000000000..4019839d54e --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTableTest.java @@ -0,0 +1,54 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; +import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTableTest { + private static final String TABLE_NAME = "organization_members"; + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTableTest.class, "schema.sql"); + + private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + + private DdlChange underTest = new DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTable(db.database(), dropPrimaryKeySqlGenerator); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertNoPrimaryKey(TABLE_NAME); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropUserIdColumnOfOrganizationMembersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropUserIdColumnOfOrganizationMembersTableTest.java new file mode 100644 index 00000000000..14b4bb00b5a --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropUserIdColumnOfOrganizationMembersTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropUserIdColumnOfOrganizationMembersTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropUserIdColumnOfOrganizationMembersTableTest.class, "schema.sql"); + + private DdlChange underTest = new DropUserIdColumnOfOrganizationMembersTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("organization_members", "user_id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/MakeOrganizationMembersUserUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/MakeOrganizationMembersUserUuidColumnNotNullableTest.java new file mode 100644 index 00000000000..54713dbc172 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/MakeOrganizationMembersUserUuidColumnNotNullableTest.java @@ -0,0 +1,43 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static java.sql.Types.VARCHAR; +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_SIZE; + +public class MakeOrganizationMembersUserUuidColumnNotNullableTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(MakeOrganizationMembersUserUuidColumnNotNullableTest.class, "schema.sql"); + + private MigrationStep underTest = new MakeOrganizationMembersUserUuidColumnNotNullable(db.database()); + + @Test + public void uuid_column_is_not_null() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("organization_members", "user_uuid", VARCHAR, UUID_SIZE, false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/PopulateOrganizationMembersUserUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/PopulateOrganizationMembersUserUuidTest.java new file mode 100644 index 00000000000..554a985b455 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/PopulateOrganizationMembersUserUuidTest.java @@ -0,0 +1,140 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.organizationmembers; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.Uuids; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulateOrganizationMembersUserUuidTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulateOrganizationMembersUserUuidTest.class, "schema.sql"); + + private DataChange underTest = new PopulateOrganizationMembersUserUuid(db.database()); + + @Test + public void populate_uuids() throws SQLException { + long userId_1 = 1L; + String userUuid_1 = "uuid-1"; + insertUser(userId_1, userUuid_1); + + long userId_2 = 2L; + String userUuid_2 = "uuid-2"; + insertUser(userId_2, userUuid_2); + + long userId_3 = 3L; + String userUuid_3 = "uuid-3"; + insertUser(userId_3, userUuid_3); + + long userId_4 = 4L; + String userUuid_4 = "uuid-4"; + insertUser(userId_4, userUuid_4); + + String organizationUuid_1 = Uuids.createFast(); + insertOrganizationMember(userId_1, organizationUuid_1); + String organizationUuid_2 = Uuids.createFast(); + insertOrganizationMember(userId_2, organizationUuid_2); + String organizationUuid_3 = Uuids.createFast(); + insertOrganizationMember(userId_3, organizationUuid_3); + String organizationUuid_4 = Uuids.createFast(); + insertOrganizationMember(userId_4, organizationUuid_4); + String organizationUuid_5 = Uuids.createFast(); + insertOrganizationMember(userId_1, organizationUuid_5); + + underTest.execute(); + + assertThatQProfileChangeRulesProfileUuidIsEqualTo(userId_1, organizationUuid_1, userUuid_1); + assertThatQProfileChangeRulesProfileUuidIsEqualTo(userId_2, organizationUuid_2, userUuid_2); + assertThatQProfileChangeRulesProfileUuidIsEqualTo(userId_3, organizationUuid_3, userUuid_3); + assertThatQProfileChangeRulesProfileUuidIsEqualTo(userId_4, organizationUuid_4, userUuid_4); + assertThatQProfileChangeRulesProfileUuidIsEqualTo(userId_1, organizationUuid_5, userUuid_1); + } + + @Test + public void migration_is_reentrant() throws SQLException { + long userId_1 = 1L; + String userUuid_1 = "uuid-1"; + insertUser(userId_1, userUuid_1); + + long userId_2 = 2L; + String userUuid_2 = "uuid-2"; + insertUser(userId_2, userUuid_2); + + long userId_3 = 3L; + String userUuid_3 = "uuid-3"; + insertUser(userId_3, userUuid_3); + + long userId_4 = 4L; + String userUuid_4 = "uuid-4"; + insertUser(userId_4, userUuid_4); + + String organizationUuid_1 = Uuids.createFast(); + insertOrganizationMember(userId_1, organizationUuid_1); + String organizationUuid_2 = Uuids.createFast(); + insertOrganizationMember(userId_2, organizationUuid_2); + String organizationUuid_3 = Uuids.createFast(); + insertOrganizationMember(userId_3, organizationUuid_3); + + underTest.execute(); + + String organizationUuid_4 = Uuids.createFast(); + insertOrganizationMember(userId_3, organizationUuid_4); + + // re-entrant + underTest.execute(); + + assertThatQProfileChangeRulesProfileUuidIsEqualTo(userId_1, organizationUuid_1, userUuid_1); + assertThatQProfileChangeRulesProfileUuidIsEqualTo(userId_2, organizationUuid_2, userUuid_2); + assertThatQProfileChangeRulesProfileUuidIsEqualTo(userId_3, organizationUuid_3, userUuid_3); + assertThatQProfileChangeRulesProfileUuidIsEqualTo(userId_3, organizationUuid_4, userUuid_3); + } + + private void assertThatQProfileChangeRulesProfileUuidIsEqualTo(Long userId, String organizationUuid, String expectedUuid) { + assertThat(db.select(String.format("select user_uuid from organization_members where user_id = %d and organization_uuid = '%s'", userId, organizationUuid)) + .stream() + .map(row -> row.get("USER_UUID")) + .findFirst()) + .hasValue(expectedUuid); + } + + private void insertOrganizationMember(Long userId, String organizationUuid) { + db.executeInsert("organization_members", + "user_id", userId, + "organization_uuid", organizationUuid); + } + + private void insertUser(Long id, String uuid) { + db.executeInsert("users", + "id", id, + "uuid", uuid, + "login", "login" + id, + "external_login", "ex-login" + id, + "external_identity_provider", "ex-provider" + id, + "external_id", id + 1, + "is_root", false, + "onboarded", false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/AddUserUuidColumnToPermTemplatesUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/AddUserUuidColumnToPermTemplatesUsersTest.java new file mode 100644 index 00000000000..563b5ec6111 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/AddUserUuidColumnToPermTemplatesUsersTest.java @@ -0,0 +1,65 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.permtemplatesusers; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.Uuids; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddUserUuidColumnToPermTemplatesUsersTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddUserUuidColumnToPermTemplatesUsersTest.class, "schema.sql"); + + private DdlChange underTest = new AddUserUuidColumnToPermTemplatesUsers(db.database()); + + @Before + public void setup() { + insertPermTemplatesUser(Uuids.createFast(), 1L); + insertPermTemplatesUser(Uuids.createFast(), 2L); + insertPermTemplatesUser(Uuids.createFast(), 3L); + } + + @Test + public void add_uuid_column() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("perm_templates_users", "user_uuid", Types.VARCHAR, 40, true); + + assertThat(db.countSql("select count(*) from perm_templates_users")) + .isEqualTo(3); + } + + private void insertPermTemplatesUser(String uuid, long userId) { + db.executeInsert("perm_templates_users", + "uuid", uuid, + "user_id", userId, + "template_id", userId + 100, + "permission_reference", Uuids.createFast()); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/DropUserIdColumnOfPermTemplatesUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/DropUserIdColumnOfPermTemplatesUsersTableTest.java new file mode 100644 index 00000000000..970bf2d6736 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/DropUserIdColumnOfPermTemplatesUsersTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.permtemplatesusers; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropUserIdColumnOfPermTemplatesUsersTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropUserIdColumnOfPermTemplatesUsersTableTest.class, "schema.sql"); + + private DdlChange underTest = new DropUserIdColumnOfPermTemplatesUsersTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("perm_templates_users", "user_id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/MakePermTemplatesUsersUserUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/MakePermTemplatesUsersUserUuidColumnNotNullableTest.java new file mode 100644 index 00000000000..8a7c5a9aab7 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/MakePermTemplatesUsersUserUuidColumnNotNullableTest.java @@ -0,0 +1,43 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.permtemplatesusers; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static java.sql.Types.VARCHAR; +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_SIZE; + +public class MakePermTemplatesUsersUserUuidColumnNotNullableTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(MakePermTemplatesUsersUserUuidColumnNotNullableTest.class, "schema.sql"); + + private MigrationStep underTest = new MakePermTemplatesUsersUserUuidColumnNotNullable(db.database()); + + @Test + public void uuid_column_is_not_null() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("perm_templates_users", "user_uuid", VARCHAR, UUID_SIZE, false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/PopulatePermTemplatesUsersUserUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/PopulatePermTemplatesUsersUserUuidTest.java new file mode 100644 index 00000000000..9e167a77981 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/PopulatePermTemplatesUsersUserUuidTest.java @@ -0,0 +1,145 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.permtemplatesusers; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.Uuids; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulatePermTemplatesUsersUserUuidTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulatePermTemplatesUsersUserUuidTest.class, "schema.sql"); + + private DataChange underTest = new PopulatePermTemplatesUsersUserUuid(db.database()); + + @Test + public void populate_uuids() throws SQLException { + long userId_1 = 1L; + String userUuid_1 = "uuid-1"; + insertUser(userId_1, userUuid_1); + + long userId_2 = 2L; + String userUuid_2 = "uuid-2"; + insertUser(userId_2, userUuid_2); + + long userId_3 = 3L; + String userUuid_3 = "uuid-3"; + insertUser(userId_3, userUuid_3); + + long userId_4 = 4L; + String userUuid_4 = "uuid-4"; + insertUser(userId_4, userUuid_4); + + String permTemplatesUserUuid_1 = Uuids.createFast(); + insertPermTemplatesUser(permTemplatesUserUuid_1, userId_1); + String permTemplatesUserUuid_2 = Uuids.createFast(); + insertPermTemplatesUser(permTemplatesUserUuid_2, userId_2); + String permTemplatesUserUuid_3 = Uuids.createFast(); + insertPermTemplatesUser(permTemplatesUserUuid_3, userId_3); + String permTemplatesUserUuid_4 = Uuids.createFast(); + insertPermTemplatesUser(permTemplatesUserUuid_4, userId_4); + String permTemplatesUserUuid_5 = Uuids.createFast(); + insertPermTemplatesUser(permTemplatesUserUuid_5, userId_1); + + underTest.execute(); + + assertThatPermTemplatesUsersUserUuidIsEqualTo(permTemplatesUserUuid_1, userUuid_1); + assertThatPermTemplatesUsersUserUuidIsEqualTo(permTemplatesUserUuid_2, userUuid_2); + assertThatPermTemplatesUsersUserUuidIsEqualTo(permTemplatesUserUuid_3, userUuid_3); + assertThatPermTemplatesUsersUserUuidIsEqualTo(permTemplatesUserUuid_4, userUuid_4); + assertThatPermTemplatesUsersUserUuidIsEqualTo(permTemplatesUserUuid_5, userUuid_1); + } + + @Test + public void migration_is_reentrant() throws SQLException { + long userId_1 = 1L; + String userUuid_1 = "uuid-1"; + insertUser(userId_1, userUuid_1); + + long userId_2 = 2L; + String userUuid_2 = "uuid-2"; + insertUser(userId_2, userUuid_2); + + long userId_3 = 3L; + String userUuid_3 = "uuid-3"; + insertUser(userId_3, userUuid_3); + + long userId_4 = 4L; + String userUuid_4 = "uuid-4"; + insertUser(userId_4, userUuid_4); + + String permTemplatesUserUuid_1 = Uuids.createFast(); + insertPermTemplatesUser(permTemplatesUserUuid_1, userId_1); + String permTemplatesUserUuid_2 = Uuids.createFast(); + insertPermTemplatesUser(permTemplatesUserUuid_2, userId_2); + String permTemplatesUserUuid_3 = Uuids.createFast(); + insertPermTemplatesUser(permTemplatesUserUuid_3, userId_3); + + underTest.execute(); + + String permTemplatesUserUuid_4 = Uuids.createFast(); + insertPermTemplatesUser(permTemplatesUserUuid_4, userId_4); + String permTemplatesUserUuid_5 = Uuids.createFast(); + insertPermTemplatesUser(permTemplatesUserUuid_5, userId_1); + + // re-entrant + underTest.execute(); + + assertThatPermTemplatesUsersUserUuidIsEqualTo(permTemplatesUserUuid_1, userUuid_1); + assertThatPermTemplatesUsersUserUuidIsEqualTo(permTemplatesUserUuid_2, userUuid_2); + assertThatPermTemplatesUsersUserUuidIsEqualTo(permTemplatesUserUuid_3, userUuid_3); + assertThatPermTemplatesUsersUserUuidIsEqualTo(permTemplatesUserUuid_4, userUuid_4); + assertThatPermTemplatesUsersUserUuidIsEqualTo(permTemplatesUserUuid_5, userUuid_1); + } + + private void assertThatPermTemplatesUsersUserUuidIsEqualTo(String permTemplatesUserUuid, String expectedUuid) { + assertThat(db.select(String.format("select user_uuid from perm_templates_users where uuid = '%s'", permTemplatesUserUuid)) + .stream() + .map(row -> row.get("USER_UUID")) + .findFirst()) + .hasValue(expectedUuid); + } + + private void insertPermTemplatesUser(String uuid, long userId) { + db.executeInsert("perm_templates_users", + "uuid", uuid, + "user_id", userId, + "template_id", userId + 100, + "permission_reference", Uuids.createFast()); + } + + private void insertUser(Long id, String uuid) { + db.executeInsert("users", + "id", id, + "uuid", uuid, + "login", "login" + id, + "external_login", "ex-login" + id, + "external_identity_provider", "ex-provider" + id, + "external_id", id + 1, + "is_root", false, + "onboarded", false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/AddUserUuidColumnToPropertiesUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/AddUserUuidColumnToPropertiesUsersTest.java new file mode 100644 index 00000000000..196d410b90a --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/AddUserUuidColumnToPropertiesUsersTest.java @@ -0,0 +1,65 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.properties; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.Uuids; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddUserUuidColumnToPropertiesUsersTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddUserUuidColumnToPropertiesUsersTest.class, "schema.sql"); + + private DdlChange underTest = new AddUserUuidColumnToPropertiesUsers(db.database()); + + @Before + public void setup() { + insertProperty(Uuids.createFast()); + insertProperty(Uuids.createFast()); + insertProperty(Uuids.createFast()); + } + + @Test + public void add_uuid_column() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("properties", "user_uuid", Types.VARCHAR, 40, true); + + assertThat(db.countSql("select count(*) from properties")) + .isEqualTo(3); + } + + private void insertProperty(String uuid) { + db.executeInsert("properties", + "uuid", uuid, + "prop_key", "kee-" + uuid, + "is_empty", false, + "created_at", System.currentTimeMillis()); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/DropUserIdColumnOfPropertiesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/DropUserIdColumnOfPropertiesTableTest.java new file mode 100644 index 00000000000..072be500d71 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/DropUserIdColumnOfPropertiesTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.properties; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropUserIdColumnOfPropertiesTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropUserIdColumnOfPropertiesTableTest.class, "schema.sql"); + + private DdlChange underTest = new DropUserIdColumnOfPropertiesTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("properties", "user_id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/PopulatePropertiesUserUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/PopulatePropertiesUserUuidTest.java new file mode 100644 index 00000000000..443bc0b2a44 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/PopulatePropertiesUserUuidTest.java @@ -0,0 +1,154 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.properties; + +import java.sql.SQLException; +import java.util.Objects; +import java.util.Optional; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.Uuids; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulatePropertiesUserUuidTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulatePropertiesUserUuidTest.class, "schema.sql"); + + private DataChange underTest = new PopulatePropertiesUserUuid(db.database()); + + @Test + public void populate_uuids() throws SQLException { + long userId_1 = 1L; + String userUuid_1 = "uuid-1"; + insertUser(userId_1, userUuid_1); + + long userId_2 = 2L; + String userUuid_2 = "uuid-2"; + insertUser(userId_2, userUuid_2); + + long userId_3 = 3L; + String userUuid_3 = "uuid-3"; + insertUser(userId_3, userUuid_3); + + long userId_4 = 4L; + String userUuid_4 = "uuid-4"; + insertUser(userId_4, userUuid_4); + + String propertyUuid_1 = Uuids.createFast(); + insertProperty(propertyUuid_1, userId_1); + String propertyUuid_2 = Uuids.createFast(); + insertProperty(propertyUuid_2, userId_2); + String propertyUuid_3 = Uuids.createFast(); + insertProperty(propertyUuid_3, userId_3); + String propertyUuid_4 = Uuids.createFast(); + insertProperty(propertyUuid_4, userId_4); + String propertyUuid_5 = Uuids.createFast(); + insertProperty(propertyUuid_5, null); + + underTest.execute(); + + assertThatPropertyUserUuidIsEqualTo(propertyUuid_1, userUuid_1); + assertThatPropertyUserUuidIsEqualTo(propertyUuid_2, userUuid_2); + assertThatPropertyUserUuidIsEqualTo(propertyUuid_3, userUuid_3); + assertThatPropertyUserUuidIsEqualTo(propertyUuid_4, userUuid_4); + assertThatPropertyUserUuidIsEqualTo(propertyUuid_5, null); + } + + @Test + public void migration_is_reentrant() throws SQLException { + long userId_1 = 1L; + String userUuid_1 = "uuid-1"; + insertUser(userId_1, userUuid_1); + + long userId_2 = 2L; + String userUuid_2 = "uuid-2"; + insertUser(userId_2, userUuid_2); + + long userId_3 = 3L; + String userUuid_3 = "uuid-3"; + insertUser(userId_3, userUuid_3); + + long userId_4 = 4L; + String userUuid_4 = "uuid-4"; + insertUser(userId_4, userUuid_4); + + String propertyUuid_1 = Uuids.createFast(); + insertProperty(propertyUuid_1, userId_1); + String propertyUuid_2 = Uuids.createFast(); + insertProperty(propertyUuid_2, userId_2); + String propertyUuid_3 = Uuids.createFast(); + insertProperty(propertyUuid_3, userId_3); + + underTest.execute(); + + String propertyUuid_4 = Uuids.createFast(); + insertProperty(propertyUuid_4, userId_4); + String propertyUuid_5 = Uuids.createFast(); + insertProperty(propertyUuid_5, null); + + // re-entrant + underTest.execute(); + + assertThatPropertyUserUuidIsEqualTo(propertyUuid_1, userUuid_1); + assertThatPropertyUserUuidIsEqualTo(propertyUuid_2, userUuid_2); + assertThatPropertyUserUuidIsEqualTo(propertyUuid_3, userUuid_3); + assertThatPropertyUserUuidIsEqualTo(propertyUuid_4, userUuid_4); + assertThatPropertyUserUuidIsEqualTo(propertyUuid_5, null); + } + + private void assertThatPropertyUserUuidIsEqualTo(String propertyUuid, String expectedUuid) { + Optional optional = db.select(String.format("select user_uuid from properties where uuid = '%s'", propertyUuid)) + .stream() + .map(row -> row.get("USER_UUID")) + .filter(Objects::nonNull) + .findFirst(); + + if (expectedUuid != null) { + assertThat(optional).hasValue(expectedUuid); + } else { + assertThat(optional).isEmpty(); + } + + } + + private void insertProperty(String uuid, Long userId) { + db.executeInsert("properties", + "uuid", uuid, + "user_id", userId, + "prop_key", "kee-" + uuid, + "is_empty", false, + "created_at", System.currentTimeMillis()); + } + + private void insertUser(Long id, String uuid) { + db.executeInsert("users", + "id", id, + "uuid", uuid, + "login", "login" + id, + "external_login", "ex-login" + id, + "external_identity_provider", "ex-provider" + id, + "external_id", id + 1, + "is_root", false, + "onboarded", false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTableTest.java new file mode 100644 index 00000000000..ccd27525ffe --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTableTest.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.qprofileeditusers; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTableTest { + + private static final String TABLE_NAME = "qprofile_edit_users"; + private static final String INDEX_NAME = "qprofile_edit_users_unique"; + + @Rule + public CoreDbTester dbTester = CoreDbTester.createForSchema(AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTableTest.class, "schema.sql"); + + DdlChange underTest = new AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTable(dbTester.database()); + + @Test + public void add_index() throws SQLException { + underTest.execute(); + dbTester.assertUniqueIndex(TABLE_NAME, INDEX_NAME, "user_uuid", "qprofile_uuid"); + } + + @Test + public void migration_is_reentrant() throws SQLException { + underTest.execute(); + dbTester.assertUniqueIndex(TABLE_NAME, INDEX_NAME, "user_uuid", "qprofile_uuid"); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/AddUserUuidColumnToQProfileEditUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/AddUserUuidColumnToQProfileEditUsersTest.java new file mode 100644 index 00000000000..08d1ce42316 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/AddUserUuidColumnToQProfileEditUsersTest.java @@ -0,0 +1,64 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.qprofileeditusers; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.Uuids; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddUserUuidColumnToQProfileEditUsersTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddUserUuidColumnToQProfileEditUsersTest.class, "schema.sql"); + + private DdlChange underTest = new AddUserUuidColumnToQProfileEditUsers(db.database()); + + @Before + public void setup() { + insertQProfileEditUser(Uuids.createFast(), 1L); + insertQProfileEditUser(Uuids.createFast(), 2L); + insertQProfileEditUser(Uuids.createFast(), 3L); + } + + @Test + public void add_uuid_column() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("qprofile_edit_users", "user_uuid", Types.VARCHAR, 40, true); + + assertThat(db.countSql("select count(*) from qprofile_edit_users")) + .isEqualTo(3); + } + + private void insertQProfileEditUser(String uuid, long userId) { + db.executeInsert("qprofile_edit_users", + "uuid", uuid, + "user_id", userId, + "qprofile_uuid", Uuids.createFast(), + "created_at", System.currentTimeMillis()); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTableTest.java new file mode 100644 index 00000000000..0ba953f9d35 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTableTest.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.qprofileeditusers; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTableTest { + + private static final String TABLE_NAME = "qprofile_edit_users"; + private static final String INDEX_NAME = "qprofile_edit_users_unique"; + + @Rule + public CoreDbTester dbTester = CoreDbTester.createForSchema(DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTableTest.class, "schema.sql"); + + DdlChange underTest = new DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTable(dbTester.database()); + + @Test + public void add_index() throws SQLException { + underTest.execute(); + dbTester.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); + } + + @Test + public void migration_is_reentrant() throws SQLException { + underTest.execute(); + dbTester.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/DropUserIdColumnOfQProfileEditUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/DropUserIdColumnOfQProfileEditUsersTableTest.java new file mode 100644 index 00000000000..69f9ec50dad --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/DropUserIdColumnOfQProfileEditUsersTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.qprofileeditusers; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropUserIdColumnOfQProfileEditUsersTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropUserIdColumnOfQProfileEditUsersTableTest.class, "schema.sql"); + + private DdlChange underTest = new DropUserIdColumnOfQProfileEditUsersTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("qprofile_edit_users", "user_id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/MakeQProfileEditUsersUserUuidColumnNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/MakeQProfileEditUsersUserUuidColumnNotNullableTest.java new file mode 100644 index 00000000000..ec3a82c731e --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/MakeQProfileEditUsersUserUuidColumnNotNullableTest.java @@ -0,0 +1,43 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.qprofileeditusers; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static java.sql.Types.VARCHAR; +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_SIZE; + +public class MakeQProfileEditUsersUserUuidColumnNotNullableTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(MakeQProfileEditUsersUserUuidColumnNotNullableTest.class, "schema.sql"); + + private MigrationStep underTest = new MakeQProfileEditUsersUserUuidColumnNotNullable(db.database()); + + @Test + public void uuid_column_is_not_null() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("qprofile_edit_users", "user_uuid", VARCHAR, UUID_SIZE, false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/PopulateQProfileEditUsersUserUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/PopulateQProfileEditUsersUserUuidTest.java new file mode 100644 index 00000000000..05a194a1b64 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/PopulateQProfileEditUsersUserUuidTest.java @@ -0,0 +1,145 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.qprofileeditusers; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.Uuids; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulateQProfileEditUsersUserUuidTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulateQProfileEditUsersUserUuidTest.class, "schema.sql"); + + private DataChange underTest = new PopulateQProfileEditUsersUserUuid(db.database()); + + @Test + public void populate_uuids() throws SQLException { + long userId_1 = 1L; + String userUuid_1 = "uuid-1"; + insertUser(userId_1, userUuid_1); + + long userId_2 = 2L; + String userUuid_2 = "uuid-2"; + insertUser(userId_2, userUuid_2); + + long userId_3 = 3L; + String userUuid_3 = "uuid-3"; + insertUser(userId_3, userUuid_3); + + long userId_4 = 4L; + String userUuid_4 = "uuid-4"; + insertUser(userId_4, userUuid_4); + + String qprofileEditUserUuid_1 = Uuids.createFast(); + insertQProfileEditUser(qprofileEditUserUuid_1, userId_1); + String qprofileEditUserUuid_2 = Uuids.createFast(); + insertQProfileEditUser(qprofileEditUserUuid_2, userId_2); + String qprofileEditUserUuid_3 = Uuids.createFast(); + insertQProfileEditUser(qprofileEditUserUuid_3, userId_3); + String qprofileEditUserUuid_4 = Uuids.createFast(); + insertQProfileEditUser(qprofileEditUserUuid_4, userId_4); + String qprofileEditUserUuid_5 = Uuids.createFast(); + insertQProfileEditUser(qprofileEditUserUuid_5, userId_1); + + underTest.execute(); + + assertThatQProfileEditUserUserUuidIsEqualTo(qprofileEditUserUuid_1, userUuid_1); + assertThatQProfileEditUserUserUuidIsEqualTo(qprofileEditUserUuid_2, userUuid_2); + assertThatQProfileEditUserUserUuidIsEqualTo(qprofileEditUserUuid_3, userUuid_3); + assertThatQProfileEditUserUserUuidIsEqualTo(qprofileEditUserUuid_4, userUuid_4); + assertThatQProfileEditUserUserUuidIsEqualTo(qprofileEditUserUuid_5, userUuid_1); + } + + @Test + public void migration_is_reentrant() throws SQLException { + long userId_1 = 1L; + String userUuid_1 = "uuid-1"; + insertUser(userId_1, userUuid_1); + + long userId_2 = 2L; + String userUuid_2 = "uuid-2"; + insertUser(userId_2, userUuid_2); + + long userId_3 = 3L; + String userUuid_3 = "uuid-3"; + insertUser(userId_3, userUuid_3); + + long userId_4 = 4L; + String userUuid_4 = "uuid-4"; + insertUser(userId_4, userUuid_4); + + String qprofileEditUserUuid_1 = Uuids.createFast(); + insertQProfileEditUser(qprofileEditUserUuid_1, userId_1); + String qprofileEditUserUuid_2 = Uuids.createFast(); + insertQProfileEditUser(qprofileEditUserUuid_2, userId_2); + String qprofileEditUserUuid_3 = Uuids.createFast(); + insertQProfileEditUser(qprofileEditUserUuid_3, userId_3); + + underTest.execute(); + + String qprofileEditUserUuid_4 = Uuids.createFast(); + insertQProfileEditUser(qprofileEditUserUuid_4, userId_4); + String qprofileEditUserUuid_5 = Uuids.createFast(); + insertQProfileEditUser(qprofileEditUserUuid_5, userId_1); + + // re-entrant + underTest.execute(); + + assertThatQProfileEditUserUserUuidIsEqualTo(qprofileEditUserUuid_1, userUuid_1); + assertThatQProfileEditUserUserUuidIsEqualTo(qprofileEditUserUuid_2, userUuid_2); + assertThatQProfileEditUserUserUuidIsEqualTo(qprofileEditUserUuid_3, userUuid_3); + assertThatQProfileEditUserUserUuidIsEqualTo(qprofileEditUserUuid_4, userUuid_4); + assertThatQProfileEditUserUserUuidIsEqualTo(qprofileEditUserUuid_5, userUuid_1); + } + + private void assertThatQProfileEditUserUserUuidIsEqualTo(String qprofileEditUserUuid, String expectedUuid) { + assertThat(db.select(String.format("select user_uuid from qprofile_edit_users where uuid = '%s'", qprofileEditUserUuid)) + .stream() + .map(row -> row.get("USER_UUID")) + .findFirst()) + .hasValue(expectedUuid); + } + + private void insertQProfileEditUser(String uuid, long userId) { + db.executeInsert("qprofile_edit_users", + "uuid", uuid, + "user_id", userId, + "qprofile_uuid", Uuids.createFast(), + "created_at", System.currentTimeMillis()); + } + + private void insertUser(Long id, String uuid) { + db.executeInsert("users", + "id", id, + "uuid", uuid, + "login", "login" + id, + "external_login", "ex-login" + id, + "external_identity_provider", "ex-provider" + id, + "external_id", id + 1, + "is_root", false, + "onboarded", false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/AddIndexOnUserUuidOfUserRolesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/AddIndexOnUserUuidOfUserRolesTableTest.java new file mode 100644 index 00000000000..8cd8e10880d --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/AddIndexOnUserUuidOfUserRolesTableTest.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.userroles; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class AddIndexOnUserUuidOfUserRolesTableTest { + + private static final String TABLE_NAME = "user_roles"; + private static final String INDEX_NAME = "user_roles_user"; + + @Rule + public CoreDbTester dbTester = CoreDbTester.createForSchema(AddIndexOnUserUuidOfUserRolesTableTest.class, "schema.sql"); + + DdlChange underTest = new AddIndexOnUserUuidOfUserRolesTable(dbTester.database()); + + @Test + public void add_index() throws SQLException { + underTest.execute(); + dbTester.assertIndex(TABLE_NAME, INDEX_NAME, "user_uuid"); + } + + @Test + public void migration_is_reentrant() throws SQLException { + underTest.execute(); + dbTester.assertIndex(TABLE_NAME, INDEX_NAME, "user_uuid"); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/AddUserUuidColumnToUserRolesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/AddUserUuidColumnToUserRolesTest.java new file mode 100644 index 00000000000..0ab2d150099 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/AddUserUuidColumnToUserRolesTest.java @@ -0,0 +1,64 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.userroles; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.Uuids; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddUserUuidColumnToUserRolesTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddUserUuidColumnToUserRolesTest.class, "schema.sql"); + + private DdlChange underTest = new AddUserUuidColumnToUserRoles(db.database()); + + @Before + public void setup() { + insertUserRole(Uuids.createFast(), 1L); + insertUserRole(Uuids.createFast(), 2L); + insertUserRole(Uuids.createFast(), 3L); + } + + @Test + public void add_uuid_column() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("user_roles", "user_uuid", Types.VARCHAR, 40, true); + + assertThat(db.countSql("select count(*) from user_roles")) + .isEqualTo(3); + } + + private void insertUserRole(String uuid, Long userId) { + db.executeInsert("user_roles", + "uuid", uuid, + "organization_uuid", Uuids.createFast(), + "user_id", userId, + "role", Uuids.createFast()); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/DropIndexOnUserIdOfUserRolesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/DropIndexOnUserIdOfUserRolesTableTest.java new file mode 100644 index 00000000000..87149c8608b --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/DropIndexOnUserIdOfUserRolesTableTest.java @@ -0,0 +1,52 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.userroles; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropIndexOnUserIdOfUserRolesTableTest { + + private static final String TABLE_NAME = "user_roles"; + private static final String INDEX_NAME = "user_roles_user"; + + @Rule + public CoreDbTester dbTester = CoreDbTester.createForSchema(DropIndexOnUserIdOfUserRolesTableTest.class, "schema.sql"); + + DdlChange underTest = new DropIndexOnUserIdOfUserRolesTable(dbTester.database()); + + @Test + public void add_index() throws SQLException { + underTest.execute(); + dbTester.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); + } + + @Test + public void migration_is_reentrant() throws SQLException { + underTest.execute(); + // re-entrant + underTest.execute(); + dbTester.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/DropUserIdColumnOfUserRolesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/DropUserIdColumnOfUserRolesTableTest.java new file mode 100644 index 00000000000..3feac55d677 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/DropUserIdColumnOfUserRolesTableTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.userroles; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropUserIdColumnOfUserRolesTableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropUserIdColumnOfUserRolesTableTest.class, "schema.sql"); + + private DdlChange underTest = new DropUserIdColumnOfUserRolesTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("user_roles", "user_id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/PopulateUserRolesUserUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/PopulateUserRolesUserUuidTest.java new file mode 100644 index 00000000000..4486e2fae71 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/PopulateUserRolesUserUuidTest.java @@ -0,0 +1,145 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.users.fk.userroles; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.Uuids; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulateUserRolesUserUuidTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulateUserRolesUserUuidTest.class, "schema.sql"); + + private DataChange underTest = new PopulateUserRolesUserUuid(db.database()); + + @Test + public void populate_uuids() throws SQLException { + long userId_1 = 1L; + String userUuid_1 = "uuid-1"; + insertUser(userId_1, userUuid_1); + + long userId_2 = 2L; + String userUuid_2 = "uuid-2"; + insertUser(userId_2, userUuid_2); + + long userId_3 = 3L; + String userUuid_3 = "uuid-3"; + insertUser(userId_3, userUuid_3); + + long userId_4 = 4L; + String userUuid_4 = "uuid-4"; + insertUser(userId_4, userUuid_4); + + String userRoleUuid_1 = Uuids.createFast(); + insertUserRole(userRoleUuid_1, userId_1); + String userRoleUuid_2 = Uuids.createFast(); + insertUserRole(userRoleUuid_2, userId_2); + String userRoleUuid_3 = Uuids.createFast(); + insertUserRole(userRoleUuid_3, userId_3); + String userRoleUuid_4 = Uuids.createFast(); + insertUserRole(userRoleUuid_4, userId_4); + String userRoleUuid_5 = Uuids.createFast(); + insertUserRole(userRoleUuid_5, userId_1); + + underTest.execute(); + + assertThatUserRoleUserUuidIsEqualTo(userRoleUuid_1, userUuid_1); + assertThatUserRoleUserUuidIsEqualTo(userRoleUuid_2, userUuid_2); + assertThatUserRoleUserUuidIsEqualTo(userRoleUuid_3, userUuid_3); + assertThatUserRoleUserUuidIsEqualTo(userRoleUuid_4, userUuid_4); + assertThatUserRoleUserUuidIsEqualTo(userRoleUuid_5, userUuid_1); + } + + @Test + public void migration_is_reentrant() throws SQLException { + long userId_1 = 1L; + String userUuid_1 = "uuid-1"; + insertUser(userId_1, userUuid_1); + + long userId_2 = 2L; + String userUuid_2 = "uuid-2"; + insertUser(userId_2, userUuid_2); + + long userId_3 = 3L; + String userUuid_3 = "uuid-3"; + insertUser(userId_3, userUuid_3); + + long userId_4 = 4L; + String userUuid_4 = "uuid-4"; + insertUser(userId_4, userUuid_4); + + String userRoleUuid_1 = Uuids.createFast(); + insertUserRole(userRoleUuid_1, userId_1); + String userRoleUuid_2 = Uuids.createFast(); + insertUserRole(userRoleUuid_2, userId_2); + String userRoleUuid_3 = Uuids.createFast(); + insertUserRole(userRoleUuid_3, userId_3); + + underTest.execute(); + + String userRoleUuid_4 = Uuids.createFast(); + insertUserRole(userRoleUuid_4, userId_4); + String userRoleUuid_5 = Uuids.createFast(); + insertUserRole(userRoleUuid_5, userId_1); + + // re-entrant + underTest.execute(); + + assertThatUserRoleUserUuidIsEqualTo(userRoleUuid_1, userUuid_1); + assertThatUserRoleUserUuidIsEqualTo(userRoleUuid_2, userUuid_2); + assertThatUserRoleUserUuidIsEqualTo(userRoleUuid_3, userUuid_3); + assertThatUserRoleUserUuidIsEqualTo(userRoleUuid_4, userUuid_4); + assertThatUserRoleUserUuidIsEqualTo(userRoleUuid_5, userUuid_1); + } + + private void assertThatUserRoleUserUuidIsEqualTo(String userRoleUuid, String expectedUuid) { + assertThat(db.select(String.format("select user_uuid from user_roles where uuid = '%s'", userRoleUuid)) + .stream() + .map(row -> row.get("USER_UUID")) + .findFirst()) + .hasValue(expectedUuid); + } + + private void insertUserRole(String uuid, Long userId) { + db.executeInsert("user_roles", + "uuid", uuid, + "organization_uuid", Uuids.createFast(), + "user_id", userId, + "role", Uuids.createFast()); + } + + private void insertUser(Long id, String uuid) { + db.executeInsert("users", + "id", id, + "uuid", uuid, + "login", "login" + id, + "external_login", "ex-login" + id, + "external_identity_provider", "ex-provider" + id, + "external_id", id + 1, + "is_root", false, + "onboarded", false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/AddPrimaryKeyOnUuidColumnOfUserTokensTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/AddPrimaryKeyOnUuidColumnOfUserTokensTableTest.java new file mode 100644 index 00000000000..ae1a6e7c256 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/AddPrimaryKeyOnUuidColumnOfUserTokensTableTest.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.usertokens; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class AddPrimaryKeyOnUuidColumnOfUserTokensTableTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfUserTokensTableTest.class, "schema.sql"); + + private MigrationStep underTest = new AddPrimaryKeyOnUuidColumnOfUserTokensTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertPrimaryKey("user_tokens", "pk_user_tokens", "uuid"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/AddUuidColumnToUserTokensTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/AddUuidColumnToUserTokensTest.java new file mode 100644 index 00000000000..6372e788a51 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/AddUuidColumnToUserTokensTest.java @@ -0,0 +1,63 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.usertokens; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AddUuidColumnToUserTokensTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(AddUuidColumnToUserTokensTest.class, "schema.sql"); + + private DdlChange underTest = new AddUuidColumnToUserTokens(db.database()); + + @Before + public void setup() { + insertUserToken(1L, "user1", "name1", "token1"); + insertUserToken(2L, "user2", "name2", "token2"); + insertUserToken(3L, "user3", "name3", "token3"); + } + + @Test + public void add_uuid_column_to_user_tokens() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("user_tokens", "uuid", Types.VARCHAR, 40, true); + + assertThat(db.countSql("select count(id) from user_tokens")) + .isEqualTo(3); + } + + private void insertUserToken(Long id, String userUuid, String name, String tokenHash) { + db.executeInsert("user_tokens", + "id", id, + "USER_UUID", userUuid, + "NAME", name, + "TOKEN_HASH", tokenHash, + "CREATED_AT", 0L); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/DropIdColumnOfUserTokensTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/DropIdColumnOfUserTokensTableTest.java new file mode 100644 index 00000000000..af6ff0b942b --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/DropIdColumnOfUserTokensTableTest.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.usertokens; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropIdColumnOfUserTokensTableTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfUserTokensTableTest.class, "schema.sql"); + + private MigrationStep underTest = new DropIdColumnOfUserTokensTable(db.database()); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist("user_tokens", "id"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/DropPrimaryKeyOnIdColumnOfUserTokensTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/DropPrimaryKeyOnIdColumnOfUserTokensTableTest.java new file mode 100644 index 00000000000..519e7c9140e --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/DropPrimaryKeyOnIdColumnOfUserTokensTableTest.java @@ -0,0 +1,55 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.usertokens; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; +import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; +import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class DropPrimaryKeyOnIdColumnOfUserTokensTableTest { + + private static final String TABLE_NAME = "user_tokens"; + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfUserTokensTableTest.class, "schema.sql"); + + private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + + private MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfUserTokensTable(db.database(), dropPrimaryKeySqlGenerator); + + @Test + public void execute() throws SQLException { + underTest.execute(); + + db.assertNoPrimaryKey(TABLE_NAME); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/MakeUserTokensUuidNotNullableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/MakeUserTokensUuidNotNullableTest.java new file mode 100644 index 00000000000..c8e6a7a1873 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/MakeUserTokensUuidNotNullableTest.java @@ -0,0 +1,43 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.usertokens; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +import static java.sql.Types.VARCHAR; + +public class MakeUserTokensUuidNotNullableTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(MakeUserTokensUuidNotNullableTest.class, "schema.sql"); + + private MigrationStep underTest = new MakeUserTokensUuidNotNullable(db.database()); + + @Test + public void created_at_and_uuid_columns_are_not_null() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition("user_tokens", "uuid", VARCHAR, null, false); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/PopulateUserTokensUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/PopulateUserTokensUuidTest.java new file mode 100644 index 00000000000..2c431240809 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/PopulateUserTokensUuidTest.java @@ -0,0 +1,97 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.usertokens; + +import java.sql.SQLException; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.core.util.UuidFactory; +import org.sonar.core.util.UuidFactoryFast; +import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulateUserTokensUuidTest { + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulateUserTokensUuidTest.class, "schema.sql"); + + private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); + private DataChange underTest = new PopulateUserTokensUuid(db.database(), uuidFactory); + + @Test + public void populate_uuids() throws SQLException { + insertUserToken(1L, "user1", "name1", "token1"); + insertUserToken(2L, "user2", "name2", "token2"); + insertUserToken(3L, "user3", "name3", "token3"); + + underTest.execute(); + + verifyUuidsAreNotNull(); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertUserToken(1L, "user1", "name1", "token1"); + insertUserToken(2L, "user2", "name2", "token2"); + insertUserToken(3L, "user3", "name3", "token3"); + + underTest.execute(); + verifyUuidsAreNotNull(); + insertUserToken(4L, "user4", "name4", "token4"); + insertUserToken(5L, "user5", "name5", "token5"); + + List uuids = db.select("select uuid from user_tokens where id = 1 or id = 2 or id = 3") + .stream() + .map(row -> (String) row.get("UUID")) + .collect(Collectors.toList()); + + // re-entrant + underTest.execute(); + verifyUuidsAreNotNull(); + + // verify that uuid set during the first migration have not been updated during the second migration + assertThat(db.select("select uuid from user_tokens") + .stream() + .map(row -> (String) row.get("UUID")) + .collect(Collectors.toList())) + .containsAll(uuids); + } + + private void verifyUuidsAreNotNull() { + assertThat(db.select("select uuid from user_tokens") + .stream() + .map(row -> row.get("UUID")) + .filter(Objects::isNull) + .collect(Collectors.toList())).isEmpty(); + } + + private void insertUserToken(Long id, String userUuid, String name, String tokenHash) { + db.executeInsert("user_tokens", + "id", id, + "USER_UUID", userUuid, + "NAME", name, + "TOKEN_HASH", tokenHash, + "CREATED_AT", 0L); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/util/AddPrimaryKeyBuilderTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/util/AddPrimaryKeyBuilderTest.java new file mode 100644 index 00000000000..ef69661255d --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/util/AddPrimaryKeyBuilderTest.java @@ -0,0 +1,43 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.util; + +import org.junit.Test; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class AddPrimaryKeyBuilderTest { + + private static final String TABLE_NAME = "issues"; + + @Test + public void generate() { + String sql = new AddPrimaryKeyBuilder(TABLE_NAME, "id").build(); + + assertThat(sql).isEqualTo("ALTER TABLE issues ADD CONSTRAINT pk_issues PRIMARY KEY (id)"); + } + + @Test + public void fail_when_table_name_is_invalid() { + assertThatThrownBy(() -> new AddPrimaryKeyBuilder("abcdefghijklmnopqrstuvwxyz", "id").build()) + .isInstanceOf(IllegalArgumentException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/util/DropPrimaryKeySqlGeneratorTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/util/DropPrimaryKeySqlGeneratorTest.java new file mode 100644 index 00000000000..5569ee18d65 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/util/DropPrimaryKeySqlGeneratorTest.java @@ -0,0 +1,96 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v84.util; + +import java.sql.SQLException; +import java.util.List; +import org.junit.Test; +import org.sonar.db.Database; +import org.sonar.db.dialect.H2; +import org.sonar.db.dialect.MsSql; +import org.sonar.db.dialect.Oracle; +import org.sonar.db.dialect.PostgreSql; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class DropPrimaryKeySqlGeneratorTest { + + private static final String TABLE_NAME = "issues"; + private static final String PK_COLUMN = "id"; + private static final String CONSTRAINT = "pk_id"; + + private static final PostgreSql POSTGRESQL = new PostgreSql(); + private static final MsSql MS_SQL = new MsSql(); + private static final Oracle ORACLE = new Oracle(); + private static final org.sonar.db.dialect.H2 H2 = new H2(); + + private Database db = mock(Database.class); + private SqlHelper sqlHelper = mock(SqlHelper.class); + + private DropPrimaryKeySqlGenerator underTest = new DropPrimaryKeySqlGenerator(db, sqlHelper); + + @Test + public void generate_for_postgres_sql() throws SQLException { + when(sqlHelper.getPostgresSqlConstraint(TABLE_NAME)).thenReturn(CONSTRAINT); + when(sqlHelper.getPostgresSqlSequence(TABLE_NAME, "id")).thenReturn(TABLE_NAME + "_id_seq"); + when(db.getDialect()).thenReturn(POSTGRESQL); + + List sqls = underTest.generate(TABLE_NAME, PK_COLUMN, true); + + assertThat(sqls).containsExactly("ALTER TABLE issues ALTER COLUMN id DROP DEFAULT", + "DROP SEQUENCE issues_id_seq", + "ALTER TABLE issues DROP CONSTRAINT pk_id"); + } + + @Test + public void generate_for_ms_sql() throws SQLException { + when(sqlHelper.getMssqlConstraint(TABLE_NAME)).thenReturn(CONSTRAINT); + when(db.getDialect()).thenReturn(MS_SQL); + + List sqls = underTest.generate(TABLE_NAME, PK_COLUMN, true); + + assertThat(sqls).containsExactly("ALTER TABLE issues DROP CONSTRAINT pk_id"); + } + + @Test + public void generate_for_oracle() throws SQLException { + when(sqlHelper.getOracleConstraint(TABLE_NAME)).thenReturn(CONSTRAINT); + when(db.getDialect()).thenReturn(ORACLE); + + List sqls = underTest.generate(TABLE_NAME, PK_COLUMN, true); + + assertThat(sqls).containsExactly("DROP TRIGGER issues_IDT", + "DROP SEQUENCE issues_SEQ", + "ALTER TABLE issues DROP CONSTRAINT pk_id"); + } + + @Test + public void generate_for_h2() throws SQLException { + when(sqlHelper.getH2Constraint(TABLE_NAME)).thenReturn(CONSTRAINT); + when(db.getDialect()).thenReturn(H2); + + List sqls = underTest.generate(TABLE_NAME, PK_COLUMN, true); + + assertThat(sqls).containsExactly("ALTER TABLE issues DROP CONSTRAINT pk_id", + "ALTER TABLE issues ALTER COLUMN id INTEGER NOT NULL"); + } +} diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTableTest/schema.sql deleted file mode 100644 index 814cb67b796..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "ACTIVE_RULE_PARAMETERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "ACTIVE_RULE_ID" INTEGER NOT NULL, - "RULES_PARAMETER_ID" INTEGER NOT NULL, - "VALUE" VARCHAR(4000), - "RULES_PARAMETER_KEY" VARCHAR(128) -); - -CREATE INDEX "IX_ARP_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/AddUuidColumnToActiveRuleParametersTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/AddUuidColumnToActiveRuleParametersTest/schema.sql deleted file mode 100644 index 8366c74f29d..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/AddUuidColumnToActiveRuleParametersTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "ACTIVE_RULE_PARAMETERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "ACTIVE_RULE_ID" INTEGER NOT NULL, - "RULES_PARAMETER_ID" INTEGER NOT NULL, - "VALUE" VARCHAR(4000), - "RULES_PARAMETER_KEY" VARCHAR(128) -); -ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("ID"); -CREATE INDEX "IX_ARP_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/DropIdColumnOfActiveRuleParametersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/DropIdColumnOfActiveRuleParametersTableTest/schema.sql deleted file mode 100644 index c95e98df88d..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/DropIdColumnOfActiveRuleParametersTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "ACTIVE_RULE_PARAMETERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "ACTIVE_RULE_ID" INTEGER NOT NULL, - "RULES_PARAMETER_ID" INTEGER NOT NULL, - "VALUE" VARCHAR(4000), - "RULES_PARAMETER_KEY" VARCHAR(128) -); -ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("UUID"); -CREATE INDEX "IX_ARP_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/DropPrimaryKeyOnIdColumnOfActiveRuleParametersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/DropPrimaryKeyOnIdColumnOfActiveRuleParametersTableTest/schema.sql deleted file mode 100644 index 88efe9d1252..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/DropPrimaryKeyOnIdColumnOfActiveRuleParametersTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "ACTIVE_RULE_PARAMETERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "ACTIVE_RULE_ID" INTEGER NOT NULL, - "RULES_PARAMETER_ID" INTEGER NOT NULL, - "VALUE" VARCHAR(4000), - "RULES_PARAMETER_KEY" VARCHAR(128) -); -ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("ID"); -CREATE INDEX "IX_ARP_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/MakeActiveRuleParametersUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/MakeActiveRuleParametersUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index e3fb5b749c3..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/MakeActiveRuleParametersUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "ACTIVE_RULE_PARAMETERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "ACTIVE_RULE_ID" INTEGER NOT NULL, - "RULES_PARAMETER_ID" INTEGER NOT NULL, - "VALUE" VARCHAR(4000), - "RULES_PARAMETER_KEY" VARCHAR(128) -); -ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("ID"); -CREATE INDEX "IX_ARP_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/PopulateActiveRuleParametersUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/PopulateActiveRuleParametersUuidTest/schema.sql deleted file mode 100644 index e3fb5b749c3..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activeruleparameters/PopulateActiveRuleParametersUuidTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "ACTIVE_RULE_PARAMETERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "ACTIVE_RULE_ID" INTEGER NOT NULL, - "RULES_PARAMETER_ID" INTEGER NOT NULL, - "VALUE" VARCHAR(4000), - "RULES_PARAMETER_KEY" VARCHAR(128) -); -ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("ID"); -CREATE INDEX "IX_ARP_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/AddActiveRuleUuidColumnToActiveRuleParametersTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/AddActiveRuleUuidColumnToActiveRuleParametersTest/schema.sql deleted file mode 100644 index 04d58e9edf0..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/AddActiveRuleUuidColumnToActiveRuleParametersTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "ACTIVE_RULE_PARAMETERS"( - "ACTIVE_RULE_ID" INTEGER NOT NULL, - "RULES_PARAMETER_ID" INTEGER NOT NULL, - "VALUE" VARCHAR(4000), - "RULES_PARAMETER_KEY" VARCHAR(128), - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("UUID"); -CREATE INDEX "IX_ARP_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/AddIndexOnActiveRuleUuidOfActiveRuleParametersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/AddIndexOnActiveRuleUuidOfActiveRuleParametersTableTest/schema.sql deleted file mode 100644 index b074136418d..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/AddIndexOnActiveRuleUuidOfActiveRuleParametersTableTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "ACTIVE_RULE_PARAMETERS"( - "ACTIVE_RULE_ID" INTEGER NOT NULL, - "ACTIVE_RULE_UUID" VARCHAR(40) NOT NULL, - "RULES_PARAMETER_ID" INTEGER NOT NULL, - "VALUE" VARCHAR(4000), - "RULES_PARAMETER_KEY" VARCHAR(128), - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/AddPrimaryKeyOnUuidColumnOfActiveRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/AddPrimaryKeyOnUuidColumnOfActiveRulesTableTest/schema.sql deleted file mode 100644 index 58802cb272e..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/AddPrimaryKeyOnUuidColumnOfActiveRulesTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "ACTIVE_RULES"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "PROFILE_ID" INTEGER NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "FAILURE_LEVEL" INTEGER NOT NULL, - "INHERITANCE" VARCHAR(10), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_ID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/AddUuidColumnToActiveRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/AddUuidColumnToActiveRulesTableTest/schema.sql deleted file mode 100644 index f7f18747670..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/AddUuidColumnToActiveRulesTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "ACTIVE_RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "PROFILE_ID" INTEGER NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "FAILURE_LEVEL" INTEGER NOT NULL, - "INHERITANCE" VARCHAR(10), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_ID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/DropActiveRuleIdColumnOfActiveRuleParametersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/DropActiveRuleIdColumnOfActiveRuleParametersTableTest/schema.sql deleted file mode 100644 index 24d5888764c..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/DropActiveRuleIdColumnOfActiveRuleParametersTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "ACTIVE_RULE_PARAMETERS"( - "ACTIVE_RULE_ID" INTEGER NOT NULL, - "ACTIVE_RULE_UUID" VARCHAR(40) NOT NULL, - "RULES_PARAMETER_ID" INTEGER NOT NULL, - "VALUE" VARCHAR(4000), - "RULES_PARAMETER_KEY" VARCHAR(128), - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("UUID"); -CREATE INDEX "ARP_ACTIVE_RULE_UUID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/DropIdColumnOfActiveRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/DropIdColumnOfActiveRulesTableTest/schema.sql deleted file mode 100644 index faf2cd098e9..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/DropIdColumnOfActiveRulesTableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "ACTIVE_RULES"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "PROFILE_ID" INTEGER NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "FAILURE_LEVEL" INTEGER NOT NULL, - "INHERITANCE" VARCHAR(10), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_ID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/DropIndexOnActiveRuleIdOfActiveRuleParametersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/DropIndexOnActiveRuleIdOfActiveRuleParametersTableTest/schema.sql deleted file mode 100644 index fe510a7faaf..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/DropIndexOnActiveRuleIdOfActiveRuleParametersTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "ACTIVE_RULE_PARAMETERS"( - "ACTIVE_RULE_ID" INTEGER NOT NULL, - "ACTIVE_RULE_UUID" VARCHAR(40) NOT NULL, - "RULES_PARAMETER_ID" INTEGER NOT NULL, - "VALUE" VARCHAR(4000), - "RULES_PARAMETER_KEY" VARCHAR(128), - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("UUID"); -CREATE INDEX "IX_ARP_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/DropPrimaryKeyOnIdColumnOfActiveRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/DropPrimaryKeyOnIdColumnOfActiveRulesTableTest/schema.sql deleted file mode 100644 index 642bd8470a6..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/DropPrimaryKeyOnIdColumnOfActiveRulesTableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "ACTIVE_RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "PROFILE_ID" INTEGER NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "FAILURE_LEVEL" INTEGER NOT NULL, - "INHERITANCE" VARCHAR(10), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_ID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/MakeActiveRuleParametersActiveRuleUuidNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/MakeActiveRuleParametersActiveRuleUuidNotNullableTest/schema.sql deleted file mode 100644 index 0f789b84e93..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/MakeActiveRuleParametersActiveRuleUuidNotNullableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "ACTIVE_RULE_PARAMETERS"( - "ACTIVE_RULE_ID" INTEGER NOT NULL, - "ACTIVE_RULE_UUID" VARCHAR(40), - "RULES_PARAMETER_ID" INTEGER NOT NULL, - "VALUE" VARCHAR(4000), - "RULES_PARAMETER_KEY" VARCHAR(128), - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("UUID"); -CREATE INDEX "IX_ARP_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/MakeActiveRulesUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/MakeActiveRulesUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index 49569a9667a..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/MakeActiveRulesUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "ACTIVE_RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "PROFILE_ID" INTEGER NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "FAILURE_LEVEL" INTEGER NOT NULL, - "INHERITANCE" VARCHAR(10), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_ID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/PopulateActiveRuleParametersActiveRuleUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/PopulateActiveRuleParametersActiveRuleUuidTest/schema.sql deleted file mode 100644 index 5d00ec845ca..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/PopulateActiveRuleParametersActiveRuleUuidTest/schema.sql +++ /dev/null @@ -1,23 +0,0 @@ -CREATE TABLE "ACTIVE_RULE_PARAMETERS"( - "ACTIVE_RULE_ID" INTEGER NOT NULL, - "ACTIVE_RULE_UUID" VARCHAR(40), - "RULES_PARAMETER_ID" INTEGER NOT NULL, - "VALUE" VARCHAR(4000), - "RULES_PARAMETER_KEY" VARCHAR(128), - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("UUID"); -CREATE INDEX "IX_ARP_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_ID"); - -CREATE TABLE "ACTIVE_RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "PROFILE_ID" INTEGER NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "FAILURE_LEVEL" INTEGER NOT NULL, - "INHERITANCE" VARCHAR(10), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_ID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/PopulateActiveRulesUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/PopulateActiveRulesUuidTest/schema.sql deleted file mode 100644 index 49569a9667a..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/activerules/PopulateActiveRulesUuidTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "ACTIVE_RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "PROFILE_ID" INTEGER NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "FAILURE_LEVEL" INTEGER NOT NULL, - "INHERITANCE" VARCHAR(10), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_ID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTableTest/schema.sql deleted file mode 100644 index 22ed140880e..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTableTest/schema.sql +++ /dev/null @@ -1,32 +0,0 @@ -CREATE TABLE "CE_ACTIVITY"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "MAIN_COMPONENT_UUID" VARCHAR(40), - "COMPONENT_UUID" VARCHAR(40), - "STATUS" VARCHAR(15) NOT NULL, - "MAIN_IS_LAST" BOOLEAN NOT NULL, - "MAIN_IS_LAST_KEY" VARCHAR(55) NOT NULL, - "IS_LAST" BOOLEAN NOT NULL, - "IS_LAST_KEY" VARCHAR(55) NOT NULL, - "SUBMITTER_UUID" VARCHAR(255), - "SUBMITTED_AT" BIGINT NOT NULL, - "STARTED_AT" BIGINT, - "EXECUTED_AT" BIGINT, - "EXECUTION_COUNT" INTEGER NOT NULL, - "EXECUTION_TIME_MS" BIGINT, - "ANALYSIS_UUID" VARCHAR(50), - "ERROR_MESSAGE" VARCHAR(1000), - "ERROR_STACKTRACE" CLOB(2147483647), - "ERROR_TYPE" VARCHAR(20), - "WORKER_UUID" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE INDEX "CE_ACTIVITY_COMPONENT" ON "CE_ACTIVITY"("COMPONENT_UUID"); -CREATE INDEX "CE_ACTIVITY_ISLAST" ON "CE_ACTIVITY"("IS_LAST", "STATUS"); -CREATE INDEX "CE_ACTIVITY_ISLAST_KEY" ON "CE_ACTIVITY"("IS_LAST_KEY"); -CREATE INDEX "CE_ACTIVITY_MAIN_COMPONENT" ON "CE_ACTIVITY"("MAIN_COMPONENT_UUID"); -CREATE INDEX "CE_ACTIVITY_MAIN_ISLAST" ON "CE_ACTIVITY"("MAIN_IS_LAST", "STATUS"); -CREATE INDEX "CE_ACTIVITY_MAIN_ISLAST_KEY" ON "CE_ACTIVITY"("MAIN_IS_LAST_KEY"); -CREATE UNIQUE INDEX "CE_ACTIVITY_UUID" ON "CE_ACTIVITY"("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/ceactivity/DropIdColumnOfCeActivityTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/ceactivity/DropIdColumnOfCeActivityTableTest/schema.sql deleted file mode 100644 index 9aa76b650fd..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/ceactivity/DropIdColumnOfCeActivityTableTest/schema.sql +++ /dev/null @@ -1,33 +0,0 @@ -CREATE TABLE "CE_ACTIVITY"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "MAIN_COMPONENT_UUID" VARCHAR(40), - "COMPONENT_UUID" VARCHAR(40), - "STATUS" VARCHAR(15) NOT NULL, - "MAIN_IS_LAST" BOOLEAN NOT NULL, - "MAIN_IS_LAST_KEY" VARCHAR(55) NOT NULL, - "IS_LAST" BOOLEAN NOT NULL, - "IS_LAST_KEY" VARCHAR(55) NOT NULL, - "SUBMITTER_UUID" VARCHAR(255), - "SUBMITTED_AT" BIGINT NOT NULL, - "STARTED_AT" BIGINT, - "EXECUTED_AT" BIGINT, - "EXECUTION_COUNT" INTEGER NOT NULL, - "EXECUTION_TIME_MS" BIGINT, - "ANALYSIS_UUID" VARCHAR(50), - "ERROR_MESSAGE" VARCHAR(1000), - "ERROR_STACKTRACE" CLOB(2147483647), - "ERROR_TYPE" VARCHAR(20), - "WORKER_UUID" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "CE_ACTIVITY" ADD CONSTRAINT "PK_CE_ACTIVITY" PRIMARY KEY("UUID"); -CREATE INDEX "CE_ACTIVITY_COMPONENT" ON "CE_ACTIVITY"("COMPONENT_UUID"); -CREATE INDEX "CE_ACTIVITY_ISLAST" ON "CE_ACTIVITY"("IS_LAST", "STATUS"); -CREATE INDEX "CE_ACTIVITY_ISLAST_KEY" ON "CE_ACTIVITY"("IS_LAST_KEY"); -CREATE INDEX "CE_ACTIVITY_MAIN_COMPONENT" ON "CE_ACTIVITY"("MAIN_COMPONENT_UUID"); -CREATE INDEX "CE_ACTIVITY_MAIN_ISLAST" ON "CE_ACTIVITY"("MAIN_IS_LAST", "STATUS"); -CREATE INDEX "CE_ACTIVITY_MAIN_ISLAST_KEY" ON "CE_ACTIVITY"("MAIN_IS_LAST_KEY"); -CREATE UNIQUE INDEX "CE_ACTIVITY_UUID" ON "CE_ACTIVITY"("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTableTest/schema.sql deleted file mode 100644 index d8fec2db804..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTableTest/schema.sql +++ /dev/null @@ -1,33 +0,0 @@ -CREATE TABLE "CE_ACTIVITY"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "MAIN_COMPONENT_UUID" VARCHAR(40), - "COMPONENT_UUID" VARCHAR(40), - "STATUS" VARCHAR(15) NOT NULL, - "MAIN_IS_LAST" BOOLEAN NOT NULL, - "MAIN_IS_LAST_KEY" VARCHAR(55) NOT NULL, - "IS_LAST" BOOLEAN NOT NULL, - "IS_LAST_KEY" VARCHAR(55) NOT NULL, - "SUBMITTER_UUID" VARCHAR(255), - "SUBMITTED_AT" BIGINT NOT NULL, - "STARTED_AT" BIGINT, - "EXECUTED_AT" BIGINT, - "EXECUTION_COUNT" INTEGER NOT NULL, - "EXECUTION_TIME_MS" BIGINT, - "ANALYSIS_UUID" VARCHAR(50), - "ERROR_MESSAGE" VARCHAR(1000), - "ERROR_STACKTRACE" CLOB(2147483647), - "ERROR_TYPE" VARCHAR(20), - "WORKER_UUID" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "CE_ACTIVITY" ADD CONSTRAINT "PK_CE_ACTIVITY" PRIMARY KEY("ID"); -CREATE INDEX "CE_ACTIVITY_COMPONENT" ON "CE_ACTIVITY"("COMPONENT_UUID"); -CREATE INDEX "CE_ACTIVITY_ISLAST" ON "CE_ACTIVITY"("IS_LAST", "STATUS"); -CREATE INDEX "CE_ACTIVITY_ISLAST_KEY" ON "CE_ACTIVITY"("IS_LAST_KEY"); -CREATE INDEX "CE_ACTIVITY_MAIN_COMPONENT" ON "CE_ACTIVITY"("MAIN_COMPONENT_UUID"); -CREATE INDEX "CE_ACTIVITY_MAIN_ISLAST" ON "CE_ACTIVITY"("MAIN_IS_LAST", "STATUS"); -CREATE INDEX "CE_ACTIVITY_MAIN_ISLAST_KEY" ON "CE_ACTIVITY"("MAIN_IS_LAST_KEY"); -CREATE UNIQUE INDEX "CE_ACTIVITY_UUID" ON "CE_ACTIVITY"("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/cequeue/AddPrimaryKeyOnUuidColumnOfCeQueueTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/cequeue/AddPrimaryKeyOnUuidColumnOfCeQueueTableTest/schema.sql deleted file mode 100644 index bf5f23f3e28..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/cequeue/AddPrimaryKeyOnUuidColumnOfCeQueueTableTest/schema.sql +++ /dev/null @@ -1,16 +0,0 @@ -CREATE TABLE "CE_QUEUE"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "MAIN_COMPONENT_UUID" VARCHAR(40), - "COMPONENT_UUID" VARCHAR(40), - "STATUS" VARCHAR(15), - "SUBMITTER_UUID" VARCHAR(255), - "STARTED_AT" BIGINT, - "WORKER_UUID" VARCHAR(40), - "EXECUTION_COUNT" INTEGER NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE INDEX "CE_QUEUE_MAIN_COMPONENT" ON "CE_QUEUE"("MAIN_COMPONENT_UUID"); -CREATE INDEX "CE_QUEUE_COMPONENT" ON "CE_QUEUE"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/cequeue/DropIdColumnOfCeQueueTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/cequeue/DropIdColumnOfCeQueueTableTest/schema.sql deleted file mode 100644 index 48cfeb2001b..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/cequeue/DropIdColumnOfCeQueueTableTest/schema.sql +++ /dev/null @@ -1,17 +0,0 @@ -CREATE TABLE "CE_QUEUE"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "MAIN_COMPONENT_UUID" VARCHAR(40), - "COMPONENT_UUID" VARCHAR(40), - "STATUS" VARCHAR(15), - "SUBMITTER_UUID" VARCHAR(255), - "STARTED_AT" BIGINT, - "WORKER_UUID" VARCHAR(40), - "EXECUTION_COUNT" INTEGER NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "CE_QUEUE" ADD CONSTRAINT "PK_CE_QUEUE" PRIMARY KEY("UUID"); -CREATE INDEX "CE_QUEUE_MAIN_COMPONENT" ON "CE_QUEUE"("MAIN_COMPONENT_UUID"); -CREATE INDEX "CE_QUEUE_COMPONENT" ON "CE_QUEUE"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/cequeue/DropPrimaryKeyOnIdColumnOfCeQueueTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/cequeue/DropPrimaryKeyOnIdColumnOfCeQueueTableTest/schema.sql deleted file mode 100644 index ca173102b08..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/cequeue/DropPrimaryKeyOnIdColumnOfCeQueueTableTest/schema.sql +++ /dev/null @@ -1,17 +0,0 @@ -CREATE TABLE "CE_QUEUE"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "MAIN_COMPONENT_UUID" VARCHAR(40), - "COMPONENT_UUID" VARCHAR(40), - "STATUS" VARCHAR(15), - "SUBMITTER_UUID" VARCHAR(255), - "STARTED_AT" BIGINT, - "WORKER_UUID" VARCHAR(40), - "EXECUTION_COUNT" INTEGER NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "CE_QUEUE" ADD CONSTRAINT "PK_CE_QUEUE" PRIMARY KEY("ID"); -CREATE INDEX "CE_QUEUE_MAIN_COMPONENT" ON "CE_QUEUE"("MAIN_COMPONENT_UUID"); -CREATE INDEX "CE_QUEUE_COMPONENT" ON "CE_QUEUE"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/cequeue/DropUniqueIndexOnUuidColumnOfCeQueueTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/cequeue/DropUniqueIndexOnUuidColumnOfCeQueueTableTest/schema.sql deleted file mode 100644 index 8ab0a1195b3..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/cequeue/DropUniqueIndexOnUuidColumnOfCeQueueTableTest/schema.sql +++ /dev/null @@ -1,18 +0,0 @@ -CREATE TABLE "CE_QUEUE"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "TASK_TYPE" VARCHAR(15) NOT NULL, - "MAIN_COMPONENT_UUID" VARCHAR(40), - "COMPONENT_UUID" VARCHAR(40), - "STATUS" VARCHAR(15), - "SUBMITTER_UUID" VARCHAR(255), - "STARTED_AT" BIGINT, - "WORKER_UUID" VARCHAR(40), - "EXECUTION_COUNT" INTEGER NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "CE_QUEUE" ADD CONSTRAINT "PK_CE_QUEUE" PRIMARY KEY("ID"); -CREATE INDEX "CE_QUEUE_MAIN_COMPONENT" ON "CE_QUEUE"("MAIN_COMPONENT_UUID"); -CREATE INDEX "CE_QUEUE_COMPONENT" ON "CE_QUEUE"("COMPONENT_UUID"); -CREATE UNIQUE INDEX "CE_QUEUE_UUID" ON "CE_QUEUE"("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTableTest/schema.sql deleted file mode 100644 index de4522b3c84..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "DUPLICATIONS_INDEX"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "HASH" VARCHAR(50) NOT NULL, - "INDEX_IN_FILE" INTEGER NOT NULL, - "START_LINE" INTEGER NOT NULL, - "END_LINE" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL -); -CREATE INDEX "DUPLICATIONS_INDEX_HASH" ON "DUPLICATIONS_INDEX"("HASH"); -CREATE INDEX "DUPLICATION_ANALYSIS_COMPONENT" ON "DUPLICATIONS_INDEX"("ANALYSIS_UUID", "COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/AddUuidToDuplicationsIndexTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/AddUuidToDuplicationsIndexTableTest/schema.sql deleted file mode 100644 index f0001521878..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/AddUuidToDuplicationsIndexTableTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "DUPLICATIONS_INDEX"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "HASH" VARCHAR(50) NOT NULL, - "INDEX_IN_FILE" INTEGER NOT NULL, - "START_LINE" INTEGER NOT NULL, - "END_LINE" INTEGER NOT NULL -); -ALTER TABLE "DUPLICATIONS_INDEX" ADD CONSTRAINT "PK_DUPLICATIONS_INDEX" PRIMARY KEY("ID"); -CREATE INDEX "DUPLICATIONS_INDEX_HASH" ON "DUPLICATIONS_INDEX"("HASH"); -CREATE INDEX "DUPLICATION_ANALYSIS_COMPONENT" ON "DUPLICATIONS_INDEX"("ANALYSIS_UUID", "COMPONENT_UUID"); - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/DropIdColumnOfDuplicationsIndexTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/DropIdColumnOfDuplicationsIndexTableTest/schema.sql deleted file mode 100644 index 1399658a241..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/DropIdColumnOfDuplicationsIndexTableTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "DUPLICATIONS_INDEX"( - "ID" BIGINT NOT NULL, - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "HASH" VARCHAR(50) NOT NULL, - "INDEX_IN_FILE" INTEGER NOT NULL, - "START_LINE" INTEGER NOT NULL, - "END_LINE" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, -); -ALTER TABLE "DUPLICATIONS_INDEX" ADD CONSTRAINT "PK_DUPLICATIONS_INDEX" PRIMARY KEY("UUID"); -CREATE INDEX "DUPLICATIONS_INDEX_HASH" ON "DUPLICATIONS_INDEX"("HASH"); -CREATE INDEX "DUPLICATION_ANALYSIS_COMPONENT" ON "DUPLICATIONS_INDEX"("ANALYSIS_UUID", "COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/DropPrimaryKeyOnIdColumnOfDuplicationsIndexTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/DropPrimaryKeyOnIdColumnOfDuplicationsIndexTableTest/schema.sql deleted file mode 100644 index e8f7a1414be..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/DropPrimaryKeyOnIdColumnOfDuplicationsIndexTableTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "DUPLICATIONS_INDEX"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "HASH" VARCHAR(50) NOT NULL, - "INDEX_IN_FILE" INTEGER NOT NULL, - "START_LINE" INTEGER NOT NULL, - "END_LINE" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, -); -ALTER TABLE "DUPLICATIONS_INDEX" ADD CONSTRAINT "PK_DUPLICATIONS_INDEX" PRIMARY KEY("ID"); -CREATE INDEX "DUPLICATIONS_INDEX_HASH" ON "DUPLICATIONS_INDEX"("HASH"); -CREATE INDEX "DUPLICATION_ANALYSIS_COMPONENT" ON "DUPLICATIONS_INDEX"("ANALYSIS_UUID", "COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/MakeDuplicationsIndexUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/MakeDuplicationsIndexUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index 6432378da7b..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/MakeDuplicationsIndexUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "DUPLICATIONS_INDEX"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "HASH" VARCHAR(50) NOT NULL, - "INDEX_IN_FILE" INTEGER NOT NULL, - "START_LINE" INTEGER NOT NULL, - "END_LINE" INTEGER NOT NULL, - "UUID" VARCHAR(40) -); -ALTER TABLE "DUPLICATIONS_INDEX" ADD CONSTRAINT "PK_DUPLICATIONS_INDEX" PRIMARY KEY("ID"); -CREATE INDEX "DUPLICATIONS_INDEX_HASH" ON "DUPLICATIONS_INDEX"("HASH"); -CREATE INDEX "DUPLICATION_ANALYSIS_COMPONENT" ON "DUPLICATIONS_INDEX"("ANALYSIS_UUID", "COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/PopulateDuplicationsIndexUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/PopulateDuplicationsIndexUuidTest/schema.sql deleted file mode 100644 index 6432378da7b..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/duplicationsindex/PopulateDuplicationsIndexUuidTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "DUPLICATIONS_INDEX"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "HASH" VARCHAR(50) NOT NULL, - "INDEX_IN_FILE" INTEGER NOT NULL, - "START_LINE" INTEGER NOT NULL, - "END_LINE" INTEGER NOT NULL, - "UUID" VARCHAR(40) -); -ALTER TABLE "DUPLICATIONS_INDEX" ADD CONSTRAINT "PK_DUPLICATIONS_INDEX" PRIMARY KEY("ID"); -CREATE INDEX "DUPLICATIONS_INDEX_HASH" ON "DUPLICATIONS_INDEX"("HASH"); -CREATE INDEX "DUPLICATION_ANALYSIS_COMPONENT" ON "DUPLICATIONS_INDEX"("ANALYSIS_UUID", "COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/events/AddPrimaryKeyOnUuidColumnOfEventsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/events/AddPrimaryKeyOnUuidColumnOfEventsTableTest/schema.sql deleted file mode 100644 index bd6b897194c..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/events/AddPrimaryKeyOnUuidColumnOfEventsTableTest/schema.sql +++ /dev/null @@ -1,15 +0,0 @@ -CREATE TABLE "EVENTS"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "NAME" VARCHAR(400), - "CATEGORY" VARCHAR(50), - "DESCRIPTION" VARCHAR(4000), - "EVENT_DATA" VARCHAR(4000), - "EVENT_DATE" BIGINT NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL -); -CREATE UNIQUE INDEX "EVENTS_UUID" ON "EVENTS"("UUID"); -CREATE INDEX "EVENTS_ANALYSIS" ON "EVENTS"("ANALYSIS_UUID"); -CREATE INDEX "EVENTS_COMPONENT_UUID" ON "EVENTS"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/events/DropIdColumnOfEventsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/events/DropIdColumnOfEventsTableTest/schema.sql deleted file mode 100644 index ac79cfaaf79..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/events/DropIdColumnOfEventsTableTest/schema.sql +++ /dev/null @@ -1,16 +0,0 @@ -CREATE TABLE "EVENTS"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "NAME" VARCHAR(400), - "CATEGORY" VARCHAR(50), - "DESCRIPTION" VARCHAR(4000), - "EVENT_DATA" VARCHAR(4000), - "EVENT_DATE" BIGINT NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL -); -ALTER TABLE "EVENTS" ADD CONSTRAINT "PK_EVENTS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "EVENTS_UUID" ON "EVENTS"("UUID"); -CREATE INDEX "EVENTS_ANALYSIS" ON "EVENTS"("ANALYSIS_UUID"); -CREATE INDEX "EVENTS_COMPONENT_UUID" ON "EVENTS"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/events/DropPrimaryKeyOnIdColumnOfEventsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/events/DropPrimaryKeyOnIdColumnOfEventsTableTest/schema.sql deleted file mode 100644 index 2f03d9d6661..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/events/DropPrimaryKeyOnIdColumnOfEventsTableTest/schema.sql +++ /dev/null @@ -1,16 +0,0 @@ -CREATE TABLE "EVENTS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "NAME" VARCHAR(400), - "CATEGORY" VARCHAR(50), - "DESCRIPTION" VARCHAR(4000), - "EVENT_DATA" VARCHAR(4000), - "EVENT_DATE" BIGINT NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL -); -ALTER TABLE "EVENTS" ADD CONSTRAINT "PK_EVENTS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "EVENTS_UUID" ON "EVENTS"("UUID"); -CREATE INDEX "EVENTS_ANALYSIS" ON "EVENTS"("ANALYSIS_UUID"); -CREATE INDEX "EVENTS_COMPONENT_UUID" ON "EVENTS"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/filesources/AddPrimaryKeyOnUuidColumnOfFileSourcesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/filesources/AddPrimaryKeyOnUuidColumnOfFileSourcesTableTest/schema.sql deleted file mode 100644 index dfb2d817bc7..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/filesources/AddPrimaryKeyOnUuidColumnOfFileSourcesTableTest/schema.sql +++ /dev/null @@ -1,18 +0,0 @@ -CREATE TABLE "FILE_SOURCES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "FILE_UUID" VARCHAR(50) NOT NULL, - "LINE_HASHES" CLOB(2147483647), - "LINE_HASHES_VERSION" INTEGER, - "DATA_HASH" VARCHAR(50), - "SRC_HASH" VARCHAR(50), - "REVISION" VARCHAR(100), - "LINE_COUNT" INTEGER NOT NULL, - "BINARY_DATA" BLOB, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "FILE_SOURCES_FILE_UUID" ON "FILE_SOURCES"("FILE_UUID"); -CREATE INDEX "FILE_SOURCES_PROJECT_UUID" ON "FILE_SOURCES"("PROJECT_UUID"); -CREATE INDEX "FILE_SOURCES_UPDATED_AT" ON "FILE_SOURCES"("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/filesources/AddUuidColumnToFileSourcesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/filesources/AddUuidColumnToFileSourcesTableTest/schema.sql deleted file mode 100644 index 179847ee2ce..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/filesources/AddUuidColumnToFileSourcesTableTest/schema.sql +++ /dev/null @@ -1,18 +0,0 @@ -CREATE TABLE "FILE_SOURCES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "FILE_UUID" VARCHAR(50) NOT NULL, - "LINE_HASHES" CLOB(2147483647), - "LINE_HASHES_VERSION" INTEGER, - "DATA_HASH" VARCHAR(50), - "SRC_HASH" VARCHAR(50), - "REVISION" VARCHAR(100), - "LINE_COUNT" INTEGER NOT NULL, - "BINARY_DATA" BLOB, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "FILE_SOURCES" ADD CONSTRAINT "PK_FILE_SOURCES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "FILE_SOURCES_FILE_UUID" ON "FILE_SOURCES"("FILE_UUID"); -CREATE INDEX "FILE_SOURCES_PROJECT_UUID" ON "FILE_SOURCES"("PROJECT_UUID"); -CREATE INDEX "FILE_SOURCES_UPDATED_AT" ON "FILE_SOURCES"("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/filesources/DropIdColumnOfFileSourcesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/filesources/DropIdColumnOfFileSourcesTableTest/schema.sql deleted file mode 100644 index 3dab0132b33..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/filesources/DropIdColumnOfFileSourcesTableTest/schema.sql +++ /dev/null @@ -1,19 +0,0 @@ -CREATE TABLE "FILE_SOURCES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "FILE_UUID" VARCHAR(50) NOT NULL, - "LINE_HASHES" CLOB(2147483647), - "LINE_HASHES_VERSION" INTEGER, - "DATA_HASH" VARCHAR(50), - "SRC_HASH" VARCHAR(50), - "REVISION" VARCHAR(100), - "LINE_COUNT" INTEGER NOT NULL, - "BINARY_DATA" BLOB, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "FILE_SOURCES" ADD CONSTRAINT "PK_FILE_SOURCES" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "FILE_SOURCES_FILE_UUID" ON "FILE_SOURCES"("FILE_UUID"); -CREATE INDEX "FILE_SOURCES_PROJECT_UUID" ON "FILE_SOURCES"("PROJECT_UUID"); -CREATE INDEX "FILE_SOURCES_UPDATED_AT" ON "FILE_SOURCES"("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/filesources/DropPrimaryKeyOnIdColumnOfFileSourcesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/filesources/DropPrimaryKeyOnIdColumnOfFileSourcesTableTest/schema.sql deleted file mode 100644 index a6a2a841f83..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/filesources/DropPrimaryKeyOnIdColumnOfFileSourcesTableTest/schema.sql +++ /dev/null @@ -1,19 +0,0 @@ -CREATE TABLE "FILE_SOURCES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "FILE_UUID" VARCHAR(50) NOT NULL, - "LINE_HASHES" CLOB(2147483647), - "LINE_HASHES_VERSION" INTEGER, - "DATA_HASH" VARCHAR(50), - "SRC_HASH" VARCHAR(50), - "REVISION" VARCHAR(100), - "LINE_COUNT" INTEGER NOT NULL, - "BINARY_DATA" BLOB, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "FILE_SOURCES" ADD CONSTRAINT "PK_FILE_SOURCES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "FILE_SOURCES_FILE_UUID" ON "FILE_SOURCES"("FILE_UUID"); -CREATE INDEX "FILE_SOURCES_PROJECT_UUID" ON "FILE_SOURCES"("PROJECT_UUID"); -CREATE INDEX "FILE_SOURCES_UPDATED_AT" ON "FILE_SOURCES"("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/filesources/MakeFileSourcesUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/filesources/MakeFileSourcesUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index 559418594f8..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/filesources/MakeFileSourcesUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,19 +0,0 @@ -CREATE TABLE "FILE_SOURCES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "FILE_UUID" VARCHAR(50) NOT NULL, - "LINE_HASHES" CLOB(2147483647), - "LINE_HASHES_VERSION" INTEGER, - "DATA_HASH" VARCHAR(50), - "SRC_HASH" VARCHAR(50), - "REVISION" VARCHAR(100), - "LINE_COUNT" INTEGER NOT NULL, - "BINARY_DATA" BLOB, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "FILE_SOURCES" ADD CONSTRAINT "PK_FILE_SOURCES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "FILE_SOURCES_FILE_UUID" ON "FILE_SOURCES"("FILE_UUID"); -CREATE INDEX "FILE_SOURCES_PROJECT_UUID" ON "FILE_SOURCES"("PROJECT_UUID"); -CREATE INDEX "FILE_SOURCES_UPDATED_AT" ON "FILE_SOURCES"("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/filesources/PopulateFileSourcesUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/filesources/PopulateFileSourcesUuidTest/schema.sql deleted file mode 100644 index 559418594f8..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/filesources/PopulateFileSourcesUuidTest/schema.sql +++ /dev/null @@ -1,19 +0,0 @@ -CREATE TABLE "FILE_SOURCES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "FILE_UUID" VARCHAR(50) NOT NULL, - "LINE_HASHES" CLOB(2147483647), - "LINE_HASHES_VERSION" INTEGER, - "DATA_HASH" VARCHAR(50), - "SRC_HASH" VARCHAR(50), - "REVISION" VARCHAR(100), - "LINE_COUNT" INTEGER NOT NULL, - "BINARY_DATA" BLOB, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "FILE_SOURCES" ADD CONSTRAINT "PK_FILE_SOURCES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "FILE_SOURCES_FILE_UUID" ON "FILE_SOURCES"("FILE_UUID"); -CREATE INDEX "FILE_SOURCES_PROJECT_UUID" ON "FILE_SOURCES"("PROJECT_UUID"); -CREATE INDEX "FILE_SOURCES_UPDATED_AT" ON "FILE_SOURCES"("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/grouproles/AddPrimaryKeyOnUuidColumnOfGroupRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/grouproles/AddPrimaryKeyOnUuidColumnOfGroupRolesTableTest/schema.sql deleted file mode 100644 index 3203c1421d1..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/grouproles/AddPrimaryKeyOnUuidColumnOfGroupRolesTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "GROUP_ROLES"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) -); - -CREATE INDEX "GROUP_ROLES_COMPONENT_UUID" ON "GROUP_ROLES"("COMPONENT_UUID"); -CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES"("ORGANIZATION_UUID", "GROUP_ID", "COMPONENT_UUID", "ROLE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/grouproles/AddUuidColumnToGroupRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/grouproles/AddUuidColumnToGroupRolesTableTest/schema.sql deleted file mode 100644 index b91324d4572..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/grouproles/AddUuidColumnToGroupRolesTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "GROUP_ROLES"( - "ID" INTEGER NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) -); -ALTER TABLE "GROUP_ROLES" ADD CONSTRAINT "PK_GROUP_ROLES" PRIMARY KEY("ID"); -CREATE INDEX "GROUP_ROLES_COMPONENT_UUID" ON "GROUP_ROLES"("COMPONENT_UUID"); -CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES"("ORGANIZATION_UUID", "GROUP_ID", "COMPONENT_UUID", "ROLE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/grouproles/DropIdColumnOfGroupRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/grouproles/DropIdColumnOfGroupRolesTableTest/schema.sql deleted file mode 100644 index 7ecca2b6b71..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/grouproles/DropIdColumnOfGroupRolesTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "GROUP_ROLES"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) -); -ALTER TABLE "GROUP_ROLES" ADD CONSTRAINT "PK_GROUP_ROLES" PRIMARY KEY("UUID"); -CREATE INDEX "GROUP_ROLES_COMPONENT_UUID" ON "GROUP_ROLES"("COMPONENT_UUID"); -CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES"("ORGANIZATION_UUID", "GROUP_ID", "COMPONENT_UUID", "ROLE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/grouproles/DropPrimaryKeyOnIdColumnOfGroupRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/grouproles/DropPrimaryKeyOnIdColumnOfGroupRolesTableTest/schema.sql deleted file mode 100644 index d7d1320aebe..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/grouproles/DropPrimaryKeyOnIdColumnOfGroupRolesTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "GROUP_ROLES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) -); -ALTER TABLE "GROUP_ROLES" ADD CONSTRAINT "PK_GROUP_ROLES" PRIMARY KEY("ID"); -CREATE INDEX "GROUP_ROLES_COMPONENT_UUID" ON "GROUP_ROLES"("COMPONENT_UUID"); -CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES"("ORGANIZATION_UUID", "GROUP_ID", "COMPONENT_UUID", "ROLE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/grouproles/MakeGroupRolesUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/grouproles/MakeGroupRolesUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index 7c73be272fd..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/grouproles/MakeGroupRolesUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "GROUP_ROLES"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) -); -ALTER TABLE "GROUP_ROLES" ADD CONSTRAINT "PK_GROUP_ROLES" PRIMARY KEY("ID"); -CREATE INDEX "GROUP_ROLES_COMPONENT_UUID" ON "GROUP_ROLES"("COMPONENT_UUID"); -CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES"("ORGANIZATION_UUID", "GROUP_ID", "COMPONENT_UUID", "ROLE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/grouproles/PopulateGroupRolesUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/grouproles/PopulateGroupRolesUuidTest/schema.sql deleted file mode 100644 index 7c73be272fd..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/grouproles/PopulateGroupRolesUuidTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "GROUP_ROLES"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) -); -ALTER TABLE "GROUP_ROLES" ADD CONSTRAINT "PK_GROUP_ROLES" PRIMARY KEY("ID"); -CREATE INDEX "GROUP_ROLES_COMPONENT_UUID" ON "GROUP_ROLES"("COMPONENT_UUID"); -CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES"("ORGANIZATION_UUID", "GROUP_ID", "COMPONENT_UUID", "ROLE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/AddPrimaryKeyOnUuidColumnOfGroupsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/AddPrimaryKeyOnUuidColumnOfGroupsTableTest/schema.sql deleted file mode 100644 index 8b2000be3e9..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/AddPrimaryKeyOnUuidColumnOfGroupsTableTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "GROUPS"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(500), - "DESCRIPTION" VARCHAR(200), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/AddUuidColumnToGroupsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/AddUuidColumnToGroupsTableTest/schema.sql deleted file mode 100644 index a20ddd6ac66..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/AddUuidColumnToGroupsTableTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "GROUPS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(500), - "DESCRIPTION" VARCHAR(200), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "GROUPS" ADD CONSTRAINT "PK_GROUPS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/DropIdColumnOfGroupsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/DropIdColumnOfGroupsTableTest/schema.sql deleted file mode 100644 index 963af911d8a..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/DropIdColumnOfGroupsTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "GROUPS"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(500), - "DESCRIPTION" VARCHAR(200), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "GROUPS" ADD CONSTRAINT "PK_GROUPS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/DropPrimaryKeyOnIdColumnOfGroupsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/DropPrimaryKeyOnIdColumnOfGroupsTableTest/schema.sql deleted file mode 100644 index 3b127b99e7a..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/DropPrimaryKeyOnIdColumnOfGroupsTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "GROUPS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(500), - "DESCRIPTION" VARCHAR(200), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "GROUPS" ADD CONSTRAINT "PK_GROUPS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/MakeGroupsUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/MakeGroupsUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index 5c6c10fce76..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/MakeGroupsUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "GROUPS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(500), - "DESCRIPTION" VARCHAR(200), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "GROUPS" ADD CONSTRAINT "PK_GROUPS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/PopulateGroupsUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/PopulateGroupsUuidTest/schema.sql deleted file mode 100644 index 5c6c10fce76..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/PopulateGroupsUuidTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "GROUPS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(500), - "DESCRIPTION" VARCHAR(200), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "GROUPS" ADD CONSTRAINT "PK_GROUPS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/AddGroupUuidColumnToGroupRolesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/AddGroupUuidColumnToGroupRolesTest/schema.sql deleted file mode 100644 index 3395ab556f2..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/AddGroupUuidColumnToGroupRolesTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "GROUP_ROLES"( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40), - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "GROUP_ROLES" ADD CONSTRAINT "PK_GROUP_ROLES" PRIMARY KEY("UUID"); -CREATE INDEX "GROUP_ROLES_COMPONENT_UUID" ON "GROUP_ROLES"("COMPONENT_UUID"); -CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES"("ORGANIZATION_UUID", "GROUP_ID", "COMPONENT_UUID", "ROLE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/AddIndexOnGroupUuidOfGroupRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/AddIndexOnGroupUuidOfGroupRolesTableTest/schema.sql deleted file mode 100644 index f1f49219014..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/AddIndexOnGroupUuidOfGroupRolesTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "GROUP_ROLES"( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER, - "GROUP_UUID" VARCHAR(40) NOT NULL, - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40), - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "GROUP_ROLES" ADD CONSTRAINT "PK_GROUP_ROLES" PRIMARY KEY("UUID"); -CREATE INDEX "GROUP_ROLES_COMPONENT_UUID" ON "GROUP_ROLES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/DropGroupIdColumnOfGroupRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/DropGroupIdColumnOfGroupRolesTableTest/schema.sql deleted file mode 100644 index 2e809ae1a2e..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/DropGroupIdColumnOfGroupRolesTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "GROUP_ROLES"( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER, - "GROUP_UUID" VARCHAR(40) NOT NULL, - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40), - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "GROUP_ROLES" ADD CONSTRAINT "PK_GROUP_ROLES" PRIMARY KEY("UUID"); -CREATE INDEX "GROUP_ROLES_COMPONENT_UUID" ON "GROUP_ROLES"("COMPONENT_UUID"); -CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES"("ORGANIZATION_UUID", "GROUP_UUID", "COMPONENT_UUID", "ROLE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/DropIndexOnGroupIdOfGroupRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/DropIndexOnGroupIdOfGroupRolesTableTest/schema.sql deleted file mode 100644 index a17d5208a43..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/DropIndexOnGroupIdOfGroupRolesTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "GROUP_ROLES"( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER, - "GROUP_UUID" VARCHAR(40) NOT NULL, - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40), - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "GROUP_ROLES" ADD CONSTRAINT "PK_GROUP_ROLES" PRIMARY KEY("UUID"); -CREATE INDEX "GROUP_ROLES_COMPONENT_UUID" ON "GROUP_ROLES"("COMPONENT_UUID"); -CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES"("ORGANIZATION_UUID", "GROUP_ID", "COMPONENT_UUID", "ROLE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/PopulateGroupRolesGroupUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/PopulateGroupRolesGroupUuidTest/schema.sql deleted file mode 100644 index dbed7d09f4f..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/grouproles/PopulateGroupRolesGroupUuidTest/schema.sql +++ /dev/null @@ -1,22 +0,0 @@ -CREATE TABLE "GROUPS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(500), - "DESCRIPTION" VARCHAR(200), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "GROUPS" ADD CONSTRAINT "PK_GROUPS" PRIMARY KEY("ID"); - -CREATE TABLE "GROUP_ROLES"( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER, - "GROUP_UUID" VARCHAR(40), - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40), - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "GROUP_ROLES" ADD CONSTRAINT "PK_GROUP_ROLES" PRIMARY KEY("UUID"); -CREATE INDEX "GROUP_ROLES_COMPONENT_UUID" ON "GROUP_ROLES"("COMPONENT_UUID"); -CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES"("ORGANIZATION_UUID", "GROUP_ID", "COMPONENT_UUID", "ROLE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/AddGroupUuidColumnToGroupsUsersTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/AddGroupUuidColumnToGroupsUsersTest/schema.sql deleted file mode 100644 index 0d7bb6e917a..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/AddGroupUuidColumnToGroupsUsersTest/schema.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE "GROUPS_USERS"( - "USER_ID" BIGINT, - "GROUP_ID" BIGINT -); -CREATE INDEX "INDEX_GROUPS_USERS_ON_USER_ID" ON "GROUPS_USERS"("USER_ID"); -CREATE INDEX "INDEX_GROUPS_USERS_ON_GROUP_ID" ON "GROUPS_USERS"("GROUP_ID"); -CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS"("GROUP_ID", "USER_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/AddIndexOnGroupUuidOfGroupsUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/AddIndexOnGroupUuidOfGroupsUsersTableTest/schema.sql deleted file mode 100644 index 4f926b037ad..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/AddIndexOnGroupUuidOfGroupsUsersTableTest/schema.sql +++ /dev/null @@ -1,6 +0,0 @@ -CREATE TABLE "GROUPS_USERS"( - "USER_ID" BIGINT, - "GROUP_UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" BIGINT -); -CREATE INDEX "INDEX_GROUPS_USERS_ON_USER_ID" ON "GROUPS_USERS"("USER_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/DropGroupIdColumnOfGroupsUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/DropGroupIdColumnOfGroupsUsersTableTest/schema.sql deleted file mode 100644 index 6f1ef46cb30..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/DropGroupIdColumnOfGroupsUsersTableTest/schema.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE "GROUPS_USERS"( - "USER_ID" BIGINT, - "GROUP_UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" BIGINT -); -CREATE INDEX "INDEX_GROUPS_USERS_ON_USER_ID" ON "GROUPS_USERS"("USER_ID"); -CREATE INDEX "INDEX_GROUPS_USERS_GROUP_UUID" ON "GROUPS_USERS"("GROUP_UUID"); -CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS"("GROUP_UUID", "USER_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/DropIndexOnGroupIdOfGroupsUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/DropIndexOnGroupIdOfGroupsUsersTableTest/schema.sql deleted file mode 100644 index 214ddd1af92..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/DropIndexOnGroupIdOfGroupsUsersTableTest/schema.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE "GROUPS_USERS"( - "USER_ID" BIGINT, - "GROUP_UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" BIGINT -); -CREATE INDEX "INDEX_GROUPS_USERS_ON_USER_ID" ON "GROUPS_USERS"("USER_ID"); -CREATE INDEX "INDEX_GROUPS_USERS_ON_GROUP_ID" ON "GROUPS_USERS"("GROUP_ID"); -CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS"("GROUP_ID", "USER_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/MakeGroupsUsersGroupUuidNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/MakeGroupsUsersGroupUuidNotNullableTest/schema.sql deleted file mode 100644 index 4614b88b6f9..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/MakeGroupsUsersGroupUuidNotNullableTest/schema.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE "GROUPS_USERS"( - "USER_ID" BIGINT, - "GROUP_UUID" VARCHAR(40), - "GROUP_ID" BIGINT -); -CREATE INDEX "INDEX_GROUPS_USERS_ON_USER_ID" ON "GROUPS_USERS"("USER_ID"); -CREATE INDEX "INDEX_GROUPS_USERS_ON_GROUP_ID" ON "GROUPS_USERS"("GROUP_ID"); -CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS"("GROUP_ID", "USER_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/PopulateGroupsUsersGroupUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/PopulateGroupsUsersGroupUuidTest/schema.sql deleted file mode 100644 index f3c7d7266a8..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/groupsusers/PopulateGroupsUsersGroupUuidTest/schema.sql +++ /dev/null @@ -1,19 +0,0 @@ -CREATE TABLE "GROUPS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(500), - "DESCRIPTION" VARCHAR(200), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "GROUPS" ADD CONSTRAINT "PK_GROUPS" PRIMARY KEY("ID"); - -CREATE TABLE "GROUPS_USERS"( - "USER_ID" BIGINT, - "GROUP_UUID" VARCHAR(40), - "GROUP_ID" BIGINT -); -CREATE INDEX "INDEX_GROUPS_USERS_ON_USER_ID" ON "GROUPS_USERS"("USER_ID"); -CREATE INDEX "INDEX_GROUPS_USERS_ON_GROUP_ID" ON "GROUPS_USERS"("GROUP_ID"); -CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS"("GROUP_ID", "USER_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/organizations/AddDefaultGroupUuidColumnToOrganizationsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/organizations/AddDefaultGroupUuidColumnToOrganizationsTest/schema.sql deleted file mode 100644 index 169cf356975..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/organizations/AddDefaultGroupUuidColumnToOrganizationsTest/schema.sql +++ /dev/null @@ -1,20 +0,0 @@ -CREATE TABLE "ORGANIZATIONS"( - "UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(255) NOT NULL, - "NAME" VARCHAR(255) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN, - "DEFAULT_GROUP_ID" INTEGER, - "DEFAULT_QUALITY_GATE_UUID" VARCHAR(40) NOT NULL, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_APP" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_PORT" VARCHAR(40), - "NEW_PROJECT_PRIVATE" BOOLEAN NOT NULL, - "SUBSCRIPTION" VARCHAR(40) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "ORGANIZATIONS" ADD CONSTRAINT "PK_ORGANIZATIONS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "ORGANIZATION_KEY" ON "ORGANIZATIONS"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/organizations/DropDefaultGroupIdColumnOfOrganizationsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/organizations/DropDefaultGroupIdColumnOfOrganizationsTableTest/schema.sql deleted file mode 100644 index 65e6acd5661..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/organizations/DropDefaultGroupIdColumnOfOrganizationsTableTest/schema.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TABLE "ORGANIZATIONS"( - "UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(255) NOT NULL, - "NAME" VARCHAR(255) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN, - "DEFAULT_GROUP_ID" INTEGER, - "DEFAULT_GROUP_UUID" VARCHAR(40), - "DEFAULT_QUALITY_GATE_UUID" VARCHAR(40) NOT NULL, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_APP" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_PORT" VARCHAR(40), - "NEW_PROJECT_PRIVATE" BOOLEAN NOT NULL, - "SUBSCRIPTION" VARCHAR(40) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "ORGANIZATIONS" ADD CONSTRAINT "PK_ORGANIZATIONS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "ORGANIZATION_KEY" ON "ORGANIZATIONS"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/organizations/PopulateOrganizationsDefaultGroupUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/organizations/PopulateOrganizationsDefaultGroupUuidTest/schema.sql deleted file mode 100644 index 6ecb376b33b..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/organizations/PopulateOrganizationsDefaultGroupUuidTest/schema.sql +++ /dev/null @@ -1,32 +0,0 @@ -CREATE TABLE "GROUPS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(500), - "DESCRIPTION" VARCHAR(200), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "GROUPS" ADD CONSTRAINT "PK_GROUPS" PRIMARY KEY("ID"); - -CREATE TABLE "ORGANIZATIONS"( - "UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(255) NOT NULL, - "NAME" VARCHAR(255) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "GUARDED" BOOLEAN, - "DEFAULT_GROUP_ID" INTEGER, - "DEFAULT_GROUP_UUID" VARCHAR(40), - "DEFAULT_QUALITY_GATE_UUID" VARCHAR(40) NOT NULL, - "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_APP" VARCHAR(40), - "DEFAULT_PERM_TEMPLATE_PORT" VARCHAR(40), - "NEW_PROJECT_PRIVATE" BOOLEAN NOT NULL, - "SUBSCRIPTION" VARCHAR(40) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "ORGANIZATIONS" ADD CONSTRAINT "PK_ORGANIZATIONS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "ORGANIZATION_KEY" ON "ORGANIZATIONS"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/permtemplatesgroups/AddGroupUuidColumnToPermTemplatesGroupsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/permtemplatesgroups/AddGroupUuidColumnToPermTemplatesGroupsTest/schema.sql deleted file mode 100644 index f8f880ba7d6..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/permtemplatesgroups/AddGroupUuidColumnToPermTemplatesGroupsTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_GROUPS"( - "GROUP_ID" INTEGER, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "PERM_TEMPLATES_GROUPS" ADD CONSTRAINT "PK_PERM_TEMPLATES_GROUPS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/permtemplatesgroups/DropGroupIdColumnOfPermTemplatesGroupsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/permtemplatesgroups/DropGroupIdColumnOfPermTemplatesGroupsTableTest/schema.sql deleted file mode 100644 index fa92bad8669..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/permtemplatesgroups/DropGroupIdColumnOfPermTemplatesGroupsTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_GROUPS"( - "GROUP_ID" INTEGER, - "GROUP_UUID" VARCHAR(40), - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "PERM_TEMPLATES_GROUPS" ADD CONSTRAINT "PK_PERM_TEMPLATES_GROUPS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/permtemplatesgroups/PopulatePermTemplatesGroupsGroupUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/permtemplatesgroups/PopulatePermTemplatesGroupsGroupUuidTest/schema.sql deleted file mode 100644 index d7f1b662726..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/permtemplatesgroups/PopulatePermTemplatesGroupsGroupUuidTest/schema.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TABLE "GROUPS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(500), - "DESCRIPTION" VARCHAR(200), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "GROUPS" ADD CONSTRAINT "PK_GROUPS" PRIMARY KEY("ID"); - -CREATE TABLE "PERM_TEMPLATES_GROUPS"( - "GROUP_ID" INTEGER, - "GROUP_UUID" VARCHAR(40), - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "PERM_TEMPLATES_GROUPS" ADD CONSTRAINT "PK_PERM_TEMPLATES_GROUPS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/AddGroupUuidColumnToQProfileEditGroupsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/AddGroupUuidColumnToQProfileEditGroupsTest/schema.sql deleted file mode 100644 index b375127ef24..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/AddGroupUuidColumnToQProfileEditGroupsTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "QPROFILE_EDIT_GROUPS"( - "UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER NOT NULL, - "QPROFILE_UUID" VARCHAR(255) NOT NULL, - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "QPROFILE_EDIT_GROUPS" ADD CONSTRAINT "PK_QPROFILE_EDIT_GROUPS" PRIMARY KEY("UUID"); -CREATE INDEX "QPROFILE_EDIT_GROUPS_QPROFILE" ON "QPROFILE_EDIT_GROUPS"("QPROFILE_UUID"); -CREATE UNIQUE INDEX "QPROFILE_EDIT_GROUPS_UNIQUE" ON "QPROFILE_EDIT_GROUPS"("GROUP_ID", "QPROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/AddIndexOnGroupUuidOfQProfileEditGroupsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/AddIndexOnGroupUuidOfQProfileEditGroupsTableTest/schema.sql deleted file mode 100644 index d7d22ae97b6..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/AddIndexOnGroupUuidOfQProfileEditGroupsTableTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "QPROFILE_EDIT_GROUPS"( - "UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER NOT NULL, - "GROUP_UUID" VARCHAR(40) NOT NULL, - "QPROFILE_UUID" VARCHAR(255) NOT NULL, - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "QPROFILE_EDIT_GROUPS" ADD CONSTRAINT "PK_QPROFILE_EDIT_GROUPS" PRIMARY KEY("UUID"); -CREATE INDEX "QPROFILE_EDIT_GROUPS_QPROFILE" ON "QPROFILE_EDIT_GROUPS"("QPROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/DropGroupIdColumnOfQProfileEditGroupsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/DropGroupIdColumnOfQProfileEditGroupsTableTest/schema.sql deleted file mode 100644 index 3a866c066ab..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/DropGroupIdColumnOfQProfileEditGroupsTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "QPROFILE_EDIT_GROUPS"( - "UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER NOT NULL, - "GROUP_UUID" VARCHAR(40) NOT NULL, - "QPROFILE_UUID" VARCHAR(255) NOT NULL, - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "QPROFILE_EDIT_GROUPS" ADD CONSTRAINT "PK_QPROFILE_EDIT_GROUPS" PRIMARY KEY("UUID"); -CREATE INDEX "QPROFILE_EDIT_GROUPS_QPROFILE" ON "QPROFILE_EDIT_GROUPS"("QPROFILE_UUID"); -CREATE UNIQUE INDEX "QPROFILE_EDIT_GROUPS_UNIQUE" ON "QPROFILE_EDIT_GROUPS"("GROUP_UUID", "QPROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/DropIndexOnGroupIdOfQProfileEditGroupsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/DropIndexOnGroupIdOfQProfileEditGroupsTableTest/schema.sql deleted file mode 100644 index e4deaa55ba0..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/DropIndexOnGroupIdOfQProfileEditGroupsTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "QPROFILE_EDIT_GROUPS"( - "UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER NOT NULL, - "GROUP_UUID" VARCHAR(40) NOT NULL, - "QPROFILE_UUID" VARCHAR(255) NOT NULL, - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "QPROFILE_EDIT_GROUPS" ADD CONSTRAINT "PK_QPROFILE_EDIT_GROUPS" PRIMARY KEY("UUID"); -CREATE INDEX "QPROFILE_EDIT_GROUPS_QPROFILE" ON "QPROFILE_EDIT_GROUPS"("QPROFILE_UUID"); -CREATE UNIQUE INDEX "QPROFILE_EDIT_GROUPS_UNIQUE" ON "QPROFILE_EDIT_GROUPS"("GROUP_ID", "QPROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/MakeQProfileEditGroupsGroupUuidNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/MakeQProfileEditGroupsGroupUuidNotNullableTest/schema.sql deleted file mode 100644 index f30b909de2e..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/MakeQProfileEditGroupsGroupUuidNotNullableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "QPROFILE_EDIT_GROUPS"( - "UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER NOT NULL, - "GROUP_UUID" VARCHAR(40), - "QPROFILE_UUID" VARCHAR(255) NOT NULL, - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "QPROFILE_EDIT_GROUPS" ADD CONSTRAINT "PK_QPROFILE_EDIT_GROUPS" PRIMARY KEY("UUID"); -CREATE INDEX "QPROFILE_EDIT_GROUPS_QPROFILE" ON "QPROFILE_EDIT_GROUPS"("QPROFILE_UUID"); -CREATE UNIQUE INDEX "QPROFILE_EDIT_GROUPS_UNIQUE" ON "QPROFILE_EDIT_GROUPS"("GROUP_ID", "QPROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/PopulateQProfileEditGroupsGroupUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/PopulateQProfileEditGroupsGroupUuidTest/schema.sql deleted file mode 100644 index 05b4a34f279..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/groups/qprofileeditgroups/PopulateQProfileEditGroupsGroupUuidTest/schema.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TABLE "GROUPS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(500), - "DESCRIPTION" VARCHAR(200), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "GROUPS" ADD CONSTRAINT "PK_GROUPS" PRIMARY KEY("ID"); - -CREATE TABLE "QPROFILE_EDIT_GROUPS"( - "UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER NOT NULL, - "GROUP_UUID" VARCHAR(40), - "QPROFILE_UUID" VARCHAR(255) NOT NULL, - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "QPROFILE_EDIT_GROUPS" ADD CONSTRAINT "PK_QPROFILE_EDIT_GROUPS" PRIMARY KEY("UUID"); -CREATE INDEX "QPROFILE_EDIT_GROUPS_QPROFILE" ON "QPROFILE_EDIT_GROUPS"("QPROFILE_UUID"); -CREATE UNIQUE INDEX "QPROFILE_EDIT_GROUPS_UNIQUE" ON "QPROFILE_EDIT_GROUPS"("GROUP_ID", "QPROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issuechanges/AddPrimaryKeyOnUuidColumnOfIssueChangesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issuechanges/AddPrimaryKeyOnUuidColumnOfIssueChangesTableTest/schema.sql deleted file mode 100644 index 5b74206accb..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issuechanges/AddPrimaryKeyOnUuidColumnOfIssueChangesTableTest/schema.sql +++ /dev/null @@ -1,14 +0,0 @@ -CREATE TABLE "ISSUE_CHANGES"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(50), - "ISSUE_KEY" VARCHAR(50) NOT NULL, - "USER_LOGIN" VARCHAR(255), - "CHANGE_TYPE" VARCHAR(20), - "CHANGE_DATA" CLOB(2147483647), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CHANGE_CREATION_DATE" BIGINT -); -CREATE INDEX "ISSUE_CHANGES_ISSUE_KEY" ON "ISSUE_CHANGES"("ISSUE_KEY"); -CREATE INDEX "ISSUE_CHANGES_KEE" ON "ISSUE_CHANGES"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issuechanges/AddUuidColumnToIssueChangesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issuechanges/AddUuidColumnToIssueChangesTableTest/schema.sql deleted file mode 100644 index 6dea8cb9711..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issuechanges/AddUuidColumnToIssueChangesTableTest/schema.sql +++ /dev/null @@ -1,14 +0,0 @@ -CREATE TABLE "ISSUE_CHANGES"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "KEE" VARCHAR(50), - "ISSUE_KEY" VARCHAR(50) NOT NULL, - "USER_LOGIN" VARCHAR(255), - "CHANGE_TYPE" VARCHAR(20), - "CHANGE_DATA" CLOB(2147483647), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CHANGE_CREATION_DATE" BIGINT -); -ALTER TABLE "ISSUE_CHANGES" ADD CONSTRAINT "PK_ISSUE_CHANGES" PRIMARY KEY("ID"); -CREATE INDEX "ISSUE_CHANGES_ISSUE_KEY" ON "ISSUE_CHANGES"("ISSUE_KEY"); -CREATE INDEX "ISSUE_CHANGES_KEE" ON "ISSUE_CHANGES"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issuechanges/DropIdColumnOfIssueChangesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issuechanges/DropIdColumnOfIssueChangesTableTest/schema.sql deleted file mode 100644 index 7b26191fc16..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issuechanges/DropIdColumnOfIssueChangesTableTest/schema.sql +++ /dev/null @@ -1,15 +0,0 @@ -CREATE TABLE "ISSUE_CHANGES"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(50), - "ISSUE_KEY" VARCHAR(50) NOT NULL, - "USER_LOGIN" VARCHAR(255), - "CHANGE_TYPE" VARCHAR(20), - "CHANGE_DATA" CLOB(2147483647), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CHANGE_CREATION_DATE" BIGINT -); -ALTER TABLE "ISSUE_CHANGES" ADD CONSTRAINT "PK_ISSUE_CHANGES" PRIMARY KEY("UUID"); -CREATE INDEX "ISSUE_CHANGES_ISSUE_KEY" ON "ISSUE_CHANGES"("ISSUE_KEY"); -CREATE INDEX "ISSUE_CHANGES_KEE" ON "ISSUE_CHANGES"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issuechanges/DropPrimaryKeyOnIdColumnOfIssueChangesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issuechanges/DropPrimaryKeyOnIdColumnOfIssueChangesTableTest/schema.sql deleted file mode 100644 index e19e2691124..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issuechanges/DropPrimaryKeyOnIdColumnOfIssueChangesTableTest/schema.sql +++ /dev/null @@ -1,15 +0,0 @@ -CREATE TABLE "ISSUE_CHANGES"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "KEE" VARCHAR(50), - "ISSUE_KEY" VARCHAR(50) NOT NULL, - "USER_LOGIN" VARCHAR(255), - "CHANGE_TYPE" VARCHAR(20), - "CHANGE_DATA" CLOB(2147483647), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CHANGE_CREATION_DATE" BIGINT -); -ALTER TABLE "ISSUE_CHANGES" ADD CONSTRAINT "PK_ISSUE_CHANGES" PRIMARY KEY("ID"); -CREATE INDEX "ISSUE_CHANGES_ISSUE_KEY" ON "ISSUE_CHANGES"("ISSUE_KEY"); -CREATE INDEX "ISSUE_CHANGES_KEE" ON "ISSUE_CHANGES"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issuechanges/MakeIssueChangesUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issuechanges/MakeIssueChangesUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index f48647de321..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issuechanges/MakeIssueChangesUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,15 +0,0 @@ -CREATE TABLE "ISSUE_CHANGES"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "KEE" VARCHAR(50), - "ISSUE_KEY" VARCHAR(50) NOT NULL, - "USER_LOGIN" VARCHAR(255), - "CHANGE_TYPE" VARCHAR(20), - "CHANGE_DATA" CLOB(2147483647), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CHANGE_CREATION_DATE" BIGINT -); -ALTER TABLE "ISSUE_CHANGES" ADD CONSTRAINT "PK_ISSUE_CHANGES" PRIMARY KEY("ID"); -CREATE INDEX "ISSUE_CHANGES_ISSUE_KEY" ON "ISSUE_CHANGES"("ISSUE_KEY"); -CREATE INDEX "ISSUE_CHANGES_KEE" ON "ISSUE_CHANGES"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issuechanges/PopulateIssueChangesUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issuechanges/PopulateIssueChangesUuidTest/schema.sql deleted file mode 100644 index f48647de321..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issuechanges/PopulateIssueChangesUuidTest/schema.sql +++ /dev/null @@ -1,15 +0,0 @@ -CREATE TABLE "ISSUE_CHANGES"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "KEE" VARCHAR(50), - "ISSUE_KEY" VARCHAR(50) NOT NULL, - "USER_LOGIN" VARCHAR(255), - "CHANGE_TYPE" VARCHAR(20), - "CHANGE_DATA" CLOB(2147483647), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CHANGE_CREATION_DATE" BIGINT -); -ALTER TABLE "ISSUE_CHANGES" ADD CONSTRAINT "PK_ISSUE_CHANGES" PRIMARY KEY("ID"); -CREATE INDEX "ISSUE_CHANGES_ISSUE_KEY" ON "ISSUE_CHANGES"("ISSUE_KEY"); -CREATE INDEX "ISSUE_CHANGES_KEE" ON "ISSUE_CHANGES"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issues/AddPrimaryKeyOnKeeColumnOfIssuesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issues/AddPrimaryKeyOnKeeColumnOfIssuesTableTest/schema.sql deleted file mode 100644 index c195339d1d7..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issues/AddPrimaryKeyOnKeeColumnOfIssuesTableTest/schema.sql +++ /dev/null @@ -1,38 +0,0 @@ -CREATE TABLE "ISSUES"( - "ID" BIGINT NOT NULL, - "KEE" VARCHAR(50) NOT NULL, - "RULE_ID" INTEGER, - "SEVERITY" VARCHAR(10), - "MANUAL_SEVERITY" BOOLEAN NOT NULL, - "MESSAGE" VARCHAR(4000), - "LINE" INTEGER, - "GAP" DOUBLE, - "STATUS" VARCHAR(20), - "RESOLUTION" VARCHAR(20), - "CHECKSUM" VARCHAR(1000), - "REPORTER" VARCHAR(255), - "ASSIGNEE" VARCHAR(255), - "AUTHOR_LOGIN" VARCHAR(255), - "ACTION_PLAN_KEY" VARCHAR(50), - "ISSUE_ATTRIBUTES" VARCHAR(4000), - "EFFORT" INTEGER, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CREATION_DATE" BIGINT, - "ISSUE_UPDATE_DATE" BIGINT, - "ISSUE_CLOSE_DATE" BIGINT, - "TAGS" VARCHAR(4000), - "COMPONENT_UUID" VARCHAR(50), - "PROJECT_UUID" VARCHAR(50), - "LOCATIONS" BLOB, - "ISSUE_TYPE" TINYINT, - "FROM_HOTSPOT" BOOLEAN -); -CREATE INDEX "ISSUES_ASSIGNEE" ON "ISSUES"("ASSIGNEE"); -CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES"("COMPONENT_UUID"); -CREATE INDEX "ISSUES_CREATION_DATE" ON "ISSUES"("ISSUE_CREATION_DATE"); -CREATE UNIQUE INDEX "ISSUES_KEE" ON "ISSUES"("KEE"); -CREATE INDEX "ISSUES_PROJECT_UUID" ON "ISSUES"("PROJECT_UUID"); -CREATE INDEX "ISSUES_RESOLUTION" ON "ISSUES"("RESOLUTION"); -CREATE INDEX "ISSUES_RULE_ID" ON "ISSUES"("RULE_ID"); -CREATE INDEX "ISSUES_UPDATED_AT" ON "ISSUES"("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issues/DropIdColumnOfIssuesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issues/DropIdColumnOfIssuesTableTest/schema.sql deleted file mode 100644 index 92fadc6580c..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issues/DropIdColumnOfIssuesTableTest/schema.sql +++ /dev/null @@ -1,39 +0,0 @@ -CREATE TABLE "ISSUES"( - "ID" BIGINT NOT NULL, - "KEE" VARCHAR(50) NOT NULL, - "RULE_ID" INTEGER, - "SEVERITY" VARCHAR(10), - "MANUAL_SEVERITY" BOOLEAN NOT NULL, - "MESSAGE" VARCHAR(4000), - "LINE" INTEGER, - "GAP" DOUBLE, - "STATUS" VARCHAR(20), - "RESOLUTION" VARCHAR(20), - "CHECKSUM" VARCHAR(1000), - "REPORTER" VARCHAR(255), - "ASSIGNEE" VARCHAR(255), - "AUTHOR_LOGIN" VARCHAR(255), - "ACTION_PLAN_KEY" VARCHAR(50), - "ISSUE_ATTRIBUTES" VARCHAR(4000), - "EFFORT" INTEGER, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CREATION_DATE" BIGINT, - "ISSUE_UPDATE_DATE" BIGINT, - "ISSUE_CLOSE_DATE" BIGINT, - "TAGS" VARCHAR(4000), - "COMPONENT_UUID" VARCHAR(50), - "PROJECT_UUID" VARCHAR(50), - "LOCATIONS" BLOB, - "ISSUE_TYPE" TINYINT, - "FROM_HOTSPOT" BOOLEAN -); -ALTER TABLE "ISSUES" ADD CONSTRAINT "PK_ISSUES" PRIMARY KEY("KEE"); -CREATE INDEX "ISSUES_ASSIGNEE" ON "ISSUES"("ASSIGNEE"); -CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES"("COMPONENT_UUID"); -CREATE INDEX "ISSUES_CREATION_DATE" ON "ISSUES"("ISSUE_CREATION_DATE"); -CREATE UNIQUE INDEX "ISSUES_KEE" ON "ISSUES"("KEE"); -CREATE INDEX "ISSUES_PROJECT_UUID" ON "ISSUES"("PROJECT_UUID"); -CREATE INDEX "ISSUES_RESOLUTION" ON "ISSUES"("RESOLUTION"); -CREATE INDEX "ISSUES_RULE_ID" ON "ISSUES"("RULE_ID"); -CREATE INDEX "ISSUES_UPDATED_AT" ON "ISSUES"("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issues/DropPrimaryKeyOnIdColumnOfIssuesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issues/DropPrimaryKeyOnIdColumnOfIssuesTableTest/schema.sql deleted file mode 100644 index cf65bc42c84..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issues/DropPrimaryKeyOnIdColumnOfIssuesTableTest/schema.sql +++ /dev/null @@ -1,39 +0,0 @@ -CREATE TABLE "ISSUES"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "KEE" VARCHAR(50) NOT NULL, - "RULE_ID" INTEGER, - "SEVERITY" VARCHAR(10), - "MANUAL_SEVERITY" BOOLEAN NOT NULL, - "MESSAGE" VARCHAR(4000), - "LINE" INTEGER, - "GAP" DOUBLE, - "STATUS" VARCHAR(20), - "RESOLUTION" VARCHAR(20), - "CHECKSUM" VARCHAR(1000), - "REPORTER" VARCHAR(255), - "ASSIGNEE" VARCHAR(255), - "AUTHOR_LOGIN" VARCHAR(255), - "ACTION_PLAN_KEY" VARCHAR(50), - "ISSUE_ATTRIBUTES" VARCHAR(4000), - "EFFORT" INTEGER, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CREATION_DATE" BIGINT, - "ISSUE_UPDATE_DATE" BIGINT, - "ISSUE_CLOSE_DATE" BIGINT, - "TAGS" VARCHAR(4000), - "COMPONENT_UUID" VARCHAR(50), - "PROJECT_UUID" VARCHAR(50), - "LOCATIONS" BLOB, - "ISSUE_TYPE" TINYINT, - "FROM_HOTSPOT" BOOLEAN -); -ALTER TABLE "ISSUES" ADD CONSTRAINT "PK_ISSUES" PRIMARY KEY("ID"); -CREATE INDEX "ISSUES_ASSIGNEE" ON "ISSUES"("ASSIGNEE"); -CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES"("COMPONENT_UUID"); -CREATE INDEX "ISSUES_CREATION_DATE" ON "ISSUES"("ISSUE_CREATION_DATE"); -CREATE UNIQUE INDEX "ISSUES_KEE" ON "ISSUES"("KEE"); -CREATE INDEX "ISSUES_PROJECT_UUID" ON "ISSUES"("PROJECT_UUID"); -CREATE INDEX "ISSUES_RESOLUTION" ON "ISSUES"("RESOLUTION"); -CREATE INDEX "ISSUES_RULE_ID" ON "ISSUES"("RULE_ID"); -CREATE INDEX "ISSUES_UPDATED_AT" ON "ISSUES"("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/manualmeasures/AddPrimaryKeyOnUuidColumnOfManualMeasureTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/manualmeasures/AddPrimaryKeyOnUuidColumnOfManualMeasureTableTest/schema.sql deleted file mode 100644 index d1048130fdd..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/manualmeasures/AddPrimaryKeyOnUuidColumnOfManualMeasureTableTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "MANUAL_MEASURES"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "METRIC_ID" INTEGER NOT NULL, - "VALUE" DOUBLE, - "TEXT_VALUE" VARCHAR(4000), - "USER_UUID" VARCHAR(255), - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "UUID" VARCHAR(40) NOT NULL -); -CREATE INDEX "MANUAL_MEASURES_COMPONENT_UUID" ON "MANUAL_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/manualmeasures/AddUuidToManualMeasuresTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/manualmeasures/AddUuidToManualMeasuresTest/schema.sql deleted file mode 100644 index 91889223c63..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/manualmeasures/AddUuidToManualMeasuresTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "MANUAL_MEASURES"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "METRIC_ID" INTEGER NOT NULL, - "VALUE" DOUBLE, - "TEXT_VALUE" VARCHAR(4000), - "USER_UUID" VARCHAR(255), - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL -); -ALTER TABLE "MANUAL_MEASURES" ADD CONSTRAINT "PK_MANUAL_MEASURES" PRIMARY KEY("ID"); -CREATE INDEX "MANUAL_MEASURES_COMPONENT_UUID" ON "MANUAL_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/manualmeasures/DropIdColumnOfManualMeasuresTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/manualmeasures/DropIdColumnOfManualMeasuresTableTest/schema.sql deleted file mode 100644 index d1048130fdd..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/manualmeasures/DropIdColumnOfManualMeasuresTableTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "MANUAL_MEASURES"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "METRIC_ID" INTEGER NOT NULL, - "VALUE" DOUBLE, - "TEXT_VALUE" VARCHAR(4000), - "USER_UUID" VARCHAR(255), - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "UUID" VARCHAR(40) NOT NULL -); -CREATE INDEX "MANUAL_MEASURES_COMPONENT_UUID" ON "MANUAL_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/manualmeasures/DropPrimaryKeyOnIdColumnOfManualMeasuresTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/manualmeasures/DropPrimaryKeyOnIdColumnOfManualMeasuresTableTest/schema.sql deleted file mode 100644 index dae762bdba3..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/manualmeasures/DropPrimaryKeyOnIdColumnOfManualMeasuresTableTest/schema.sql +++ /dev/null @@ -1,14 +0,0 @@ -CREATE TABLE "MANUAL_MEASURES"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "METRIC_ID" INTEGER NOT NULL, - "VALUE" DOUBLE, - "TEXT_VALUE" VARCHAR(4000), - "USER_UUID" VARCHAR(255), - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "MANUAL_MEASURES" ADD CONSTRAINT "PK_MANUAL_MEASURES" PRIMARY KEY("ID"); -CREATE INDEX "MANUAL_MEASURES_COMPONENT_UUID" ON "MANUAL_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/manualmeasures/MakeManualMeasuresUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/manualmeasures/MakeManualMeasuresUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index c9ff15f330d..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/manualmeasures/MakeManualMeasuresUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,14 +0,0 @@ -CREATE TABLE "MANUAL_MEASURES"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "METRIC_ID" INTEGER NOT NULL, - "VALUE" DOUBLE, - "TEXT_VALUE" VARCHAR(4000), - "USER_UUID" VARCHAR(255), - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "UUID" VARCHAR(40) -); -ALTER TABLE "MANUAL_MEASURES" ADD CONSTRAINT "PK_MANUAL_MEASURES" PRIMARY KEY("ID"); -CREATE INDEX "MANUAL_MEASURES_COMPONENT_UUID" ON "MANUAL_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/manualmeasures/PopulateManualMeasuresUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/manualmeasures/PopulateManualMeasuresUuidTest/schema.sql deleted file mode 100644 index c9ff15f330d..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/manualmeasures/PopulateManualMeasuresUuidTest/schema.sql +++ /dev/null @@ -1,14 +0,0 @@ -CREATE TABLE "MANUAL_MEASURES"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "METRIC_ID" INTEGER NOT NULL, - "VALUE" DOUBLE, - "TEXT_VALUE" VARCHAR(4000), - "USER_UUID" VARCHAR(255), - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "UUID" VARCHAR(40) -); -ALTER TABLE "MANUAL_MEASURES" ADD CONSTRAINT "PK_MANUAL_MEASURES" PRIMARY KEY("ID"); -CREATE INDEX "MANUAL_MEASURES_COMPONENT_UUID" ON "MANUAL_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/AddPrimaryKeyOnUuidColumnOfMetricsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/AddPrimaryKeyOnUuidColumnOfMetricsTableTest/schema.sql deleted file mode 100644 index 51a7ed18a25..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/AddPrimaryKeyOnUuidColumnOfMetricsTableTest/schema.sql +++ /dev/null @@ -1,20 +0,0 @@ -CREATE TABLE "METRICS"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(255), - "DIRECTION" INTEGER DEFAULT 0 NOT NULL, - "DOMAIN" VARCHAR(64), - "SHORT_NAME" VARCHAR(64), - "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, - "VAL_TYPE" VARCHAR(8), - "USER_MANAGED" BOOLEAN DEFAULT FALSE, - "ENABLED" BOOLEAN DEFAULT TRUE, - "WORST_VALUE" DOUBLE, - "BEST_VALUE" DOUBLE, - "OPTIMIZED_BEST_VALUE" BOOLEAN, - "HIDDEN" BOOLEAN, - "DELETE_HISTORICAL_DATA" BOOLEAN, - "DECIMAL_SCALE" INTEGER -); -CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/AddUuidColumnToMetricsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/AddUuidColumnToMetricsTableTest/schema.sql deleted file mode 100644 index 8ca314830d2..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/AddUuidColumnToMetricsTableTest/schema.sql +++ /dev/null @@ -1,20 +0,0 @@ -CREATE TABLE "METRICS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(255), - "DIRECTION" INTEGER DEFAULT 0 NOT NULL, - "DOMAIN" VARCHAR(64), - "SHORT_NAME" VARCHAR(64), - "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, - "VAL_TYPE" VARCHAR(8), - "USER_MANAGED" BOOLEAN DEFAULT FALSE, - "ENABLED" BOOLEAN DEFAULT TRUE, - "WORST_VALUE" DOUBLE, - "BEST_VALUE" DOUBLE, - "OPTIMIZED_BEST_VALUE" BOOLEAN, - "HIDDEN" BOOLEAN, - "DELETE_HISTORICAL_DATA" BOOLEAN, - "DECIMAL_SCALE" INTEGER -); -ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/DropIdColumnOfMetricsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/DropIdColumnOfMetricsTableTest/schema.sql deleted file mode 100644 index cc5c53aec36..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/DropIdColumnOfMetricsTableTest/schema.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TABLE "METRICS"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(255), - "DIRECTION" INTEGER DEFAULT 0 NOT NULL, - "DOMAIN" VARCHAR(64), - "SHORT_NAME" VARCHAR(64), - "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, - "VAL_TYPE" VARCHAR(8), - "USER_MANAGED" BOOLEAN DEFAULT FALSE, - "ENABLED" BOOLEAN DEFAULT TRUE, - "WORST_VALUE" DOUBLE, - "BEST_VALUE" DOUBLE, - "OPTIMIZED_BEST_VALUE" BOOLEAN, - "HIDDEN" BOOLEAN, - "DELETE_HISTORICAL_DATA" BOOLEAN, - "DECIMAL_SCALE" INTEGER -); -ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/DropPrimaryKeyOnIdColumnOfMetricsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/DropPrimaryKeyOnIdColumnOfMetricsTableTest/schema.sql deleted file mode 100644 index a5940e9702e..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/DropPrimaryKeyOnIdColumnOfMetricsTableTest/schema.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TABLE "METRICS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(255), - "DIRECTION" INTEGER DEFAULT 0 NOT NULL, - "DOMAIN" VARCHAR(64), - "SHORT_NAME" VARCHAR(64), - "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, - "VAL_TYPE" VARCHAR(8), - "USER_MANAGED" BOOLEAN DEFAULT FALSE, - "ENABLED" BOOLEAN DEFAULT TRUE, - "WORST_VALUE" DOUBLE, - "BEST_VALUE" DOUBLE, - "OPTIMIZED_BEST_VALUE" BOOLEAN, - "HIDDEN" BOOLEAN, - "DELETE_HISTORICAL_DATA" BOOLEAN, - "DECIMAL_SCALE" INTEGER -); -ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/MakeMetricsUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/MakeMetricsUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index 5e215f6a7a9..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/MakeMetricsUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TABLE "METRICS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(255), - "DIRECTION" INTEGER DEFAULT 0 NOT NULL, - "DOMAIN" VARCHAR(64), - "SHORT_NAME" VARCHAR(64), - "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, - "VAL_TYPE" VARCHAR(8), - "USER_MANAGED" BOOLEAN DEFAULT FALSE, - "ENABLED" BOOLEAN DEFAULT TRUE, - "WORST_VALUE" DOUBLE, - "BEST_VALUE" DOUBLE, - "OPTIMIZED_BEST_VALUE" BOOLEAN, - "HIDDEN" BOOLEAN, - "DELETE_HISTORICAL_DATA" BOOLEAN, - "DECIMAL_SCALE" INTEGER -); -ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/PopulateMetricsUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/PopulateMetricsUuidTest/schema.sql deleted file mode 100644 index 5e215f6a7a9..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/PopulateMetricsUuidTest/schema.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TABLE "METRICS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(255), - "DIRECTION" INTEGER DEFAULT 0 NOT NULL, - "DOMAIN" VARCHAR(64), - "SHORT_NAME" VARCHAR(64), - "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, - "VAL_TYPE" VARCHAR(8), - "USER_MANAGED" BOOLEAN DEFAULT FALSE, - "ENABLED" BOOLEAN DEFAULT TRUE, - "WORST_VALUE" DOUBLE, - "BEST_VALUE" DOUBLE, - "OPTIMIZED_BEST_VALUE" BOOLEAN, - "HIDDEN" BOOLEAN, - "DELETE_HISTORICAL_DATA" BOOLEAN, - "DECIMAL_SCALE" INTEGER -); -ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/AddIndexOnMetricUuidOfLiveMeasuresTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/AddIndexOnMetricUuidOfLiveMeasuresTableTest/schema.sql deleted file mode 100644 index b624715d6c6..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/AddIndexOnMetricUuidOfLiveMeasuresTableTest/schema.sql +++ /dev/null @@ -1,16 +0,0 @@ -CREATE TABLE "LIVE_MEASURES"( - "UUID" VARCHAR(40) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "METRIC_ID" INTEGER NOT NULL, - "METRIC_UUID" VARCHAR NOT NULL, - "VALUE" DOUBLE, - "TEXT_VALUE" VARCHAR(4000), - "VARIATION" DOUBLE, - "MEASURE_DATA" BLOB, - "UPDATE_MARKER" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "LIVE_MEASURES" ADD CONSTRAINT "PK_LIVE_MEASURES" PRIMARY KEY("UUID"); -CREATE INDEX "LIVE_MEASURES_PROJECT" ON "LIVE_MEASURES"("PROJECT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/AddMetricUuidColumnToLiveMeasuresTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/AddMetricUuidColumnToLiveMeasuresTest/schema.sql deleted file mode 100644 index e969dd3add3..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/AddMetricUuidColumnToLiveMeasuresTest/schema.sql +++ /dev/null @@ -1,16 +0,0 @@ -CREATE TABLE "LIVE_MEASURES"( - "UUID" VARCHAR(40) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "METRIC_ID" INTEGER NOT NULL, - "VALUE" DOUBLE, - "TEXT_VALUE" VARCHAR(4000), - "VARIATION" DOUBLE, - "MEASURE_DATA" BLOB, - "UPDATE_MARKER" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "LIVE_MEASURES" ADD CONSTRAINT "PK_LIVE_MEASURES" PRIMARY KEY("UUID"); -CREATE INDEX "LIVE_MEASURES_PROJECT" ON "LIVE_MEASURES"("PROJECT_UUID"); -CREATE UNIQUE INDEX "LIVE_MEASURES_COMPONENT" ON "LIVE_MEASURES"("COMPONENT_UUID", "METRIC_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/DropIndexOnMetricIdOfLiveMeasuresTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/DropIndexOnMetricIdOfLiveMeasuresTableTest/schema.sql deleted file mode 100644 index 79dd9a63064..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/DropIndexOnMetricIdOfLiveMeasuresTableTest/schema.sql +++ /dev/null @@ -1,17 +0,0 @@ -CREATE TABLE "LIVE_MEASURES"( - "UUID" VARCHAR(40) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "METRIC_ID" INTEGER NOT NULL, - "METRIC_UUID" VARCHAR NOT NULL, - "VALUE" DOUBLE, - "TEXT_VALUE" VARCHAR(4000), - "VARIATION" DOUBLE, - "MEASURE_DATA" BLOB, - "UPDATE_MARKER" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "LIVE_MEASURES" ADD CONSTRAINT "PK_LIVE_MEASURES" PRIMARY KEY("UUID"); -CREATE INDEX "LIVE_MEASURES_PROJECT" ON "LIVE_MEASURES"("PROJECT_UUID"); -CREATE UNIQUE INDEX "LIVE_MEASURES_COMPONENT" ON "LIVE_MEASURES"("COMPONENT_UUID", "METRIC_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/DropMetricIdColumnOfLiveMeasuresTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/DropMetricIdColumnOfLiveMeasuresTableTest/schema.sql deleted file mode 100644 index 5b750f3ece5..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/DropMetricIdColumnOfLiveMeasuresTableTest/schema.sql +++ /dev/null @@ -1,17 +0,0 @@ -CREATE TABLE "LIVE_MEASURES"( - "UUID" VARCHAR(40) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "METRIC_ID" INTEGER NOT NULL, - "METRIC_UUID" VARCHAR NOT NULL, - "VALUE" DOUBLE, - "TEXT_VALUE" VARCHAR(4000), - "VARIATION" DOUBLE, - "MEASURE_DATA" BLOB, - "UPDATE_MARKER" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "LIVE_MEASURES" ADD CONSTRAINT "PK_LIVE_MEASURES" PRIMARY KEY("UUID"); -CREATE INDEX "LIVE_MEASURES_PROJECT" ON "LIVE_MEASURES"("PROJECT_UUID"); -CREATE UNIQUE INDEX "LIVE_MEASURES_COMPONENT" ON "LIVE_MEASURES"("COMPONENT_UUID", "METRIC_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/MakeLiveMeasuresMetricUuidNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/MakeLiveMeasuresMetricUuidNotNullableTest/schema.sql deleted file mode 100644 index dd1e89afe4c..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/MakeLiveMeasuresMetricUuidNotNullableTest/schema.sql +++ /dev/null @@ -1,17 +0,0 @@ -CREATE TABLE "LIVE_MEASURES"( - "UUID" VARCHAR(40) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "METRIC_ID" INTEGER NOT NULL, - "METRIC_UUID" VARCHAR(40), - "VALUE" DOUBLE, - "TEXT_VALUE" VARCHAR(4000), - "VARIATION" DOUBLE, - "MEASURE_DATA" BLOB, - "UPDATE_MARKER" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "LIVE_MEASURES" ADD CONSTRAINT "PK_LIVE_MEASURES" PRIMARY KEY("UUID"); -CREATE INDEX "LIVE_MEASURES_PROJECT" ON "LIVE_MEASURES"("PROJECT_UUID"); -CREATE UNIQUE INDEX "LIVE_MEASURES_COMPONENT" ON "LIVE_MEASURES"("COMPONENT_UUID", "METRIC_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/PopulateLiveMeasuresMetricUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/PopulateLiveMeasuresMetricUuidTest/schema.sql deleted file mode 100644 index 85b848f4614..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/livemeasures/PopulateLiveMeasuresMetricUuidTest/schema.sql +++ /dev/null @@ -1,39 +0,0 @@ -CREATE TABLE "LIVE_MEASURES"( - "UUID" VARCHAR(40) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "METRIC_ID" INTEGER NOT NULL, - "METRIC_UUID" VARCHAR(40), - "VALUE" DOUBLE, - "TEXT_VALUE" VARCHAR(4000), - "VARIATION" DOUBLE, - "MEASURE_DATA" BLOB, - "UPDATE_MARKER" VARCHAR(40), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "LIVE_MEASURES" ADD CONSTRAINT "PK_LIVE_MEASURES" PRIMARY KEY("UUID"); -CREATE INDEX "LIVE_MEASURES_PROJECT" ON "LIVE_MEASURES"("PROJECT_UUID"); -CREATE UNIQUE INDEX "LIVE_MEASURES_COMPONENT" ON "LIVE_MEASURES"("COMPONENT_UUID", "METRIC_ID"); - -CREATE TABLE "METRICS"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(255), - "DIRECTION" INTEGER DEFAULT 0 NOT NULL, - "DOMAIN" VARCHAR(64), - "SHORT_NAME" VARCHAR(64), - "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, - "VAL_TYPE" VARCHAR(8), - "USER_MANAGED" BOOLEAN DEFAULT FALSE, - "ENABLED" BOOLEAN DEFAULT TRUE, - "WORST_VALUE" DOUBLE, - "BEST_VALUE" DOUBLE, - "OPTIMIZED_BEST_VALUE" BOOLEAN, - "HIDDEN" BOOLEAN, - "DELETE_HISTORICAL_DATA" BOOLEAN, - "DECIMAL_SCALE" INTEGER -); -ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/AddMetricUuidColumnToManualMeasuresTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/AddMetricUuidColumnToManualMeasuresTest/schema.sql deleted file mode 100644 index 37a120d6215..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/AddMetricUuidColumnToManualMeasuresTest/schema.sql +++ /dev/null @@ -1,35 +0,0 @@ -CREATE TABLE "MANUAL_MEASURES"( - "UUID" VARCHAR(40) NOT NULL, - "METRIC_ID" INTEGER NOT NULL, - "VALUE" DOUBLE, - "TEXT_VALUE" VARCHAR(4000), - "USER_UUID" VARCHAR(255), - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL -); -ALTER TABLE "MANUAL_MEASURES" ADD CONSTRAINT "PK_MANUAL_MEASURES" PRIMARY KEY("UUID"); -CREATE INDEX "MANUAL_MEASURES_COMPONENT_UUID" ON "MANUAL_MEASURES"("COMPONENT_UUID"); - -CREATE TABLE "METRICS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(255), - "DIRECTION" INTEGER DEFAULT 0 NOT NULL, - "DOMAIN" VARCHAR(64), - "SHORT_NAME" VARCHAR(64), - "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, - "VAL_TYPE" VARCHAR(8), - "USER_MANAGED" BOOLEAN DEFAULT FALSE, - "ENABLED" BOOLEAN DEFAULT TRUE, - "WORST_VALUE" DOUBLE, - "BEST_VALUE" DOUBLE, - "OPTIMIZED_BEST_VALUE" BOOLEAN, - "HIDDEN" BOOLEAN, - "DELETE_HISTORICAL_DATA" BOOLEAN, - "DECIMAL_SCALE" INTEGER, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/DropMetricIdColumnOfManualMeasuresTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/DropMetricIdColumnOfManualMeasuresTableTest/schema.sql deleted file mode 100644 index 3bb1010e374..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/DropMetricIdColumnOfManualMeasuresTableTest/schema.sql +++ /dev/null @@ -1,36 +0,0 @@ -CREATE TABLE "MANUAL_MEASURES"( - "UUID" VARCHAR(40) NOT NULL, - "METRIC_UUID" VARCHAR(40) NOT NULL, - "METRIC_ID" INTEGER NOT NULL, - "VALUE" DOUBLE, - "TEXT_VALUE" VARCHAR(4000), - "USER_UUID" VARCHAR(255), - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL -); -ALTER TABLE "MANUAL_MEASURES" ADD CONSTRAINT "PK_MANUAL_MEASURES" PRIMARY KEY("UUID"); -CREATE INDEX "MANUAL_MEASURES_COMPONENT_UUID" ON "MANUAL_MEASURES"("COMPONENT_UUID"); - -CREATE TABLE "METRICS"( - "ID" INTEGER NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(255), - "DIRECTION" INTEGER DEFAULT 0 NOT NULL, - "DOMAIN" VARCHAR(64), - "SHORT_NAME" VARCHAR(64), - "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, - "VAL_TYPE" VARCHAR(8), - "USER_MANAGED" BOOLEAN DEFAULT FALSE, - "ENABLED" BOOLEAN DEFAULT TRUE, - "WORST_VALUE" DOUBLE, - "BEST_VALUE" DOUBLE, - "OPTIMIZED_BEST_VALUE" BOOLEAN, - "HIDDEN" BOOLEAN, - "DELETE_HISTORICAL_DATA" BOOLEAN, - "DECIMAL_SCALE" INTEGER, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/MakeManualMeasuresMetricUuidNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/MakeManualMeasuresMetricUuidNotNullableTest/schema.sql deleted file mode 100644 index fe619cf50f2..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/MakeManualMeasuresMetricUuidNotNullableTest/schema.sql +++ /dev/null @@ -1,36 +0,0 @@ -CREATE TABLE "MANUAL_MEASURES"( - "UUID" VARCHAR(40) NOT NULL, - "METRIC_UUID" VARCHAR(40), - "METRIC_ID" INTEGER NOT NULL, - "VALUE" DOUBLE, - "TEXT_VALUE" VARCHAR(4000), - "USER_UUID" VARCHAR(255), - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL -); -ALTER TABLE "MANUAL_MEASURES" ADD CONSTRAINT "PK_MANUAL_MEASURES" PRIMARY KEY("UUID"); -CREATE INDEX "MANUAL_MEASURES_COMPONENT_UUID" ON "MANUAL_MEASURES"("COMPONENT_UUID"); - -CREATE TABLE "METRICS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(255), - "DIRECTION" INTEGER DEFAULT 0 NOT NULL, - "DOMAIN" VARCHAR(64), - "SHORT_NAME" VARCHAR(64), - "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, - "VAL_TYPE" VARCHAR(8), - "USER_MANAGED" BOOLEAN DEFAULT FALSE, - "ENABLED" BOOLEAN DEFAULT TRUE, - "WORST_VALUE" DOUBLE, - "BEST_VALUE" DOUBLE, - "OPTIMIZED_BEST_VALUE" BOOLEAN, - "HIDDEN" BOOLEAN, - "DELETE_HISTORICAL_DATA" BOOLEAN, - "DECIMAL_SCALE" INTEGER, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/PopulateManualMeasuresMetricUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/PopulateManualMeasuresMetricUuidTest/schema.sql deleted file mode 100644 index fe619cf50f2..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/manualmeasures/PopulateManualMeasuresMetricUuidTest/schema.sql +++ /dev/null @@ -1,36 +0,0 @@ -CREATE TABLE "MANUAL_MEASURES"( - "UUID" VARCHAR(40) NOT NULL, - "METRIC_UUID" VARCHAR(40), - "METRIC_ID" INTEGER NOT NULL, - "VALUE" DOUBLE, - "TEXT_VALUE" VARCHAR(4000), - "USER_UUID" VARCHAR(255), - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "COMPONENT_UUID" VARCHAR(50) NOT NULL -); -ALTER TABLE "MANUAL_MEASURES" ADD CONSTRAINT "PK_MANUAL_MEASURES" PRIMARY KEY("UUID"); -CREATE INDEX "MANUAL_MEASURES_COMPONENT_UUID" ON "MANUAL_MEASURES"("COMPONENT_UUID"); - -CREATE TABLE "METRICS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(255), - "DIRECTION" INTEGER DEFAULT 0 NOT NULL, - "DOMAIN" VARCHAR(64), - "SHORT_NAME" VARCHAR(64), - "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, - "VAL_TYPE" VARCHAR(8), - "USER_MANAGED" BOOLEAN DEFAULT FALSE, - "ENABLED" BOOLEAN DEFAULT TRUE, - "WORST_VALUE" DOUBLE, - "BEST_VALUE" DOUBLE, - "OPTIMIZED_BEST_VALUE" BOOLEAN, - "HIDDEN" BOOLEAN, - "DELETE_HISTORICAL_DATA" BOOLEAN, - "DECIMAL_SCALE" INTEGER, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/AddIndexOnMetricUuidOfProjectMeasuresTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/AddIndexOnMetricUuidOfProjectMeasuresTableTest/schema.sql deleted file mode 100644 index bcd93c5d249..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/AddIndexOnMetricUuidOfProjectMeasuresTableTest/schema.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TABLE "PROJECT_MEASURES"( - "VALUE" DOUBLE, - "METRIC_UUID" VARCHAR(40) NOT NULL, - "METRIC_ID" INTEGER NOT NULL, - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "ALERT_STATUS" VARCHAR(5), - "ALERT_TEXT" VARCHAR(4000), - "DESCRIPTION" VARCHAR(4000), - "PERSON_ID" INTEGER, - "VARIATION_VALUE_1" DOUBLE, - "VARIATION_VALUE_2" DOUBLE, - "VARIATION_VALUE_3" DOUBLE, - "VARIATION_VALUE_4" DOUBLE, - "VARIATION_VALUE_5" DOUBLE, - "MEASURE_DATA" BLOB, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "PROJECT_MEASURES" ADD CONSTRAINT "PK_PROJECT_MEASURES" PRIMARY KEY("UUID"); -CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/AddMetricUuidColumnToProjectMeasuresTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/AddMetricUuidColumnToProjectMeasuresTest/schema.sql deleted file mode 100644 index 847518066d5..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/AddMetricUuidColumnToProjectMeasuresTest/schema.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TABLE "PROJECT_MEASURES"( - "VALUE" DOUBLE, - "METRIC_ID" INTEGER NOT NULL, - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "ALERT_STATUS" VARCHAR(5), - "ALERT_TEXT" VARCHAR(4000), - "DESCRIPTION" VARCHAR(4000), - "PERSON_ID" INTEGER, - "VARIATION_VALUE_1" DOUBLE, - "VARIATION_VALUE_2" DOUBLE, - "VARIATION_VALUE_3" DOUBLE, - "VARIATION_VALUE_4" DOUBLE, - "VARIATION_VALUE_5" DOUBLE, - "MEASURE_DATA" BLOB, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "PROJECT_MEASURES" ADD CONSTRAINT "PK_PROJECT_MEASURES" PRIMARY KEY("UUID"); -CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES"("ANALYSIS_UUID", "METRIC_ID"); -CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/DropIndexOnMetricIdOfProjectMeasuresTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/DropIndexOnMetricIdOfProjectMeasuresTableTest/schema.sql deleted file mode 100644 index 90d0eb46d3e..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/DropIndexOnMetricIdOfProjectMeasuresTableTest/schema.sql +++ /dev/null @@ -1,22 +0,0 @@ -CREATE TABLE "PROJECT_MEASURES"( - "VALUE" DOUBLE, - "METRIC_UUID" VARCHAR(40) NOT NULL, - "METRIC_ID" INTEGER NOT NULL, - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "ALERT_STATUS" VARCHAR(5), - "ALERT_TEXT" VARCHAR(4000), - "DESCRIPTION" VARCHAR(4000), - "PERSON_ID" INTEGER, - "VARIATION_VALUE_1" DOUBLE, - "VARIATION_VALUE_2" DOUBLE, - "VARIATION_VALUE_3" DOUBLE, - "VARIATION_VALUE_4" DOUBLE, - "VARIATION_VALUE_5" DOUBLE, - "MEASURE_DATA" BLOB, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "PROJECT_MEASURES" ADD CONSTRAINT "PK_PROJECT_MEASURES" PRIMARY KEY("UUID"); -CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES"("ANALYSIS_UUID", "METRIC_ID"); -CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/DropMetricIdColumnOfProjectMeasuresTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/DropMetricIdColumnOfProjectMeasuresTableTest/schema.sql deleted file mode 100644 index 55356e78300..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/DropMetricIdColumnOfProjectMeasuresTableTest/schema.sql +++ /dev/null @@ -1,22 +0,0 @@ -CREATE TABLE "PROJECT_MEASURES"( - "VALUE" DOUBLE, - "METRIC_UUID" VARCHAR(40) NOT NULL, - "METRIC_ID" INTEGER NOT NULL, - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "ALERT_STATUS" VARCHAR(5), - "ALERT_TEXT" VARCHAR(4000), - "DESCRIPTION" VARCHAR(4000), - "PERSON_ID" INTEGER, - "VARIATION_VALUE_1" DOUBLE, - "VARIATION_VALUE_2" DOUBLE, - "VARIATION_VALUE_3" DOUBLE, - "VARIATION_VALUE_4" DOUBLE, - "VARIATION_VALUE_5" DOUBLE, - "MEASURE_DATA" BLOB, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "PROJECT_MEASURES" ADD CONSTRAINT "PK_PROJECT_MEASURES" PRIMARY KEY("UUID"); -CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES"("ANALYSIS_UUID", "METRIC_UUID"); -CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/MakeProjectMeasuresMetricUuidNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/MakeProjectMeasuresMetricUuidNotNullableTest/schema.sql deleted file mode 100644 index d78a04c7c95..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/MakeProjectMeasuresMetricUuidNotNullableTest/schema.sql +++ /dev/null @@ -1,22 +0,0 @@ -CREATE TABLE "PROJECT_MEASURES"( - "VALUE" DOUBLE, - "METRIC_UUID" VARCHAR(40), - "METRIC_ID" INTEGER NOT NULL, - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "ALERT_STATUS" VARCHAR(5), - "ALERT_TEXT" VARCHAR(4000), - "DESCRIPTION" VARCHAR(4000), - "PERSON_ID" INTEGER, - "VARIATION_VALUE_1" DOUBLE, - "VARIATION_VALUE_2" DOUBLE, - "VARIATION_VALUE_3" DOUBLE, - "VARIATION_VALUE_4" DOUBLE, - "VARIATION_VALUE_5" DOUBLE, - "MEASURE_DATA" BLOB, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "PROJECT_MEASURES" ADD CONSTRAINT "PK_PROJECT_MEASURES" PRIMARY KEY("UUID"); -CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES"("ANALYSIS_UUID", "METRIC_ID"); -CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/PopulateProjectMeasuresMetricUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/PopulateProjectMeasuresMetricUuidTest/schema.sql deleted file mode 100644 index ae7f3c32c33..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/projectmeasures/PopulateProjectMeasuresMetricUuidTest/schema.sql +++ /dev/null @@ -1,44 +0,0 @@ -CREATE TABLE "PROJECT_MEASURES"( - "VALUE" DOUBLE, - "METRIC_UUID" VARCHAR(40), - "METRIC_ID" INTEGER NOT NULL, - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "ALERT_STATUS" VARCHAR(5), - "ALERT_TEXT" VARCHAR(4000), - "DESCRIPTION" VARCHAR(4000), - "PERSON_ID" INTEGER, - "VARIATION_VALUE_1" DOUBLE, - "VARIATION_VALUE_2" DOUBLE, - "VARIATION_VALUE_3" DOUBLE, - "VARIATION_VALUE_4" DOUBLE, - "VARIATION_VALUE_5" DOUBLE, - "MEASURE_DATA" BLOB, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "PROJECT_MEASURES" ADD CONSTRAINT "PK_PROJECT_MEASURES" PRIMARY KEY("UUID"); -CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES"("ANALYSIS_UUID", "METRIC_ID"); -CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES"("COMPONENT_UUID"); - -CREATE TABLE "METRICS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(255), - "DIRECTION" INTEGER DEFAULT 0 NOT NULL, - "DOMAIN" VARCHAR(64), - "SHORT_NAME" VARCHAR(64), - "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, - "VAL_TYPE" VARCHAR(8), - "USER_MANAGED" BOOLEAN DEFAULT FALSE, - "ENABLED" BOOLEAN DEFAULT TRUE, - "WORST_VALUE" DOUBLE, - "BEST_VALUE" DOUBLE, - "OPTIMIZED_BEST_VALUE" BOOLEAN, - "HIDDEN" BOOLEAN, - "DELETE_HISTORICAL_DATA" BOOLEAN, - "DECIMAL_SCALE" INTEGER -); -ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/AddMetricUuidColumnToQualityGateConditionsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/AddMetricUuidColumnToQualityGateConditionsTest/schema.sql deleted file mode 100644 index dff1d72e573..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/AddMetricUuidColumnToQualityGateConditionsTest/schema.sql +++ /dev/null @@ -1,34 +0,0 @@ -CREATE TABLE "QUALITY_GATE_CONDITIONS"( - "UUID" VARCHAR(40) NOT NULL, - "QGATE_ID" INTEGER, - "METRIC_ID" INTEGER, - "PERIOD" INTEGER, - "OPERATOR" VARCHAR(3), - "VALUE_ERROR" VARCHAR(64), - "VALUE_WARNING" VARCHAR(64), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "QUALITY_GATE_CONDITIONS" ADD CONSTRAINT "PK_QUALITY_GATE_CONDITIONS" PRIMARY KEY("UUID"); - -CREATE TABLE "METRICS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(255), - "DIRECTION" INTEGER DEFAULT 0 NOT NULL, - "DOMAIN" VARCHAR(64), - "SHORT_NAME" VARCHAR(64), - "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, - "VAL_TYPE" VARCHAR(8), - "USER_MANAGED" BOOLEAN DEFAULT FALSE, - "ENABLED" BOOLEAN DEFAULT TRUE, - "WORST_VALUE" DOUBLE, - "BEST_VALUE" DOUBLE, - "OPTIMIZED_BEST_VALUE" BOOLEAN, - "HIDDEN" BOOLEAN, - "DELETE_HISTORICAL_DATA" BOOLEAN, - "DECIMAL_SCALE" INTEGER -); -ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/DropMetricIdColumnOfQualityGateConditionsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/DropMetricIdColumnOfQualityGateConditionsTableTest/schema.sql deleted file mode 100644 index aa2aaf71563..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/DropMetricIdColumnOfQualityGateConditionsTableTest/schema.sql +++ /dev/null @@ -1,35 +0,0 @@ -CREATE TABLE "QUALITY_GATE_CONDITIONS"( - "UUID" VARCHAR(40) NOT NULL, - "QGATE_ID" INTEGER, - "METRIC_UUID" VARCHAR(40) NOT NULL, - "METRIC_ID" INTEGER, - "PERIOD" INTEGER, - "OPERATOR" VARCHAR(3), - "VALUE_ERROR" VARCHAR(64), - "VALUE_WARNING" VARCHAR(64), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "QUALITY_GATE_CONDITIONS" ADD CONSTRAINT "PK_QUALITY_GATE_CONDITIONS" PRIMARY KEY("UUID"); - -CREATE TABLE "METRICS"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(255), - "DIRECTION" INTEGER DEFAULT 0 NOT NULL, - "DOMAIN" VARCHAR(64), - "SHORT_NAME" VARCHAR(64), - "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, - "VAL_TYPE" VARCHAR(8), - "USER_MANAGED" BOOLEAN DEFAULT FALSE, - "ENABLED" BOOLEAN DEFAULT TRUE, - "WORST_VALUE" DOUBLE, - "BEST_VALUE" DOUBLE, - "OPTIMIZED_BEST_VALUE" BOOLEAN, - "HIDDEN" BOOLEAN, - "DELETE_HISTORICAL_DATA" BOOLEAN, - "DECIMAL_SCALE" INTEGER -); -ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/MakeQualityGateConditionsMetricUuidNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/MakeQualityGateConditionsMetricUuidNotNullableTest/schema.sql deleted file mode 100644 index 2b5a222cb91..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/MakeQualityGateConditionsMetricUuidNotNullableTest/schema.sql +++ /dev/null @@ -1,35 +0,0 @@ -CREATE TABLE "QUALITY_GATE_CONDITIONS"( - "UUID" VARCHAR(40) NOT NULL, - "QGATE_ID" INTEGER, - "METRIC_UUID" VARCHAR(40), - "METRIC_ID" INTEGER, - "PERIOD" INTEGER, - "OPERATOR" VARCHAR(3), - "VALUE_ERROR" VARCHAR(64), - "VALUE_WARNING" VARCHAR(64), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "QUALITY_GATE_CONDITIONS" ADD CONSTRAINT "PK_QUALITY_GATE_CONDITIONS" PRIMARY KEY("UUID"); - -CREATE TABLE "METRICS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(255), - "DIRECTION" INTEGER DEFAULT 0 NOT NULL, - "DOMAIN" VARCHAR(64), - "SHORT_NAME" VARCHAR(64), - "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, - "VAL_TYPE" VARCHAR(8), - "USER_MANAGED" BOOLEAN DEFAULT FALSE, - "ENABLED" BOOLEAN DEFAULT TRUE, - "WORST_VALUE" DOUBLE, - "BEST_VALUE" DOUBLE, - "OPTIMIZED_BEST_VALUE" BOOLEAN, - "HIDDEN" BOOLEAN, - "DELETE_HISTORICAL_DATA" BOOLEAN, - "DECIMAL_SCALE" INTEGER -); -ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/PopulateQualityGateConditionsMetricUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/PopulateQualityGateConditionsMetricUuidTest/schema.sql deleted file mode 100644 index 2b5a222cb91..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/metrics/qualitygateconditions/PopulateQualityGateConditionsMetricUuidTest/schema.sql +++ /dev/null @@ -1,35 +0,0 @@ -CREATE TABLE "QUALITY_GATE_CONDITIONS"( - "UUID" VARCHAR(40) NOT NULL, - "QGATE_ID" INTEGER, - "METRIC_UUID" VARCHAR(40), - "METRIC_ID" INTEGER, - "PERIOD" INTEGER, - "OPERATOR" VARCHAR(3), - "VALUE_ERROR" VARCHAR(64), - "VALUE_WARNING" VARCHAR(64), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "QUALITY_GATE_CONDITIONS" ADD CONSTRAINT "PK_QUALITY_GATE_CONDITIONS" PRIMARY KEY("UUID"); - -CREATE TABLE "METRICS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(255), - "DIRECTION" INTEGER DEFAULT 0 NOT NULL, - "DOMAIN" VARCHAR(64), - "SHORT_NAME" VARCHAR(64), - "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, - "VAL_TYPE" VARCHAR(8), - "USER_MANAGED" BOOLEAN DEFAULT FALSE, - "ENABLED" BOOLEAN DEFAULT TRUE, - "WORST_VALUE" DOUBLE, - "BEST_VALUE" DOUBLE, - "OPTIMIZED_BEST_VALUE" BOOLEAN, - "HIDDEN" BOOLEAN, - "DELETE_HISTORICAL_DATA" BOOLEAN, - "DECIMAL_SCALE" INTEGER -); -ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/notifications/AddPrimaryKeyOnUuidColumnOfNotificationTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/notifications/AddPrimaryKeyOnUuidColumnOfNotificationTableTest/schema.sql deleted file mode 100644 index 530b33a0863..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/notifications/AddPrimaryKeyOnUuidColumnOfNotificationTableTest/schema.sql +++ /dev/null @@ -1,6 +0,0 @@ -CREATE TABLE "NOTIFICATIONS"( - "ID" INTEGER NOT NULL, - "DATA" BLOB, - "UUID" VARCHAR(40) NOT NULL, - "CREATED_AT" BIGINT NOT NULL -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/notifications/AddUuidAndCreatedAtColumnsToNotificationTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/notifications/AddUuidAndCreatedAtColumnsToNotificationTest/schema.sql deleted file mode 100644 index bde193df885..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/notifications/AddUuidAndCreatedAtColumnsToNotificationTest/schema.sql +++ /dev/null @@ -1,5 +0,0 @@ -CREATE TABLE "NOTIFICATIONS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "DATA" BLOB -); -ALTER TABLE "NOTIFICATIONS" ADD CONSTRAINT "PK_NOTIFICATIONS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/notifications/DropIdColumnOfNotificationTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/notifications/DropIdColumnOfNotificationTableTest/schema.sql deleted file mode 100644 index b007218aa89..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/notifications/DropIdColumnOfNotificationTableTest/schema.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE "NOTIFICATIONS"( - "ID" INTEGER NOT NULL, - "DATA" BLOB, - "UUID" VARCHAR(40) NOT NULL, - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "NOTIFICATIONS" ADD CONSTRAINT "PK_NOTIFICATIONS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/notifications/DropPrimaryKeyOnIdColumnOfNotificationTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/notifications/DropPrimaryKeyOnIdColumnOfNotificationTableTest/schema.sql deleted file mode 100644 index 082c809f6e0..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/notifications/DropPrimaryKeyOnIdColumnOfNotificationTableTest/schema.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE "NOTIFICATIONS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "DATA" BLOB -); -ALTER TABLE "NOTIFICATIONS" ADD CONSTRAINT "PK_NOTIFICATIONS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/notifications/MakeNotificationUuidAndCreatedAtColumnsNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/notifications/MakeNotificationUuidAndCreatedAtColumnsNotNullableTest/schema.sql deleted file mode 100644 index 3e3bae5d79d..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/notifications/MakeNotificationUuidAndCreatedAtColumnsNotNullableTest/schema.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE "NOTIFICATIONS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "CREATED_AT" BIGINT, - "DATA" BLOB -); -ALTER TABLE "NOTIFICATIONS" ADD CONSTRAINT "PK_NOTIFICATIONS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/notifications/PopulateNotificationUuidAndCreatedAtTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/notifications/PopulateNotificationUuidAndCreatedAtTest/schema.sql deleted file mode 100644 index ca8451dbfd5..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/notifications/PopulateNotificationUuidAndCreatedAtTest/schema.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE "NOTIFICATIONS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "CREATED_AT" BIGINT NULL, - "DATA" BLOB -); -ALTER TABLE "NOTIFICATIONS" ADD CONSTRAINT "PK_NOTIFICATIONS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTableTest/schema.sql deleted file mode 100644 index 52bb4a2e2c5..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "PERMISSION_TEMPLATES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "KEE" VARCHAR(100) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "KEY_PATTERN" VARCHAR(500) -); - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/AddUuidColumnToPermissionTemplatesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/AddUuidColumnToPermissionTemplatesTest/schema.sql deleted file mode 100644 index 0a21fe126d2..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/AddUuidColumnToPermissionTemplatesTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PERMISSION_TEMPLATES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "KEE" VARCHAR(100) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "KEY_PATTERN" VARCHAR(500) -); -ALTER TABLE "PERMISSION_TEMPLATES" ADD CONSTRAINT "PK_PERMISSION_TEMPLATES" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/DropIdColumnOfPermissionTemplatesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/DropIdColumnOfPermissionTemplatesTableTest/schema.sql deleted file mode 100644 index abff11e7672..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/DropIdColumnOfPermissionTemplatesTableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "PERMISSION_TEMPLATES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "KEE" VARCHAR(100) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "KEY_PATTERN" VARCHAR(500) -); -ALTER TABLE "PERMISSION_TEMPLATES" ADD CONSTRAINT "PK_PERMISSION_TEMPLATES" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/DropKeeColumnOfPermissionTemplatesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/DropKeeColumnOfPermissionTemplatesTableTest/schema.sql deleted file mode 100644 index 10c79779e6d..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/DropKeeColumnOfPermissionTemplatesTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PERMISSION_TEMPLATES"( - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "KEE" VARCHAR(100) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "KEY_PATTERN" VARCHAR(500) -); -ALTER TABLE "PERMISSION_TEMPLATES" ADD CONSTRAINT "PK_PERMISSION_TEMPLATES" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/DropPrimaryKeyOnIdColumnOfPermissionTemplatesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/DropPrimaryKeyOnIdColumnOfPermissionTemplatesTableTest/schema.sql deleted file mode 100644 index ed17fd38257..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/DropPrimaryKeyOnIdColumnOfPermissionTemplatesTableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "PERMISSION_TEMPLATES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "KEE" VARCHAR(100) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "KEY_PATTERN" VARCHAR(500) -); -ALTER TABLE "PERMISSION_TEMPLATES" ADD CONSTRAINT "PK_PERMISSION_TEMPLATES" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/MakePermissionTemplateUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/MakePermissionTemplateUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index a9667137aec..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/MakePermissionTemplateUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "PERMISSION_TEMPLATES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "KEE" VARCHAR(100) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "KEY_PATTERN" VARCHAR(500) -); -ALTER TABLE "PERMISSION_TEMPLATES" ADD CONSTRAINT "PK_PERMISSION_TEMPLATES" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/PopulatePermissionTemplatesUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/PopulatePermissionTemplatesUuidTest/schema.sql deleted file mode 100644 index a9667137aec..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/PopulatePermissionTemplatesUuidTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "PERMISSION_TEMPLATES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "KEE" VARCHAR(100) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "KEY_PATTERN" VARCHAR(500) -); -ALTER TABLE "PERMISSION_TEMPLATES" ADD CONSTRAINT "PK_PERMISSION_TEMPLATES" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/AddTemplateUuidColumnToPermTemplatesGroupsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/AddTemplateUuidColumnToPermTemplatesGroupsTest/schema.sql deleted file mode 100644 index 8fc600ae7dd..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/AddTemplateUuidColumnToPermTemplatesGroupsTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_GROUPS"( - "UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "PERM_TEMPLATES_GROUPS" ADD CONSTRAINT "PK_PERM_TEMPLATES_GROUPS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/DropTemplateIdColumnOfPermTemplatesGroupsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/DropTemplateIdColumnOfPermTemplatesGroupsTableTest/schema.sql deleted file mode 100644 index 9be99ebafe8..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/DropTemplateIdColumnOfPermTemplatesGroupsTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_GROUPS"( - "UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER, - "TEMPLATE_UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "PERM_TEMPLATES_GROUPS" ADD CONSTRAINT "PK_PERM_TEMPLATES_GROUPS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/MakePermTemplatesGroupsTemplateUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/MakePermTemplatesGroupsTemplateUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index a3174f7b947..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/MakePermTemplatesGroupsTemplateUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_GROUPS"( - "UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER, - "TEMPLATE_UUID" VARCHAR(40), - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "PERM_TEMPLATES_GROUPS" ADD CONSTRAINT "PK_PERM_TEMPLATES_GROUPS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/PopulatePermTemplatesGroupsTemplateUuidColumnTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/PopulatePermTemplatesGroupsTemplateUuidColumnTest/schema.sql deleted file mode 100644 index 5f566add810..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesgroups/PopulatePermTemplatesGroupsTemplateUuidColumnTest/schema.sql +++ /dev/null @@ -1,23 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_GROUPS"( - "UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER, - "TEMPLATE_UUID" VARCHAR(40), - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "PERM_TEMPLATES_GROUPS" ADD CONSTRAINT "PK_PERM_TEMPLATES_GROUPS" PRIMARY KEY("UUID"); - -CREATE TABLE "PERMISSION_TEMPLATES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "KEE" VARCHAR(100) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "KEY_PATTERN" VARCHAR(500) -); -ALTER TABLE "PERMISSION_TEMPLATES" ADD CONSTRAINT "PK_PERMISSION_TEMPLATES" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/AddTemplateUuidColumnToPermTemplatesUsersTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/AddTemplateUuidColumnToPermTemplatesUsersTest/schema.sql deleted file mode 100644 index e9a334d0030..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/AddTemplateUuidColumnToPermTemplatesUsersTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_USERS"( - "UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "PERM_TEMPLATES_USERS" ADD CONSTRAINT "PK_PERM_TEMPLATES_USERS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/DropTemplateIdColumnOfPermTemplatesUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/DropTemplateIdColumnOfPermTemplatesUsersTableTest/schema.sql deleted file mode 100644 index af182cb58ab..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/DropTemplateIdColumnOfPermTemplatesUsersTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_USERS"( - "UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "PERM_TEMPLATES_USERS" ADD CONSTRAINT "PK_PERM_TEMPLATES_USERS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/MakePermTemplatesUsersTemplateUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/MakePermTemplatesUsersTemplateUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index d175d8aa1aa..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/MakePermTemplatesUsersTemplateUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_USERS"( - "UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL, - "TEMPLATE_UUID" VARCHAR(40), - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "PERM_TEMPLATES_USERS" ADD CONSTRAINT "PK_PERM_TEMPLATES_USERS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/PopulatePermTemplatesUsersTemplateUuidColumnTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/PopulatePermTemplatesUsersTemplateUuidColumnTest/schema.sql deleted file mode 100644 index 055479cfb13..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtemplatesusers/PopulatePermTemplatesUsersTemplateUuidColumnTest/schema.sql +++ /dev/null @@ -1,23 +0,0 @@ -CREATE TABLE "PERMISSION_TEMPLATES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "KEE" VARCHAR(100) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "KEY_PATTERN" VARCHAR(500) -); -ALTER TABLE "PERMISSION_TEMPLATES" ADD CONSTRAINT "PK_PERMISSION_TEMPLATES" PRIMARY KEY("ID"); - -CREATE TABLE "PERM_TEMPLATES_USERS"( - "UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL, - "TEMPLATE_UUID" VARCHAR(40), - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "PERM_TEMPLATES_USERS" ADD CONSTRAINT "PK_PERM_TEMPLATES_USERS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/AddTemplateUuidColumnToPermTplCharacteristicsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/AddTemplateUuidColumnToPermTplCharacteristicsTest/schema.sql deleted file mode 100644 index bd692486b2a..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/AddTemplateUuidColumnToPermTplCharacteristicsTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "PERM_TPL_CHARACTERISTICS"( - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_KEY" VARCHAR(64) NOT NULL, - "WITH_PROJECT_CREATOR" BOOLEAN DEFAULT FALSE NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PERM_TPL_CHARACTERISTICS" ADD CONSTRAINT "PK_PERM_TPL_CHARACTERISTICS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PERM_TPL_CHARAC" ON "PERM_TPL_CHARACTERISTICS"("TEMPLATE_ID", "PERMISSION_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest/schema.sql deleted file mode 100644 index 648fb65271a..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PERM_TPL_CHARACTERISTICS"( - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) NOT NULL, - "PERMISSION_KEY" VARCHAR(64) NOT NULL, - "WITH_PROJECT_CREATOR" BOOLEAN DEFAULT FALSE NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PERM_TPL_CHARACTERISTICS" ADD CONSTRAINT "PK_PERM_TPL_CHARACTERISTICS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PERM_TPL_CHARAC" ON "PERM_TPL_CHARACTERISTICS"("TEMPLATE_ID", "PERMISSION_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/DropTemplateIdColumnOfPermTplCharacteristicsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/DropTemplateIdColumnOfPermTplCharacteristicsTableTest/schema.sql deleted file mode 100644 index f61883e3019..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/DropTemplateIdColumnOfPermTplCharacteristicsTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PERM_TPL_CHARACTERISTICS"( - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_KEY" VARCHAR(64) NOT NULL, - "WITH_PROJECT_CREATOR" BOOLEAN DEFAULT FALSE NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PERM_TPL_CHARACTERISTICS" ADD CONSTRAINT "PK_PERM_TPL_CHARACTERISTICS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PERM_TPL_CHARAC" ON "PERM_TPL_CHARACTERISTICS"("TEMPLATE_UUID", "PERMISSION_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest/schema.sql deleted file mode 100644 index 47559a2cab0..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PERM_TPL_CHARACTERISTICS"( - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" INTEGER NOT NULL, - "TEMPLATE_ID" VARCHAR(40) NOT NULL, - "PERMISSION_KEY" VARCHAR(64) NOT NULL, - "WITH_PROJECT_CREATOR" BOOLEAN DEFAULT FALSE NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PERM_TPL_CHARACTERISTICS" ADD CONSTRAINT "PK_PERM_TPL_CHARACTERISTICS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PERM_TPL_CHARAC" ON "PERM_TPL_CHARACTERISTICS"("TEMPLATE_ID", "PERMISSION_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/MakePermTplCharacteristicsTemplateUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/MakePermTplCharacteristicsTemplateUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index 5e36ef16eff..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/MakePermTplCharacteristicsTemplateUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PERM_TPL_CHARACTERISTICS"( - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "TEMPLATE_UUID" VARCHAR(40), - "PERMISSION_KEY" VARCHAR(64) NOT NULL, - "WITH_PROJECT_CREATOR" BOOLEAN DEFAULT FALSE NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PERM_TPL_CHARACTERISTICS" ADD CONSTRAINT "PK_PERM_TPL_CHARACTERISTICS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PERM_TPL_CHARAC" ON "PERM_TPL_CHARACTERISTICS"("TEMPLATE_ID", "PERMISSION_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/PopulatePermTplCharacteristicsTemplateUuidColumnTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/PopulatePermTplCharacteristicsTemplateUuidColumnTest/schema.sql deleted file mode 100644 index 2443d0d12c8..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permissiontemplates/fk/permtplcharacteristics/PopulatePermTplCharacteristicsTemplateUuidColumnTest/schema.sql +++ /dev/null @@ -1,24 +0,0 @@ -CREATE TABLE "PERMISSION_TEMPLATES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "KEE" VARCHAR(100) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "KEY_PATTERN" VARCHAR(500) -); -ALTER TABLE "PERMISSION_TEMPLATES" ADD CONSTRAINT "PK_PERMISSION_TEMPLATES" PRIMARY KEY("ID"); - -CREATE TABLE "PERM_TPL_CHARACTERISTICS"( - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "TEMPLATE_UUID" VARCHAR(40), - "PERMISSION_KEY" VARCHAR(64) NOT NULL, - "WITH_PROJECT_CREATOR" BOOLEAN DEFAULT FALSE NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PERM_TPL_CHARACTERISTICS" ADD CONSTRAINT "PK_PERM_TPL_CHARACTERISTICS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PERM_TPL_CHARAC" ON "PERM_TPL_CHARACTERISTICS"("TEMPLATE_ID", "PERMISSION_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTableTest/schema.sql deleted file mode 100644 index f3319b5bc6f..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTableTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_GROUPS"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/AddUuidColumnToPermTemplatesGroupsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/AddUuidColumnToPermTemplatesGroupsTableTest/schema.sql deleted file mode 100644 index fa6baad81b0..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/AddUuidColumnToPermTemplatesGroupsTableTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_GROUPS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "GROUP_ID" INTEGER, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "PERM_TEMPLATES_GROUPS" ADD CONSTRAINT "PK_PERM_TEMPLATES_GROUPS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/DropIdColumnOfPermTemplatesGroupsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/DropIdColumnOfPermTemplatesGroupsTableTest/schema.sql deleted file mode 100644 index 395419e5803..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/DropIdColumnOfPermTemplatesGroupsTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_GROUPS"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "PERM_TEMPLATES_GROUPS" ADD CONSTRAINT "PK_PERM_TEMPLATES_GROUPS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTableTest/schema.sql deleted file mode 100644 index dcef0db3e5e..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_GROUPS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "GROUP_ID" INTEGER, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "PERM_TEMPLATES_GROUPS" ADD CONSTRAINT "PK_PERM_TEMPLATES_GROUPS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/MakePermTemplatesGroupsUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/MakePermTemplatesGroupsUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index a1d04848527..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/MakePermTemplatesGroupsUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_GROUPS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "GROUP_ID" INTEGER, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "PERM_TEMPLATES_GROUPS" ADD CONSTRAINT "PK_PERM_TEMPLATES_GROUPS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/PopulatePermTemplatesGroupsUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/PopulatePermTemplatesGroupsUuidTest/schema.sql deleted file mode 100644 index a1d04848527..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesgroups/PopulatePermTemplatesGroupsUuidTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_GROUPS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "GROUP_ID" INTEGER, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "PERM_TEMPLATES_GROUPS" ADD CONSTRAINT "PK_PERM_TEMPLATES_GROUPS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTableTest/schema.sql deleted file mode 100644 index d51c8ba2245..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTableTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_USERS"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/AddUuidColumnToPermTemplatesUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/AddUuidColumnToPermTemplatesUsersTableTest/schema.sql deleted file mode 100644 index 285b963b8cd..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/AddUuidColumnToPermTemplatesUsersTableTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_USERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "USER_ID" INTEGER NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "PERM_TEMPLATES_USERS" ADD CONSTRAINT "PK_PERM_TEMPLATES_USERS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/DropIdColumnOfPermTemplatesUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/DropIdColumnOfPermTemplatesUsersTableTest/schema.sql deleted file mode 100644 index f2974f76813..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/DropIdColumnOfPermTemplatesUsersTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_USERS"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "PERM_TEMPLATES_USERS" ADD CONSTRAINT "PK_PERM_TEMPLATES_USERS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTableTest/schema.sql deleted file mode 100644 index dc2d8b31e74..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_USERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "PERM_TEMPLATES_USERS" ADD CONSTRAINT "PK_PERM_TEMPLATES_USERS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/MakePermTemplatesUsersUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/MakePermTemplatesUsersUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index 23c2c4f21e6..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/MakePermTemplatesUsersUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_USERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "USER_ID" INTEGER NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "PERM_TEMPLATES_USERS" ADD CONSTRAINT "PK_PERM_TEMPLATES_USERS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/PopulatePermTemplatesUsersUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/PopulatePermTemplatesUsersUuidTest/schema.sql deleted file mode 100644 index 23c2c4f21e6..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtemplatesusers/PopulatePermTemplatesUsersUuidTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_USERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "USER_ID" INTEGER NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "PERM_TEMPLATES_USERS" ADD CONSTRAINT "PK_PERM_TEMPLATES_USERS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTableTest/schema.sql deleted file mode 100644 index e8784cadf0c..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "PERM_TPL_CHARACTERISTICS"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_KEY" VARCHAR(64) NOT NULL, - "WITH_PROJECT_CREATOR" BOOLEAN DEFAULT FALSE NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "UNIQ_PERM_TPL_CHARAC" ON "PERM_TPL_CHARACTERISTICS"("TEMPLATE_ID", "PERMISSION_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/AddUuidColumnToPermTplCharacteristicsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/AddUuidColumnToPermTplCharacteristicsTableTest/schema.sql deleted file mode 100644 index 174c2e880c9..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/AddUuidColumnToPermTplCharacteristicsTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "PERM_TPL_CHARACTERISTICS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_KEY" VARCHAR(64) NOT NULL, - "WITH_PROJECT_CREATOR" BOOLEAN DEFAULT FALSE NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PERM_TPL_CHARACTERISTICS" ADD CONSTRAINT "PK_PERM_TPL_CHARACTERISTICS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_PERM_TPL_CHARAC" ON "PERM_TPL_CHARACTERISTICS"("TEMPLATE_ID", "PERMISSION_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/DropIdColumnOfPermTplCharacteristicsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/DropIdColumnOfPermTplCharacteristicsTableTest/schema.sql deleted file mode 100644 index 8fad4d5a96c..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/DropIdColumnOfPermTplCharacteristicsTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PERM_TPL_CHARACTERISTICS"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_KEY" VARCHAR(64) NOT NULL, - "WITH_PROJECT_CREATOR" BOOLEAN DEFAULT FALSE NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PERM_TPL_CHARACTERISTICS" ADD CONSTRAINT "PK_PERM_TPL_CHARACTERISTICS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PERM_TPL_CHARAC" ON "PERM_TPL_CHARACTERISTICS"("TEMPLATE_ID", "PERMISSION_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTableTest/schema.sql deleted file mode 100644 index 3cf4c91cf61..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PERM_TPL_CHARACTERISTICS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_KEY" VARCHAR(64) NOT NULL, - "WITH_PROJECT_CREATOR" BOOLEAN DEFAULT FALSE NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PERM_TPL_CHARACTERISTICS" ADD CONSTRAINT "PK_PERM_TPL_CHARACTERISTICS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_PERM_TPL_CHARAC" ON "PERM_TPL_CHARACTERISTICS"("TEMPLATE_ID", "PERMISSION_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/MakePermTplCharacteristicsUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/MakePermTplCharacteristicsUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index ea986ff54d8..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/MakePermTplCharacteristicsUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PERM_TPL_CHARACTERISTICS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_KEY" VARCHAR(64) NOT NULL, - "WITH_PROJECT_CREATOR" BOOLEAN DEFAULT FALSE NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PERM_TPL_CHARACTERISTICS" ADD CONSTRAINT "PK_PERM_TPL_CHARACTERISTICS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_PERM_TPL_CHARAC" ON "PERM_TPL_CHARACTERISTICS"("TEMPLATE_ID", "PERMISSION_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/PopulatePermTplCharacteristicsUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/PopulatePermTplCharacteristicsUuidTest/schema.sql deleted file mode 100644 index ea986ff54d8..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/permtplcharacteristics/PopulatePermTplCharacteristicsUuidTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PERM_TPL_CHARACTERISTICS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_KEY" VARCHAR(64) NOT NULL, - "WITH_PROJECT_CREATOR" BOOLEAN DEFAULT FALSE NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PERM_TPL_CHARACTERISTICS" ADD CONSTRAINT "PK_PERM_TPL_CHARACTERISTICS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_PERM_TPL_CHARAC" ON "PERM_TPL_CHARACTERISTICS"("TEMPLATE_ID", "PERMISSION_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectmeasures/AddPrimaryKeyOnUuidColumnOfProjectMeasureTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectmeasures/AddPrimaryKeyOnUuidColumnOfProjectMeasureTableTest/schema.sql deleted file mode 100644 index 81664d485b2..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectmeasures/AddPrimaryKeyOnUuidColumnOfProjectMeasureTableTest/schema.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TABLE "PROJECT_MEASURES"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "VALUE" DOUBLE, - "METRIC_ID" INTEGER NOT NULL, - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "ALERT_STATUS" VARCHAR(5), - "ALERT_TEXT" VARCHAR(4000), - "DESCRIPTION" VARCHAR(4000), - "PERSON_ID" INTEGER, - "VARIATION_VALUE_1" DOUBLE, - "VARIATION_VALUE_2" DOUBLE, - "VARIATION_VALUE_3" DOUBLE, - "VARIATION_VALUE_4" DOUBLE, - "VARIATION_VALUE_5" DOUBLE, - "MEASURE_DATA" BLOB -); -CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES"("ANALYSIS_UUID", "METRIC_ID"); -CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectmeasures/AddUuidToProjectMeasuresTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectmeasures/AddUuidToProjectMeasuresTest/schema.sql deleted file mode 100644 index 3ff9ce0fef9..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectmeasures/AddUuidToProjectMeasuresTest/schema.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TABLE "PROJECT_MEASURES"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "VALUE" DOUBLE, - "METRIC_ID" INTEGER NOT NULL, - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "ALERT_STATUS" VARCHAR(5), - "ALERT_TEXT" VARCHAR(4000), - "DESCRIPTION" VARCHAR(4000), - "PERSON_ID" INTEGER, - "VARIATION_VALUE_1" DOUBLE, - "VARIATION_VALUE_2" DOUBLE, - "VARIATION_VALUE_3" DOUBLE, - "VARIATION_VALUE_4" DOUBLE, - "VARIATION_VALUE_5" DOUBLE, - "MEASURE_DATA" BLOB -); -ALTER TABLE "PROJECT_MEASURES" ADD CONSTRAINT "PK_PROJECT_MEASURES" PRIMARY KEY("ID"); -CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES"("ANALYSIS_UUID", "METRIC_ID"); -CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectmeasures/DropIdColumnOfProjectMeasuresTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectmeasures/DropIdColumnOfProjectMeasuresTableTest/schema.sql deleted file mode 100644 index f66002cb755..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectmeasures/DropIdColumnOfProjectMeasuresTableTest/schema.sql +++ /dev/null @@ -1,22 +0,0 @@ -CREATE TABLE "PROJECT_MEASURES"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "VALUE" DOUBLE, - "METRIC_ID" INTEGER NOT NULL, - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "ALERT_STATUS" VARCHAR(5), - "ALERT_TEXT" VARCHAR(4000), - "DESCRIPTION" VARCHAR(4000), - "PERSON_ID" INTEGER, - "VARIATION_VALUE_1" DOUBLE, - "VARIATION_VALUE_2" DOUBLE, - "VARIATION_VALUE_3" DOUBLE, - "VARIATION_VALUE_4" DOUBLE, - "VARIATION_VALUE_5" DOUBLE, - "MEASURE_DATA" BLOB -); -ALTER TABLE "PROJECT_MEASURES" ADD CONSTRAINT "PK_PROJECT_MEASURES" PRIMARY KEY("UUID"); -CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES"("ANALYSIS_UUID", "METRIC_ID"); -CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectmeasures/DropPrimaryKeyOnIdColumnOfProjectMeasuresTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectmeasures/DropPrimaryKeyOnIdColumnOfProjectMeasuresTableTest/schema.sql deleted file mode 100644 index fd01be5f1bd..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectmeasures/DropPrimaryKeyOnIdColumnOfProjectMeasuresTableTest/schema.sql +++ /dev/null @@ -1,22 +0,0 @@ -CREATE TABLE "PROJECT_MEASURES"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "VALUE" DOUBLE, - "METRIC_ID" INTEGER NOT NULL, - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "ALERT_STATUS" VARCHAR(5), - "ALERT_TEXT" VARCHAR(4000), - "DESCRIPTION" VARCHAR(4000), - "PERSON_ID" INTEGER, - "VARIATION_VALUE_1" DOUBLE, - "VARIATION_VALUE_2" DOUBLE, - "VARIATION_VALUE_3" DOUBLE, - "VARIATION_VALUE_4" DOUBLE, - "VARIATION_VALUE_5" DOUBLE, - "MEASURE_DATA" BLOB -); -ALTER TABLE "PROJECT_MEASURES" ADD CONSTRAINT "PK_PROJECT_MEASURES" PRIMARY KEY("ID"); -CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES"("ANALYSIS_UUID", "METRIC_ID"); -CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectmeasures/MakeProjectMeasuresUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectmeasures/MakeProjectMeasuresUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index ba02385e040..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectmeasures/MakeProjectMeasuresUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,22 +0,0 @@ -CREATE TABLE "PROJECT_MEASURES"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "VALUE" DOUBLE, - "METRIC_ID" INTEGER NOT NULL, - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "ALERT_STATUS" VARCHAR(5), - "ALERT_TEXT" VARCHAR(4000), - "DESCRIPTION" VARCHAR(4000), - "PERSON_ID" INTEGER, - "VARIATION_VALUE_1" DOUBLE, - "VARIATION_VALUE_2" DOUBLE, - "VARIATION_VALUE_3" DOUBLE, - "VARIATION_VALUE_4" DOUBLE, - "VARIATION_VALUE_5" DOUBLE, - "MEASURE_DATA" BLOB -); -ALTER TABLE "PROJECT_MEASURES" ADD CONSTRAINT "PK_PROJECT_MEASURES" PRIMARY KEY("ID"); -CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES"("ANALYSIS_UUID", "METRIC_ID"); -CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectmeasures/PopulateProjectMeasuresUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectmeasures/PopulateProjectMeasuresUuidTest/schema.sql deleted file mode 100644 index ba02385e040..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectmeasures/PopulateProjectMeasuresUuidTest/schema.sql +++ /dev/null @@ -1,22 +0,0 @@ -CREATE TABLE "PROJECT_MEASURES"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "VALUE" DOUBLE, - "METRIC_ID" INTEGER NOT NULL, - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "ALERT_STATUS" VARCHAR(5), - "ALERT_TEXT" VARCHAR(4000), - "DESCRIPTION" VARCHAR(4000), - "PERSON_ID" INTEGER, - "VARIATION_VALUE_1" DOUBLE, - "VARIATION_VALUE_2" DOUBLE, - "VARIATION_VALUE_3" DOUBLE, - "VARIATION_VALUE_4" DOUBLE, - "VARIATION_VALUE_5" DOUBLE, - "MEASURE_DATA" BLOB -); -ALTER TABLE "PROJECT_MEASURES" ADD CONSTRAINT "PK_PROJECT_MEASURES" PRIMARY KEY("ID"); -CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES"("ANALYSIS_UUID", "METRIC_ID"); -CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTableTest/schema.sql deleted file mode 100644 index b294830aee9..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTableTest/schema.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE "PROJECT_QPROFILES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "PROFILE_KEY" VARCHAR(50) NOT NULL -); -CREATE UNIQUE INDEX "UNIQ_PROJECT_QPROFILES" ON "PROJECT_QPROFILES"("PROJECT_UUID", "PROFILE_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/AddUuidColumnToProjectQProfilesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/AddUuidColumnToProjectQProfilesTableTest/schema.sql deleted file mode 100644 index c7530b1d254..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/AddUuidColumnToProjectQProfilesTableTest/schema.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE "PROJECT_QPROFILES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "PROFILE_KEY" VARCHAR(50) NOT NULL -); -ALTER TABLE "PROJECT_QPROFILES" ADD CONSTRAINT "PK_PROJECT_QPROFILES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_PROJECT_QPROFILES" ON "PROJECT_QPROFILES"("PROJECT_UUID", "PROFILE_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/DropIdColumnOfProjectQProfilesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/DropIdColumnOfProjectQProfilesTableTest/schema.sql deleted file mode 100644 index d531ef1fa69..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/DropIdColumnOfProjectQProfilesTableTest/schema.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE "PROJECT_QPROFILES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "PROFILE_KEY" VARCHAR(50) NOT NULL -); -ALTER TABLE "PROJECT_QPROFILES" ADD CONSTRAINT "PK_PROJECT_QPROFILES" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PROJECT_QPROFILES" ON "PROJECT_QPROFILES"("PROJECT_UUID", "PROFILE_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest/schema.sql deleted file mode 100644 index 75824e05246..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest/schema.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE "PROJECT_QPROFILES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "PROFILE_KEY" VARCHAR(50) NOT NULL -); -ALTER TABLE "PROJECT_QPROFILES" ADD CONSTRAINT "PK_PROJECT_QPROFILES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_PROJECT_QPROFILES" ON "PROJECT_QPROFILES"("PROJECT_UUID", "PROFILE_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/MakeProjectQProfilesUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/MakeProjectQProfilesUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index f961bdc422c..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/MakeProjectQProfilesUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE "PROJECT_QPROFILES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "PROFILE_KEY" VARCHAR(50) NOT NULL -); -ALTER TABLE "PROJECT_QPROFILES" ADD CONSTRAINT "PK_PROJECT_QPROFILES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_PROJECT_QPROFILES" ON "PROJECT_QPROFILES"("PROJECT_UUID", "PROFILE_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/PopulateProjectQProfilesUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/PopulateProjectQProfilesUuidTest/schema.sql deleted file mode 100644 index f961bdc422c..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/projectqprofiles/PopulateProjectQProfilesUuidTest/schema.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE "PROJECT_QPROFILES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "PROJECT_UUID" VARCHAR(50) NOT NULL, - "PROFILE_KEY" VARCHAR(50) NOT NULL -); -ALTER TABLE "PROJECT_QPROFILES" ADD CONSTRAINT "PK_PROJECT_QPROFILES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_PROJECT_QPROFILES" ON "PROJECT_QPROFILES"("PROJECT_UUID", "PROFILE_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/properties/AddPrimaryKeyOnUuidColumnOfPropertiesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/properties/AddPrimaryKeyOnUuidColumnOfPropertiesTableTest/schema.sql deleted file mode 100644 index e2598421ec2..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/properties/AddPrimaryKeyOnUuidColumnOfPropertiesTableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "PROPERTIES"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "PROP_KEY" VARCHAR(512) NOT NULL, - "RESOURCE_ID" BIGINT, - "USER_ID" BIGINT, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB(2147483647), - "CREATED_AT" BIGINT NOT NULL -); -CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES"("PROP_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/properties/AddUuidColumnToPropertiesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/properties/AddUuidColumnToPropertiesTest/schema.sql deleted file mode 100644 index 2ac16011ffb..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/properties/AddUuidColumnToPropertiesTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "PROPERTIES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "PROP_KEY" VARCHAR(512) NOT NULL, - "RESOURCE_ID" BIGINT, - "USER_ID" BIGINT, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB(2147483647), - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PROPERTIES" ADD CONSTRAINT "PK_PROPERTIES" PRIMARY KEY("ID"); -CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES"("PROP_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/properties/DropIdColumnOfPropertiesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/properties/DropIdColumnOfPropertiesTableTest/schema.sql deleted file mode 100644 index 363c084bb6f..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/properties/DropIdColumnOfPropertiesTableTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "PROPERTIES"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "PROP_KEY" VARCHAR(512) NOT NULL, - "RESOURCE_ID" BIGINT, - "USER_ID" BIGINT, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB(2147483647), - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PROPERTIES" ADD CONSTRAINT "PK_PROPERTIES" PRIMARY KEY("UUID"); -CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES"("PROP_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/properties/DropPrimaryKeyOnIdColumnOfPropertiesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/properties/DropPrimaryKeyOnIdColumnOfPropertiesTableTest/schema.sql deleted file mode 100644 index 87e741f36e3..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/properties/DropPrimaryKeyOnIdColumnOfPropertiesTableTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "PROPERTIES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "PROP_KEY" VARCHAR(512) NOT NULL, - "RESOURCE_ID" BIGINT, - "USER_ID" BIGINT, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB(2147483647), - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PROPERTIES" ADD CONSTRAINT "PK_PROPERTIES" PRIMARY KEY("ID"); -CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES"("PROP_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/properties/MakeNotificationUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/properties/MakeNotificationUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index 8b61cd12907..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/properties/MakeNotificationUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "PROPERTIES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "PROP_KEY" VARCHAR(512) NOT NULL, - "RESOURCE_ID" BIGINT, - "USER_ID" BIGINT, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB(2147483647), - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PROPERTIES" ADD CONSTRAINT "PK_PROPERTIES" PRIMARY KEY("ID"); -CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES"("PROP_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/properties/MakePropertiesUuidColumnNotNullable/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/properties/MakePropertiesUuidColumnNotNullable/schema.sql deleted file mode 100644 index 9b6848f3a3c..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/properties/MakePropertiesUuidColumnNotNullable/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "PROPERTIES"( - "ID" INTEGER, - "UUID" VARCHAR(40), - "PROP_KEY" VARCHAR(512) NOT NULL, - "RESOURCE_ID" BIGINT, - "USER_ID" BIGINT, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB(2147483647), - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PROPERTIES" ADD CONSTRAINT "PK_PROPERTIES" PRIMARY KEY("ID"); -CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES"("PROP_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/properties/PopulatePropertiesUuidAndCreatedAtTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/properties/PopulatePropertiesUuidAndCreatedAtTest/schema.sql deleted file mode 100644 index 8b61cd12907..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/properties/PopulatePropertiesUuidAndCreatedAtTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "PROPERTIES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "PROP_KEY" VARCHAR(512) NOT NULL, - "RESOURCE_ID" BIGINT, - "USER_ID" BIGINT, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB(2147483647), - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "PROPERTIES" ADD CONSTRAINT "PK_PROPERTIES" PRIMARY KEY("ID"); -CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES"("PROP_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTableTest/schema.sql deleted file mode 100644 index eb63669fd7e..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "QUALITY_GATE_CONDITIONS"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "QGATE_ID" INTEGER, - "METRIC_ID" INTEGER, - "PERIOD" INTEGER, - "OPERATOR" VARCHAR(3), - "VALUE_ERROR" VARCHAR(64), - "VALUE_WARNING" VARCHAR(64), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/AddUuidColumnToQualityGateConditionsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/AddUuidColumnToQualityGateConditionsTableTest/schema.sql deleted file mode 100644 index a347b023e66..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/AddUuidColumnToQualityGateConditionsTableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "QUALITY_GATE_CONDITIONS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "QGATE_ID" INTEGER, - "METRIC_ID" INTEGER, - "PERIOD" INTEGER, - "OPERATOR" VARCHAR(3), - "VALUE_ERROR" VARCHAR(64), - "VALUE_WARNING" VARCHAR(64), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "QUALITY_GATE_CONDITIONS" ADD CONSTRAINT "PK_QUALITY_GATE_CONDITIONS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/DropIdColumnOfQualityGateConditionsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/DropIdColumnOfQualityGateConditionsTableTest/schema.sql deleted file mode 100644 index 68093696c1e..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/DropIdColumnOfQualityGateConditionsTableTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "QUALITY_GATE_CONDITIONS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "QGATE_ID" INTEGER, - "METRIC_ID" INTEGER, - "PERIOD" INTEGER, - "OPERATOR" VARCHAR(3), - "VALUE_ERROR" VARCHAR(64), - "VALUE_WARNING" VARCHAR(64), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "QUALITY_GATE_CONDITIONS" ADD CONSTRAINT "PK_QUALITY_GATE_CONDITIONS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/DropPrimaryKeyOnIdColumnOfQualityGateConditionsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/DropPrimaryKeyOnIdColumnOfQualityGateConditionsTableTest/schema.sql deleted file mode 100644 index 751e993b7ee..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/DropPrimaryKeyOnIdColumnOfQualityGateConditionsTableTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "QUALITY_GATE_CONDITIONS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "QGATE_ID" INTEGER, - "METRIC_ID" INTEGER, - "PERIOD" INTEGER, - "OPERATOR" VARCHAR(3), - "VALUE_ERROR" VARCHAR(64), - "VALUE_WARNING" VARCHAR(64), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "QUALITY_GATE_CONDITIONS" ADD CONSTRAINT "PK_QUALITY_GATE_CONDITIONS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/MakeQualityGateConditionsUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/MakeQualityGateConditionsUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index dd697725c44..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/MakeQualityGateConditionsUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "QUALITY_GATE_CONDITIONS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "QGATE_ID" INTEGER, - "METRIC_ID" INTEGER, - "PERIOD" INTEGER, - "OPERATOR" VARCHAR(3), - "VALUE_ERROR" VARCHAR(64), - "VALUE_WARNING" VARCHAR(64), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/PopulateQualityGateConditionsUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/PopulateQualityGateConditionsUuidTest/schema.sql deleted file mode 100644 index 2f6bb7f50c1..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygateconditions/PopulateQualityGateConditionsUuidTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "QUALITY_GATE_CONDITIONS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "QGATE_ID" INTEGER, - "METRIC_ID" INTEGER, - "PERIOD" INTEGER, - "OPERATOR" VARCHAR(3), - "VALUE_ERROR" VARCHAR(64), - "VALUE_WARNING" VARCHAR(64), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "QUALITY_GATE_CONDITIONS" ADD CONSTRAINT "PK_QUALITY_GATE_CONDITIONS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygates/AddPrimaryKeyOnUuidColumnOfQGatesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygates/AddPrimaryKeyOnUuidColumnOfQGatesTableTest/schema.sql deleted file mode 100644 index 11efefb9936..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygates/AddPrimaryKeyOnUuidColumnOfQGatesTableTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "QUALITY_GATES"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "IS_BUILT_IN" BOOLEAN NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -CREATE UNIQUE INDEX "UNIQ_QUALITY_GATES_UUID" ON "QUALITY_GATES"("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygates/AddQGateUuidColumnForQGateConditionsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygates/AddQGateUuidColumnForQGateConditionsTest/schema.sql deleted file mode 100644 index 00b6663de81..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygates/AddQGateUuidColumnForQGateConditionsTest/schema.sql +++ /dev/null @@ -1,23 +0,0 @@ -CREATE TABLE "QUALITY_GATE_CONDITIONS"( - "QGATE_ID" INTEGER, - "METRIC_ID" INTEGER, - "PERIOD" INTEGER, - "OPERATOR" VARCHAR(3), - "VALUE_ERROR" VARCHAR(64), - "VALUE_WARNING" VARCHAR(64), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "QUALITY_GATE_CONDITIONS" ADD CONSTRAINT "PK_QUALITY_GATE_CONDITIONS" PRIMARY KEY("UUID"); - -CREATE TABLE "QUALITY_GATES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "IS_BUILT_IN" BOOLEAN NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "QUALITY_GATES" ADD CONSTRAINT "PK_QUALITY_GATES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_QUALITY_GATES_UUID" ON "QUALITY_GATES"("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropIdColumnOfQGateTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropIdColumnOfQGateTableTest/schema.sql deleted file mode 100644 index dfcae5380ea..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropIdColumnOfQGateTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "QUALITY_GATES"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "IS_BUILT_IN" BOOLEAN NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "QUALITY_GATES" ADD CONSTRAINT "PK_QUALITY_GATES" PRIMARY KEY("UUID"); - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropOrphansQGateConditionsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropOrphansQGateConditionsTest/schema.sql deleted file mode 100644 index 497d17eddf5..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropOrphansQGateConditionsTest/schema.sql +++ /dev/null @@ -1,24 +0,0 @@ -CREATE TABLE "QUALITY_GATE_CONDITIONS"( - "QGATE_ID" INTEGER, - "QGATE_UUID" VARCHAR(40), - "METRIC_ID" INTEGER, - "PERIOD" INTEGER, - "OPERATOR" VARCHAR(3), - "VALUE_ERROR" VARCHAR(64), - "VALUE_WARNING" VARCHAR(64), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "QUALITY_GATE_CONDITIONS" ADD CONSTRAINT "PK_QUALITY_GATE_CONDITIONS" PRIMARY KEY("UUID"); - -CREATE TABLE "QUALITY_GATES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "IS_BUILT_IN" BOOLEAN NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "QUALITY_GATES" ADD CONSTRAINT "PK_QUALITY_GATES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_QUALITY_GATES_UUID" ON "QUALITY_GATES"("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropPrimaryKeyOnIdColumnOfQGatesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropPrimaryKeyOnIdColumnOfQGatesTableTest/schema.sql deleted file mode 100644 index 5093408fcda..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropPrimaryKeyOnIdColumnOfQGatesTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "QUALITY_GATES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "IS_BUILT_IN" BOOLEAN NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "QUALITY_GATES" ADD CONSTRAINT "PK_QUALITY_GATES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_QUALITY_GATES_UUID" ON "QUALITY_GATES"("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropQGateIdColumnForQGateConditionsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropQGateIdColumnForQGateConditionsTest/schema.sql deleted file mode 100644 index cd2a8e3f853..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropQGateIdColumnForQGateConditionsTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "QUALITY_GATE_CONDITIONS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "QGATE_ID" INTEGER, - "QGATE_UUID" VARCHAR(40) NOT NULL, - "METRIC_ID" INTEGER, - "PERIOD" INTEGER, - "OPERATOR" VARCHAR(3), - "VALUE_ERROR" VARCHAR(64), - "VALUE_WARNING" VARCHAR(64), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "QUALITY_GATE_CONDITIONS" ADD CONSTRAINT "PK_QUALITY_GATE_CONDITIONS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropUniqueIndexOnUuidColumnOfQualityGatesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropUniqueIndexOnUuidColumnOfQualityGatesTableTest/schema.sql deleted file mode 100644 index 11efefb9936..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygates/DropUniqueIndexOnUuidColumnOfQualityGatesTableTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "QUALITY_GATES"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "IS_BUILT_IN" BOOLEAN NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -CREATE UNIQUE INDEX "UNIQ_QUALITY_GATES_UUID" ON "QUALITY_GATES"("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygates/MakeQGateUuidColumnNotNullableForQGateConditionsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygates/MakeQGateUuidColumnNotNullableForQGateConditionsTest/schema.sql deleted file mode 100644 index 5fc71ff5b95..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygates/MakeQGateUuidColumnNotNullableForQGateConditionsTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "QUALITY_GATE_CONDITIONS"( - "QGATE_ID" INTEGER, - "QGATE_UUID" VARCHAR(40), - "METRIC_ID" INTEGER, - "PERIOD" INTEGER, - "OPERATOR" VARCHAR(3), - "VALUE_ERROR" VARCHAR(64), - "VALUE_WARNING" VARCHAR(64), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "QUALITY_GATE_CONDITIONS" ADD CONSTRAINT "PK_QUALITY_GATE_CONDITIONS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygates/PopulateQGateUuidColumnForQGateConditionsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygates/PopulateQGateUuidColumnForQGateConditionsTest/schema.sql deleted file mode 100644 index 497d17eddf5..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/qualitygates/PopulateQGateUuidColumnForQGateConditionsTest/schema.sql +++ /dev/null @@ -1,24 +0,0 @@ -CREATE TABLE "QUALITY_GATE_CONDITIONS"( - "QGATE_ID" INTEGER, - "QGATE_UUID" VARCHAR(40), - "METRIC_ID" INTEGER, - "PERIOD" INTEGER, - "OPERATOR" VARCHAR(3), - "VALUE_ERROR" VARCHAR(64), - "VALUE_WARNING" VARCHAR(64), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "QUALITY_GATE_CONDITIONS" ADD CONSTRAINT "PK_QUALITY_GATE_CONDITIONS" PRIMARY KEY("UUID"); - -CREATE TABLE "QUALITY_GATES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "IS_BUILT_IN" BOOLEAN NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "QUALITY_GATES" ADD CONSTRAINT "PK_QUALITY_GATES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_QUALITY_GATES_UUID" ON "QUALITY_GATES"("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/AddPrimaryKeyOnUuidColumnOfRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/AddPrimaryKeyOnUuidColumnOfRulesTableTest/schema.sql deleted file mode 100644 index df25471a0ba..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/AddPrimaryKeyOnUuidColumnOfRulesTableTest/schema.sql +++ /dev/null @@ -1,29 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/AddUuidAndTemplateUuidColumnsToRulesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/AddUuidAndTemplateUuidColumnsToRulesTest/schema.sql deleted file mode 100644 index 66e55fb1b3f..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/AddUuidAndTemplateUuidColumnsToRulesTest/schema.sql +++ /dev/null @@ -1,29 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "TEMPLATE_ID" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/DropIdColumnOfRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/DropIdColumnOfRulesTableTest/schema.sql deleted file mode 100644 index 4045c3e578a..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/DropIdColumnOfRulesTableTest/schema.sql +++ /dev/null @@ -1,30 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/DropPrimaryKeyOnIdColumnOfRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/DropPrimaryKeyOnIdColumnOfRulesTableTest/schema.sql deleted file mode 100644 index 04dc8de79c8..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/DropPrimaryKeyOnIdColumnOfRulesTableTest/schema.sql +++ /dev/null @@ -1,30 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/DropTemplateIdColumnOfRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/DropTemplateIdColumnOfRulesTableTest/schema.sql deleted file mode 100644 index ee19fb605ea..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/DropTemplateIdColumnOfRulesTableTest/schema.sql +++ /dev/null @@ -1,31 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "TEMPLATE_ID" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/MakeRulesUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/MakeRulesUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index e2d578ae008..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/MakeRulesUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,31 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "TEMPLATE_ID" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40), - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/PopulateRulesTemplateUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/PopulateRulesTemplateUuidTest/schema.sql deleted file mode 100644 index ee19fb605ea..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/PopulateRulesTemplateUuidTest/schema.sql +++ /dev/null @@ -1,31 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "TEMPLATE_ID" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/PopulateRulesUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/PopulateRulesUuidTest/schema.sql deleted file mode 100644 index e2d578ae008..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/PopulateRulesUuidTest/schema.sql +++ /dev/null @@ -1,31 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "TEMPLATE_ID" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40), - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/activerules/AddIndexToActiveRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/activerules/AddIndexToActiveRulesTableTest/schema.sql deleted file mode 100644 index b3b1b4d7c04..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/activerules/AddIndexToActiveRulesTableTest/schema.sql +++ /dev/null @@ -1,42 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "ACTIVE_RULES"( - "RULE_ID" INTEGER NOT NULL, - "FAILURE_LEVEL" INTEGER NOT NULL, - "INHERITANCE" VARCHAR(10), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "PROFILE_UUID" VARCHAR(40) NOT NULL, - "RULE_UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/activerules/AddRuleUuidColumnToActiveRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/activerules/AddRuleUuidColumnToActiveRulesTableTest/schema.sql deleted file mode 100644 index d05e47d8bc5..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/activerules/AddRuleUuidColumnToActiveRulesTableTest/schema.sql +++ /dev/null @@ -1,42 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "ACTIVE_RULES"( - "RULE_ID" INTEGER NOT NULL, - "FAILURE_LEVEL" INTEGER NOT NULL, - "INHERITANCE" VARCHAR(10), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "PROFILE_UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_UUID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/activerules/DropIndexOnRuleIdColumnOfActiveRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/activerules/DropIndexOnRuleIdColumnOfActiveRulesTableTest/schema.sql deleted file mode 100644 index 9156127c902..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/activerules/DropIndexOnRuleIdColumnOfActiveRulesTableTest/schema.sql +++ /dev/null @@ -1,43 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "ACTIVE_RULES"( - "RULE_ID" INTEGER NOT NULL, - "FAILURE_LEVEL" INTEGER NOT NULL, - "INHERITANCE" VARCHAR(10), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "PROFILE_UUID" VARCHAR(40) NOT NULL, - "RULE_UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_UUID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/activerules/DropRuleIdColumnOfActiveRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/activerules/DropRuleIdColumnOfActiveRulesTableTest/schema.sql deleted file mode 100644 index d786db82af6..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/activerules/DropRuleIdColumnOfActiveRulesTableTest/schema.sql +++ /dev/null @@ -1,43 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "ACTIVE_RULES"( - "RULE_ID" INTEGER NOT NULL, - "FAILURE_LEVEL" INTEGER NOT NULL, - "INHERITANCE" VARCHAR(10), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "PROFILE_UUID" VARCHAR(40) NOT NULL, - "RULE_UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_UUIDS" ON "ACTIVE_RULES"("PROFILE_UUID", "RULE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/activerules/MakeActiveRulesRuleUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/activerules/MakeActiveRulesRuleUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index ac68fc9c530..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/activerules/MakeActiveRulesRuleUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,43 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "ACTIVE_RULES"( - "RULE_ID" INTEGER NOT NULL, - "FAILURE_LEVEL" INTEGER NOT NULL, - "INHERITANCE" VARCHAR(10), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "PROFILE_UUID" VARCHAR(40) NOT NULL, - "RULE_UUID" VARCHAR(40) -); -ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_UUID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/activerules/PopulateActiveRulesRuleUuidColumnTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/activerules/PopulateActiveRulesRuleUuidColumnTest/schema.sql deleted file mode 100644 index ac68fc9c530..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/activerules/PopulateActiveRulesRuleUuidColumnTest/schema.sql +++ /dev/null @@ -1,43 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "ACTIVE_RULES"( - "RULE_ID" INTEGER NOT NULL, - "FAILURE_LEVEL" INTEGER NOT NULL, - "INHERITANCE" VARCHAR(10), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "PROFILE_UUID" VARCHAR(40) NOT NULL, - "RULE_UUID" VARCHAR(40) -); -ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_UUID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/AddIndexToDeprecatedRuleKeysTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/AddIndexToDeprecatedRuleKeysTableTest/schema.sql deleted file mode 100644 index 7d99e6c84e9..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/AddIndexToDeprecatedRuleKeysTableTest/schema.sql +++ /dev/null @@ -1,41 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "DEPRECATED_RULE_KEYS"( - "UUID" VARCHAR(40) NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "OLD_REPOSITORY_KEY" VARCHAR(255) NOT NULL, - "OLD_RULE_KEY" VARCHAR(200) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "RULE_UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "DEPRECATED_RULE_KEYS" ADD CONSTRAINT "PK_DEPRECATED_RULE_KEYS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_DEPRECATED_RULE_KEYS" ON "DEPRECATED_RULE_KEYS"("OLD_REPOSITORY_KEY", "OLD_RULE_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/AddRuleUuidColumnToDeprecatedRuleKeysTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/AddRuleUuidColumnToDeprecatedRuleKeysTableTest/schema.sql deleted file mode 100644 index 5f7d81c739c..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/AddRuleUuidColumnToDeprecatedRuleKeysTableTest/schema.sql +++ /dev/null @@ -1,41 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "DEPRECATED_RULE_KEYS"( - "UUID" VARCHAR(40) NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "OLD_REPOSITORY_KEY" VARCHAR(255) NOT NULL, - "OLD_RULE_KEY" VARCHAR(200) NOT NULL, - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "DEPRECATED_RULE_KEYS" ADD CONSTRAINT "PK_DEPRECATED_RULE_KEYS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_DEPRECATED_RULE_KEYS" ON "DEPRECATED_RULE_KEYS"("OLD_REPOSITORY_KEY", "OLD_RULE_KEY"); -CREATE INDEX "RULE_ID_DEPRECATED_RULE_KEYS" ON "DEPRECATED_RULE_KEYS"("RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTableTest/schema.sql deleted file mode 100644 index 9f9a6ff004a..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTableTest/schema.sql +++ /dev/null @@ -1,42 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "DEPRECATED_RULE_KEYS"( - "UUID" VARCHAR(40) NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "OLD_REPOSITORY_KEY" VARCHAR(255) NOT NULL, - "OLD_RULE_KEY" VARCHAR(200) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "RULE_UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "DEPRECATED_RULE_KEYS" ADD CONSTRAINT "PK_DEPRECATED_RULE_KEYS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_DEPRECATED_RULE_KEYS" ON "DEPRECATED_RULE_KEYS"("OLD_REPOSITORY_KEY", "OLD_RULE_KEY"); -CREATE INDEX "RULE_ID_DEPRECATED_RULE_KEYS" ON "DEPRECATED_RULE_KEYS"("RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/DropRuleIdColumnOfDeprecatedRuleKeysTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/DropRuleIdColumnOfDeprecatedRuleKeysTableTest/schema.sql deleted file mode 100644 index 557f113a0c2..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/DropRuleIdColumnOfDeprecatedRuleKeysTableTest/schema.sql +++ /dev/null @@ -1,42 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "DEPRECATED_RULE_KEYS"( - "UUID" VARCHAR(40) NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "OLD_REPOSITORY_KEY" VARCHAR(255) NOT NULL, - "OLD_RULE_KEY" VARCHAR(200) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "RULE_UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "DEPRECATED_RULE_KEYS" ADD CONSTRAINT "PK_DEPRECATED_RULE_KEYS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_DEPRECATED_RULE_KEYS" ON "DEPRECATED_RULE_KEYS"("OLD_REPOSITORY_KEY", "OLD_RULE_KEY"); -CREATE INDEX "RULE_UUID_DEPRECATED_RULE_KEYS" ON "DEPRECATED_RULE_KEYS"("RULE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/MakeDeprecatedRuleKeysRuleUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/MakeDeprecatedRuleKeysRuleUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index a33abf46805..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/MakeDeprecatedRuleKeysRuleUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,42 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "DEPRECATED_RULE_KEYS"( - "UUID" VARCHAR(40) NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "OLD_REPOSITORY_KEY" VARCHAR(255) NOT NULL, - "OLD_RULE_KEY" VARCHAR(200) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "RULE_UUID" VARCHAR(40) -); -ALTER TABLE "DEPRECATED_RULE_KEYS" ADD CONSTRAINT "PK_DEPRECATED_RULE_KEYS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_DEPRECATED_RULE_KEYS" ON "DEPRECATED_RULE_KEYS"("OLD_REPOSITORY_KEY", "OLD_RULE_KEY"); -CREATE INDEX "RULE_ID_DEPRECATED_RULE_KEYS" ON "DEPRECATED_RULE_KEYS"("RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/PopulateDeprecatedRuleKeysRuleUuidColumnTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/PopulateDeprecatedRuleKeysRuleUuidColumnTest/schema.sql deleted file mode 100644 index a33abf46805..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/deprecatedrulekeys/PopulateDeprecatedRuleKeysRuleUuidColumnTest/schema.sql +++ /dev/null @@ -1,42 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "DEPRECATED_RULE_KEYS"( - "UUID" VARCHAR(40) NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "OLD_REPOSITORY_KEY" VARCHAR(255) NOT NULL, - "OLD_RULE_KEY" VARCHAR(200) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "RULE_UUID" VARCHAR(40) -); -ALTER TABLE "DEPRECATED_RULE_KEYS" ADD CONSTRAINT "PK_DEPRECATED_RULE_KEYS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_DEPRECATED_RULE_KEYS" ON "DEPRECATED_RULE_KEYS"("OLD_REPOSITORY_KEY", "OLD_RULE_KEY"); -CREATE INDEX "RULE_ID_DEPRECATED_RULE_KEYS" ON "DEPRECATED_RULE_KEYS"("RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/issues/AddIndexToIssuesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/issues/AddIndexToIssuesTableTest/schema.sql deleted file mode 100644 index d02b9c74ec2..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/issues/AddIndexToIssuesTableTest/schema.sql +++ /dev/null @@ -1,69 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "ISSUES"( - "KEE" VARCHAR(50) NOT NULL, - "RULE_ID" INTEGER, - "SEVERITY" VARCHAR(10), - "MANUAL_SEVERITY" BOOLEAN NOT NULL, - "MESSAGE" VARCHAR(4000), - "LINE" INTEGER, - "GAP" DOUBLE, - "STATUS" VARCHAR(20), - "RESOLUTION" VARCHAR(20), - "CHECKSUM" VARCHAR(1000), - "REPORTER" VARCHAR(255), - "ASSIGNEE" VARCHAR(255), - "AUTHOR_LOGIN" VARCHAR(255), - "ACTION_PLAN_KEY" VARCHAR(50), - "ISSUE_ATTRIBUTES" VARCHAR(4000), - "EFFORT" INTEGER, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CREATION_DATE" BIGINT, - "ISSUE_UPDATE_DATE" BIGINT, - "ISSUE_CLOSE_DATE" BIGINT, - "TAGS" VARCHAR(4000), - "COMPONENT_UUID" VARCHAR(50), - "PROJECT_UUID" VARCHAR(50), - "LOCATIONS" BLOB, - "ISSUE_TYPE" TINYINT, - "FROM_HOTSPOT" BOOLEAN, - "RULE_UUID" VARCHAR(40) -); -ALTER TABLE "ISSUES" ADD CONSTRAINT "PK_ISSUES" PRIMARY KEY("KEE"); -CREATE INDEX "ISSUES_ASSIGNEE" ON "ISSUES"("ASSIGNEE"); -CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES"("COMPONENT_UUID"); -CREATE INDEX "ISSUES_CREATION_DATE" ON "ISSUES"("ISSUE_CREATION_DATE"); -CREATE UNIQUE INDEX "ISSUES_KEE" ON "ISSUES"("KEE"); -CREATE INDEX "ISSUES_PROJECT_UUID" ON "ISSUES"("PROJECT_UUID"); -CREATE INDEX "ISSUES_RESOLUTION" ON "ISSUES"("RESOLUTION"); -CREATE INDEX "ISSUES_UPDATED_AT" ON "ISSUES"("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/issues/AddRuleUuidColumnToIssuesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/issues/AddRuleUuidColumnToIssuesTableTest/schema.sql deleted file mode 100644 index 89488e5506f..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/issues/AddRuleUuidColumnToIssuesTableTest/schema.sql +++ /dev/null @@ -1,69 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "ISSUES"( - "KEE" VARCHAR(50) NOT NULL, - "RULE_ID" INTEGER, - "SEVERITY" VARCHAR(10), - "MANUAL_SEVERITY" BOOLEAN NOT NULL, - "MESSAGE" VARCHAR(4000), - "LINE" INTEGER, - "GAP" DOUBLE, - "STATUS" VARCHAR(20), - "RESOLUTION" VARCHAR(20), - "CHECKSUM" VARCHAR(1000), - "REPORTER" VARCHAR(255), - "ASSIGNEE" VARCHAR(255), - "AUTHOR_LOGIN" VARCHAR(255), - "ACTION_PLAN_KEY" VARCHAR(50), - "ISSUE_ATTRIBUTES" VARCHAR(4000), - "EFFORT" INTEGER, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CREATION_DATE" BIGINT, - "ISSUE_UPDATE_DATE" BIGINT, - "ISSUE_CLOSE_DATE" BIGINT, - "TAGS" VARCHAR(4000), - "COMPONENT_UUID" VARCHAR(50), - "PROJECT_UUID" VARCHAR(50), - "LOCATIONS" BLOB, - "ISSUE_TYPE" TINYINT, - "FROM_HOTSPOT" BOOLEAN -); -ALTER TABLE "ISSUES" ADD CONSTRAINT "PK_ISSUES" PRIMARY KEY("KEE"); -CREATE INDEX "ISSUES_ASSIGNEE" ON "ISSUES"("ASSIGNEE"); -CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES"("COMPONENT_UUID"); -CREATE INDEX "ISSUES_CREATION_DATE" ON "ISSUES"("ISSUE_CREATION_DATE"); -CREATE UNIQUE INDEX "ISSUES_KEE" ON "ISSUES"("KEE"); -CREATE INDEX "ISSUES_PROJECT_UUID" ON "ISSUES"("PROJECT_UUID"); -CREATE INDEX "ISSUES_RESOLUTION" ON "ISSUES"("RESOLUTION"); -CREATE INDEX "ISSUES_RULE_ID" ON "ISSUES"("RULE_ID"); -CREATE INDEX "ISSUES_UPDATED_AT" ON "ISSUES"("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/issues/DropIndexOnRuleIdColumnOfIssuesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/issues/DropIndexOnRuleIdColumnOfIssuesTableTest/schema.sql deleted file mode 100644 index d6c8f6b855e..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/issues/DropIndexOnRuleIdColumnOfIssuesTableTest/schema.sql +++ /dev/null @@ -1,70 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "ISSUES"( - "KEE" VARCHAR(50) NOT NULL, - "RULE_ID" INTEGER, - "SEVERITY" VARCHAR(10), - "MANUAL_SEVERITY" BOOLEAN NOT NULL, - "MESSAGE" VARCHAR(4000), - "LINE" INTEGER, - "GAP" DOUBLE, - "STATUS" VARCHAR(20), - "RESOLUTION" VARCHAR(20), - "CHECKSUM" VARCHAR(1000), - "REPORTER" VARCHAR(255), - "ASSIGNEE" VARCHAR(255), - "AUTHOR_LOGIN" VARCHAR(255), - "ACTION_PLAN_KEY" VARCHAR(50), - "ISSUE_ATTRIBUTES" VARCHAR(4000), - "EFFORT" INTEGER, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CREATION_DATE" BIGINT, - "ISSUE_UPDATE_DATE" BIGINT, - "ISSUE_CLOSE_DATE" BIGINT, - "TAGS" VARCHAR(4000), - "COMPONENT_UUID" VARCHAR(50), - "PROJECT_UUID" VARCHAR(50), - "LOCATIONS" BLOB, - "ISSUE_TYPE" TINYINT, - "FROM_HOTSPOT" BOOLEAN, - "RULE_UUID" VARCHAR(40) -); -ALTER TABLE "ISSUES" ADD CONSTRAINT "PK_ISSUES" PRIMARY KEY("KEE"); -CREATE INDEX "ISSUES_ASSIGNEE" ON "ISSUES"("ASSIGNEE"); -CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES"("COMPONENT_UUID"); -CREATE INDEX "ISSUES_CREATION_DATE" ON "ISSUES"("ISSUE_CREATION_DATE"); -CREATE UNIQUE INDEX "ISSUES_KEE" ON "ISSUES"("KEE"); -CREATE INDEX "ISSUES_PROJECT_UUID" ON "ISSUES"("PROJECT_UUID"); -CREATE INDEX "ISSUES_RESOLUTION" ON "ISSUES"("RESOLUTION"); -CREATE INDEX "ISSUES_RULE_ID" ON "ISSUES"("RULE_ID"); -CREATE INDEX "ISSUES_UPDATED_AT" ON "ISSUES"("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/issues/DropRuleIdColumnOfIssuesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/issues/DropRuleIdColumnOfIssuesTableTest/schema.sql deleted file mode 100644 index a2da6523742..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/issues/DropRuleIdColumnOfIssuesTableTest/schema.sql +++ /dev/null @@ -1,70 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "ISSUES"( - "KEE" VARCHAR(50) NOT NULL, - "RULE_ID" INTEGER, - "SEVERITY" VARCHAR(10), - "MANUAL_SEVERITY" BOOLEAN NOT NULL, - "MESSAGE" VARCHAR(4000), - "LINE" INTEGER, - "GAP" DOUBLE, - "STATUS" VARCHAR(20), - "RESOLUTION" VARCHAR(20), - "CHECKSUM" VARCHAR(1000), - "REPORTER" VARCHAR(255), - "ASSIGNEE" VARCHAR(255), - "AUTHOR_LOGIN" VARCHAR(255), - "ACTION_PLAN_KEY" VARCHAR(50), - "ISSUE_ATTRIBUTES" VARCHAR(4000), - "EFFORT" INTEGER, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CREATION_DATE" BIGINT, - "ISSUE_UPDATE_DATE" BIGINT, - "ISSUE_CLOSE_DATE" BIGINT, - "TAGS" VARCHAR(4000), - "COMPONENT_UUID" VARCHAR(50), - "PROJECT_UUID" VARCHAR(50), - "LOCATIONS" BLOB, - "ISSUE_TYPE" TINYINT, - "FROM_HOTSPOT" BOOLEAN, - "RULE_UUID" VARCHAR(40) -); -ALTER TABLE "ISSUES" ADD CONSTRAINT "PK_ISSUES" PRIMARY KEY("KEE"); -CREATE INDEX "ISSUES_ASSIGNEE" ON "ISSUES"("ASSIGNEE"); -CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES"("COMPONENT_UUID"); -CREATE INDEX "ISSUES_CREATION_DATE" ON "ISSUES"("ISSUE_CREATION_DATE"); -CREATE UNIQUE INDEX "ISSUES_KEE" ON "ISSUES"("KEE"); -CREATE INDEX "ISSUES_PROJECT_UUID" ON "ISSUES"("PROJECT_UUID"); -CREATE INDEX "ISSUES_RESOLUTION" ON "ISSUES"("RESOLUTION"); -CREATE INDEX "ISSUES_RULE_UUID" ON "ISSUES"("RULE_UUID"); -CREATE INDEX "ISSUES_UPDATED_AT" ON "ISSUES"("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/issues/PopulateIssuesRuleUuidColumnTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/issues/PopulateIssuesRuleUuidColumnTest/schema.sql deleted file mode 100644 index d6c8f6b855e..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/issues/PopulateIssuesRuleUuidColumnTest/schema.sql +++ /dev/null @@ -1,70 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "ISSUES"( - "KEE" VARCHAR(50) NOT NULL, - "RULE_ID" INTEGER, - "SEVERITY" VARCHAR(10), - "MANUAL_SEVERITY" BOOLEAN NOT NULL, - "MESSAGE" VARCHAR(4000), - "LINE" INTEGER, - "GAP" DOUBLE, - "STATUS" VARCHAR(20), - "RESOLUTION" VARCHAR(20), - "CHECKSUM" VARCHAR(1000), - "REPORTER" VARCHAR(255), - "ASSIGNEE" VARCHAR(255), - "AUTHOR_LOGIN" VARCHAR(255), - "ACTION_PLAN_KEY" VARCHAR(50), - "ISSUE_ATTRIBUTES" VARCHAR(4000), - "EFFORT" INTEGER, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "ISSUE_CREATION_DATE" BIGINT, - "ISSUE_UPDATE_DATE" BIGINT, - "ISSUE_CLOSE_DATE" BIGINT, - "TAGS" VARCHAR(4000), - "COMPONENT_UUID" VARCHAR(50), - "PROJECT_UUID" VARCHAR(50), - "LOCATIONS" BLOB, - "ISSUE_TYPE" TINYINT, - "FROM_HOTSPOT" BOOLEAN, - "RULE_UUID" VARCHAR(40) -); -ALTER TABLE "ISSUES" ADD CONSTRAINT "PK_ISSUES" PRIMARY KEY("KEE"); -CREATE INDEX "ISSUES_ASSIGNEE" ON "ISSUES"("ASSIGNEE"); -CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES"("COMPONENT_UUID"); -CREATE INDEX "ISSUES_CREATION_DATE" ON "ISSUES"("ISSUE_CREATION_DATE"); -CREATE UNIQUE INDEX "ISSUES_KEE" ON "ISSUES"("KEE"); -CREATE INDEX "ISSUES_PROJECT_UUID" ON "ISSUES"("PROJECT_UUID"); -CREATE INDEX "ISSUES_RESOLUTION" ON "ISSUES"("RESOLUTION"); -CREATE INDEX "ISSUES_RULE_ID" ON "ISSUES"("RULE_ID"); -CREATE INDEX "ISSUES_UPDATED_AT" ON "ISSUES"("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTableTest/schema.sql deleted file mode 100644 index 7e46834a915..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTableTest/schema.sql +++ /dev/null @@ -1,50 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "RULES_METADATA"( - "RULE_ID" INTEGER NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NOTE_DATA" CLOB(2147483647), - "NOTE_USER_UUID" VARCHAR(255), - "NOTE_CREATED_AT" BIGINT, - "NOTE_UPDATED_AT" BIGINT, - "REMEDIATION_FUNCTION" VARCHAR(20), - "REMEDIATION_GAP_MULT" VARCHAR(20), - "REMEDIATION_BASE_EFFORT" VARCHAR(20), - "TAGS" VARCHAR(4000), - "AD_HOC_NAME" VARCHAR(200), - "AD_HOC_DESCRIPTION" CLOB(2147483647), - "AD_HOC_SEVERITY" VARCHAR(10), - "AD_HOC_TYPE" TINYINT, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "RULE_UUID" VARCHAR(40) NOT NULL -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/AddRuleUuidColumnToRulesMetadataTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/AddRuleUuidColumnToRulesMetadataTableTest/schema.sql deleted file mode 100644 index 6dd1263edd1..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/AddRuleUuidColumnToRulesMetadataTableTest/schema.sql +++ /dev/null @@ -1,50 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "RULES_METADATA"( - "RULE_ID" INTEGER NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NOTE_DATA" CLOB(2147483647), - "NOTE_USER_UUID" VARCHAR(255), - "NOTE_CREATED_AT" BIGINT, - "NOTE_UPDATED_AT" BIGINT, - "REMEDIATION_FUNCTION" VARCHAR(20), - "REMEDIATION_GAP_MULT" VARCHAR(20), - "REMEDIATION_BASE_EFFORT" VARCHAR(20), - "TAGS" VARCHAR(4000), - "AD_HOC_NAME" VARCHAR(200), - "AD_HOC_DESCRIPTION" CLOB(2147483647), - "AD_HOC_SEVERITY" VARCHAR(10), - "AD_HOC_TYPE" TINYINT, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "RULES_METADATA" ADD CONSTRAINT "PK_RULES_METADATA" PRIMARY KEY("RULE_ID", "ORGANIZATION_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/DropPrimaryKeyOnIdColumnOfRulesMetadataTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/DropPrimaryKeyOnIdColumnOfRulesMetadataTableTest/schema.sql deleted file mode 100644 index 9f014613799..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/DropPrimaryKeyOnIdColumnOfRulesMetadataTableTest/schema.sql +++ /dev/null @@ -1,51 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "RULES_METADATA"( - "RULE_ID" INTEGER NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NOTE_DATA" CLOB(2147483647), - "NOTE_USER_UUID" VARCHAR(255), - "NOTE_CREATED_AT" BIGINT, - "NOTE_UPDATED_AT" BIGINT, - "REMEDIATION_FUNCTION" VARCHAR(20), - "REMEDIATION_GAP_MULT" VARCHAR(20), - "REMEDIATION_BASE_EFFORT" VARCHAR(20), - "TAGS" VARCHAR(4000), - "AD_HOC_NAME" VARCHAR(200), - "AD_HOC_DESCRIPTION" CLOB(2147483647), - "AD_HOC_SEVERITY" VARCHAR(10), - "AD_HOC_TYPE" TINYINT, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "RULE_UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "RULES_METADATA" ADD CONSTRAINT "PK_RULES_METADATA" PRIMARY KEY("RULE_ID", "ORGANIZATION_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/DropRuleIdColumnOfRulesMetadataTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/DropRuleIdColumnOfRulesMetadataTableTest/schema.sql deleted file mode 100644 index d7862acb77c..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/DropRuleIdColumnOfRulesMetadataTableTest/schema.sql +++ /dev/null @@ -1,51 +0,0 @@ -create TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -alter table "RULES" add CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -create UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "RULES_METADATA"( - "RULE_ID" INTEGER NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NOTE_DATA" CLOB(2147483647), - "NOTE_USER_UUID" VARCHAR(255), - "NOTE_CREATED_AT" BIGINT, - "NOTE_UPDATED_AT" BIGINT, - "REMEDIATION_FUNCTION" VARCHAR(20), - "REMEDIATION_GAP_MULT" VARCHAR(20), - "REMEDIATION_BASE_EFFORT" VARCHAR(20), - "TAGS" VARCHAR(4000), - "AD_HOC_NAME" VARCHAR(200), - "AD_HOC_DESCRIPTION" CLOB(2147483647), - "AD_HOC_SEVERITY" VARCHAR(10), - "AD_HOC_TYPE" TINYINT, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "RULE_UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "RULES_METADATA" ADD CONSTRAINT "PK_RULES_METADATA" PRIMARY KEY("RULE_UUID", "ORGANIZATION_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/MakeRulesMetadataRuleUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/MakeRulesMetadataRuleUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index 9e725d8243b..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/MakeRulesMetadataRuleUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,51 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "RULES_METADATA"( - "RULE_ID" INTEGER NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NOTE_DATA" CLOB(2147483647), - "NOTE_USER_UUID" VARCHAR(255), - "NOTE_CREATED_AT" BIGINT, - "NOTE_UPDATED_AT" BIGINT, - "REMEDIATION_FUNCTION" VARCHAR(20), - "REMEDIATION_GAP_MULT" VARCHAR(20), - "REMEDIATION_BASE_EFFORT" VARCHAR(20), - "TAGS" VARCHAR(4000), - "AD_HOC_NAME" VARCHAR(200), - "AD_HOC_DESCRIPTION" CLOB(2147483647), - "AD_HOC_SEVERITY" VARCHAR(10), - "AD_HOC_TYPE" TINYINT, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "RULE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES_METADATA" ADD CONSTRAINT "PK_RULES_METADATA" PRIMARY KEY("RULE_ID", "ORGANIZATION_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/PopulateRulesMetadataRuleUuidColumnTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/PopulateRulesMetadataRuleUuidColumnTest/schema.sql deleted file mode 100644 index 9e725d8243b..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesmetadata/PopulateRulesMetadataRuleUuidColumnTest/schema.sql +++ /dev/null @@ -1,51 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "RULES_METADATA"( - "RULE_ID" INTEGER NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "NOTE_DATA" CLOB(2147483647), - "NOTE_USER_UUID" VARCHAR(255), - "NOTE_CREATED_AT" BIGINT, - "NOTE_UPDATED_AT" BIGINT, - "REMEDIATION_FUNCTION" VARCHAR(20), - "REMEDIATION_GAP_MULT" VARCHAR(20), - "REMEDIATION_BASE_EFFORT" VARCHAR(20), - "TAGS" VARCHAR(4000), - "AD_HOC_NAME" VARCHAR(200), - "AD_HOC_DESCRIPTION" CLOB(2147483647), - "AD_HOC_SEVERITY" VARCHAR(10), - "AD_HOC_TYPE" TINYINT, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL, - "RULE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES_METADATA" ADD CONSTRAINT "PK_RULES_METADATA" PRIMARY KEY("RULE_ID", "ORGANIZATION_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/AddIndexesToRulesParametersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/AddIndexesToRulesParametersTableTest/schema.sql deleted file mode 100644 index 13198189e57..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/AddIndexesToRulesParametersTableTest/schema.sql +++ /dev/null @@ -1,41 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "RULES_PARAMETERS"( - "UUID" VARCHAR(40) NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "NAME" VARCHAR(128) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "PARAM_TYPE" VARCHAR(512) NOT NULL, - "DEFAULT_VALUE" VARCHAR(4000), - "RULE_UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "RULES_PARAMETERS" ADD CONSTRAINT "PK_RULES_PARAMETERS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/AddRuleUuidColumnToRulesParametersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/AddRuleUuidColumnToRulesParametersTableTest/schema.sql deleted file mode 100644 index 88e9e77a4e3..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/AddRuleUuidColumnToRulesParametersTableTest/schema.sql +++ /dev/null @@ -1,42 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "RULES_PARAMETERS"( - "UUID" VARCHAR(40) NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "NAME" VARCHAR(128) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "PARAM_TYPE" VARCHAR(512) NOT NULL, - "DEFAULT_VALUE" VARCHAR(4000) -); -ALTER TABLE "RULES_PARAMETERS" ADD CONSTRAINT "PK_RULES_PARAMETERS" PRIMARY KEY("UUID"); -CREATE INDEX "RULES_PARAMETERS_RULE_ID" ON "RULES_PARAMETERS"("RULE_ID"); -CREATE UNIQUE INDEX "RULES_PARAMETERS_UNIQUE" ON "RULES_PARAMETERS"("RULE_ID", "NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/DropIndexesOnRuleIdColumnOfRulesParametersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/DropIndexesOnRuleIdColumnOfRulesParametersTableTest/schema.sql deleted file mode 100644 index 81bbe5119c2..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/DropIndexesOnRuleIdColumnOfRulesParametersTableTest/schema.sql +++ /dev/null @@ -1,43 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "RULES_PARAMETERS"( - "UUID" VARCHAR(40) NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "NAME" VARCHAR(128) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "PARAM_TYPE" VARCHAR(512) NOT NULL, - "DEFAULT_VALUE" VARCHAR(4000), - "RULE_UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "RULES_PARAMETERS" ADD CONSTRAINT "PK_RULES_PARAMETERS" PRIMARY KEY("UUID"); -CREATE INDEX "RULES_PARAMETERS_RULE_ID" ON "RULES_PARAMETERS"("RULE_ID"); -CREATE UNIQUE INDEX "RULES_PARAMETERS_UNIQUE" ON "RULES_PARAMETERS"("RULE_ID", "NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/DropRuleIdColumnOfRulesParametersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/DropRuleIdColumnOfRulesParametersTableTest/schema.sql deleted file mode 100644 index eafb90192e1..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/DropRuleIdColumnOfRulesParametersTableTest/schema.sql +++ /dev/null @@ -1,43 +0,0 @@ -create TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -alter table "RULES" add CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -create UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -create TABLE "RULES_PARAMETERS"( - "UUID" VARCHAR(40) NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "NAME" VARCHAR(128) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "PARAM_TYPE" VARCHAR(512) NOT NULL, - "DEFAULT_VALUE" VARCHAR(4000), - "RULE_UUID" VARCHAR(40) NOT NULL -); -alter table "RULES_PARAMETERS" add CONSTRAINT "PK_RULES_PARAMETERS" PRIMARY KEY("UUID"); -create INDEX "RULES_PARAMETERS_RULE_UUID" ON "RULES_PARAMETERS"("RULE_UUID"); -create UNIQUE INDEX "RULES_PARAMETERS_UNIQUE" ON "RULES_PARAMETERS"("RULE_UUID", "NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/MakeRulesParametersRuleUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/MakeRulesParametersRuleUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index 9fdc54dfb08..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/MakeRulesParametersRuleUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,43 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "RULES_PARAMETERS"( - "UUID" VARCHAR(40) NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "NAME" VARCHAR(128) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "PARAM_TYPE" VARCHAR(512) NOT NULL, - "DEFAULT_VALUE" VARCHAR(4000), - "RULE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES_PARAMETERS" ADD CONSTRAINT "PK_RULES_PARAMETERS" PRIMARY KEY("UUID"); -CREATE INDEX "RULES_PARAMETERS_RULE_ID" ON "RULES_PARAMETERS"("RULE_ID"); -CREATE UNIQUE INDEX "RULES_PARAMETERS_UNIQUE" ON "RULES_PARAMETERS"("RULE_ID", "NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/PopulateRulesParametersRuleUuidColumnTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/PopulateRulesParametersRuleUuidColumnTest/schema.sql deleted file mode 100644 index 9fdc54dfb08..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rules/rulesparameters/PopulateRulesParametersRuleUuidColumnTest/schema.sql +++ /dev/null @@ -1,43 +0,0 @@ -CREATE TABLE "RULES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(200), - "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, - "PLUGIN_KEY" VARCHAR(200), - "PLUGIN_CONFIG_KEY" VARCHAR(200), - "PLUGIN_NAME" VARCHAR(255) NOT NULL, - "SCOPE" VARCHAR(20) NOT NULL, - "DESCRIPTION" CLOB(2147483647), - "PRIORITY" INTEGER, - "STATUS" VARCHAR(40), - "LANGUAGE" VARCHAR(20), - "DEF_REMEDIATION_FUNCTION" VARCHAR(20), - "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), - "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), - "GAP_DESCRIPTION" VARCHAR(4000), - "SYSTEM_TAGS" VARCHAR(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" VARCHAR(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" VARCHAR(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "UUID" VARCHAR(40) NOT NULL, - "TEMPLATE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); - -CREATE TABLE "RULES_PARAMETERS"( - "UUID" VARCHAR(40) NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "NAME" VARCHAR(128) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "PARAM_TYPE" VARCHAR(512) NOT NULL, - "DEFAULT_VALUE" VARCHAR(4000), - "RULE_UUID" VARCHAR(40) -); -ALTER TABLE "RULES_PARAMETERS" ADD CONSTRAINT "PK_RULES_PARAMETERS" PRIMARY KEY("UUID"); -CREATE INDEX "RULES_PARAMETERS_RULE_ID" ON "RULES_PARAMETERS"("RULE_ID"); -CREATE UNIQUE INDEX "RULES_PARAMETERS_UNIQUE" ON "RULES_PARAMETERS"("RULE_ID", "NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesparameters/AddPrimaryKeyOnUuidColumnOfRulesParametersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesparameters/AddPrimaryKeyOnUuidColumnOfRulesParametersTableTest/schema.sql deleted file mode 100644 index 961a5cb8cac..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesparameters/AddPrimaryKeyOnUuidColumnOfRulesParametersTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "RULES_PARAMETERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "NAME" VARCHAR(128) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "PARAM_TYPE" VARCHAR(512) NOT NULL, - "DEFAULT_VALUE" VARCHAR(4000) -); -CREATE INDEX "RULES_PARAMETERS_RULE_ID" ON "RULES_PARAMETERS"("RULE_ID"); -CREATE UNIQUE INDEX "RULES_PARAMETERS_UNIQUE" ON "RULES_PARAMETERS"("RULE_ID", "NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesparameters/AddUuidColumnToRulesParametersTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesparameters/AddUuidColumnToRulesParametersTest/schema.sql deleted file mode 100644 index 98a62c638d9..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesparameters/AddUuidColumnToRulesParametersTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "RULES_PARAMETERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "RULE_ID" INTEGER NOT NULL, - "NAME" VARCHAR(128) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "PARAM_TYPE" VARCHAR(512) NOT NULL, - "DEFAULT_VALUE" VARCHAR(4000) -); -ALTER TABLE "RULES_PARAMETERS" ADD CONSTRAINT "PK_RULES_PARAMETERS" PRIMARY KEY("ID"); -CREATE INDEX "RULES_PARAMETERS_RULE_ID" ON "RULES_PARAMETERS"("RULE_ID"); -CREATE UNIQUE INDEX "RULES_PARAMETERS_UNIQUE" ON "RULES_PARAMETERS"("RULE_ID", "NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesparameters/DropIdColumnOfRulesParametersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesparameters/DropIdColumnOfRulesParametersTableTest/schema.sql deleted file mode 100644 index 60597fff321..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesparameters/DropIdColumnOfRulesParametersTableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "RULES_PARAMETERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "NAME" VARCHAR(128) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "PARAM_TYPE" VARCHAR(512) NOT NULL, - "DEFAULT_VALUE" VARCHAR(4000) -); -ALTER TABLE "RULES_PARAMETERS" ADD CONSTRAINT "PK_RULES_PARAMETERS" PRIMARY KEY("UUID"); -CREATE INDEX "RULES_PARAMETERS_RULE_ID" ON "RULES_PARAMETERS"("RULE_ID"); -CREATE UNIQUE INDEX "RULES_PARAMETERS_UNIQUE" ON "RULES_PARAMETERS"("RULE_ID", "NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesparameters/DropPrimaryKeyOnIdColumnOfRulesParametersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesparameters/DropPrimaryKeyOnIdColumnOfRulesParametersTableTest/schema.sql deleted file mode 100644 index efdec30874f..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesparameters/DropPrimaryKeyOnIdColumnOfRulesParametersTableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "RULES_PARAMETERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "NAME" VARCHAR(128) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "PARAM_TYPE" VARCHAR(512) NOT NULL, - "DEFAULT_VALUE" VARCHAR(4000) -); -ALTER TABLE "RULES_PARAMETERS" ADD CONSTRAINT "PK_RULES_PARAMETERS" PRIMARY KEY("ID"); -CREATE INDEX "RULES_PARAMETERS_RULE_ID" ON "RULES_PARAMETERS"("RULE_ID"); -CREATE UNIQUE INDEX "RULES_PARAMETERS_UNIQUE" ON "RULES_PARAMETERS"("RULE_ID", "NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesparameters/MakeRulesParametersUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesparameters/MakeRulesParametersUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index 55efee58993..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesparameters/MakeRulesParametersUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "RULES_PARAMETERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "RULE_ID" INTEGER NOT NULL, - "NAME" VARCHAR(128) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "PARAM_TYPE" VARCHAR(512) NOT NULL, - "DEFAULT_VALUE" VARCHAR(4000) -); -ALTER TABLE "RULES_PARAMETERS" ADD CONSTRAINT "PK_RULES_PARAMETERS" PRIMARY KEY("ID"); -CREATE INDEX "RULES_PARAMETERS_RULE_ID" ON "RULES_PARAMETERS"("RULE_ID"); -CREATE UNIQUE INDEX "RULES_PARAMETERS_UNIQUE" ON "RULES_PARAMETERS"("RULE_ID", "NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesparameters/PopulateRulesParametersUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesparameters/PopulateRulesParametersUuidTest/schema.sql deleted file mode 100644 index 55efee58993..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesparameters/PopulateRulesParametersUuidTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "RULES_PARAMETERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "RULE_ID" INTEGER NOT NULL, - "NAME" VARCHAR(128) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "PARAM_TYPE" VARCHAR(512) NOT NULL, - "DEFAULT_VALUE" VARCHAR(4000) -); -ALTER TABLE "RULES_PARAMETERS" ADD CONSTRAINT "PK_RULES_PARAMETERS" PRIMARY KEY("ID"); -CREATE INDEX "RULES_PARAMETERS_RULE_ID" ON "RULES_PARAMETERS"("RULE_ID"); -CREATE UNIQUE INDEX "RULES_PARAMETERS_UNIQUE" ON "RULES_PARAMETERS"("RULE_ID", "NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/AddRulesParameterUuidColumnToActiveRuleParametersTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/AddRulesParameterUuidColumnToActiveRuleParametersTest/schema.sql deleted file mode 100644 index 04d58e9edf0..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/AddRulesParameterUuidColumnToActiveRuleParametersTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "ACTIVE_RULE_PARAMETERS"( - "ACTIVE_RULE_ID" INTEGER NOT NULL, - "RULES_PARAMETER_ID" INTEGER NOT NULL, - "VALUE" VARCHAR(4000), - "RULES_PARAMETER_KEY" VARCHAR(128), - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("UUID"); -CREATE INDEX "IX_ARP_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/DropRulesParameterIdColumnOfActiveRuleParametersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/DropRulesParameterIdColumnOfActiveRuleParametersTableTest/schema.sql deleted file mode 100644 index 3782982a167..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/DropRulesParameterIdColumnOfActiveRuleParametersTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "ACTIVE_RULE_PARAMETERS"( - "ACTIVE_RULE_ID" INTEGER NOT NULL, - "RULES_PARAMETER_ID" INTEGER NOT NULL, - "RULES_PARAMETER_UUID" VARCHAR(40) NOT NULL, - "VALUE" VARCHAR(4000), - "RULES_PARAMETER_KEY" VARCHAR(128), - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("UUID"); -CREATE INDEX "IX_ARP_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/MakeActiveRuleParametersRulesParameterUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/MakeActiveRuleParametersRulesParameterUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index de06e416db2..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/MakeActiveRuleParametersRulesParameterUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "ACTIVE_RULE_PARAMETERS"( - "ACTIVE_RULE_ID" INTEGER NOT NULL, - "RULES_PARAMETER_ID" INTEGER NOT NULL, - "RULES_PARAMETER_UUID" VARCHAR(40), - "VALUE" VARCHAR(4000), - "RULES_PARAMETER_KEY" VARCHAR(128), - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("UUID"); -CREATE INDEX "IX_ARP_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/PopulateActiveRuleParametersRulesParameterUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/PopulateActiveRuleParametersRulesParameterUuidTest/schema.sql deleted file mode 100644 index 0bb696c346c..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesparameters/fk/PopulateActiveRuleParametersRulesParameterUuidTest/schema.sql +++ /dev/null @@ -1,23 +0,0 @@ -CREATE TABLE "RULES_PARAMETERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "NAME" VARCHAR(128) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "PARAM_TYPE" VARCHAR(512) NOT NULL, - "DEFAULT_VALUE" VARCHAR(4000) -); -ALTER TABLE "RULES_PARAMETERS" ADD CONSTRAINT "PK_RULES_PARAMETERS" PRIMARY KEY("ID"); -CREATE INDEX "RULES_PARAMETERS_RULE_ID" ON "RULES_PARAMETERS"("RULE_ID"); -CREATE UNIQUE INDEX "RULES_PARAMETERS_UNIQUE" ON "RULES_PARAMETERS"("RULE_ID", "NAME"); - -CREATE TABLE "ACTIVE_RULE_PARAMETERS"( - "ACTIVE_RULE_ID" INTEGER NOT NULL, - "RULES_PARAMETER_ID" INTEGER NOT NULL, - "RULES_PARAMETER_UUID" VARCHAR(40), - "VALUE" VARCHAR(4000), - "RULES_PARAMETER_KEY" VARCHAR(128), - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("UUID"); -CREATE INDEX "IX_ARP_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/AddPrimaryKeyOnUuidColumnOfRulesProfilesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/AddPrimaryKeyOnUuidColumnOfRulesProfilesTableTest/schema.sql deleted file mode 100644 index 8f7a7f216ae..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/AddPrimaryKeyOnUuidColumnOfRulesProfilesTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "RULES_PROFILES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "IS_BUILT_IN" BOOLEAN NOT NULL, - "RULES_UPDATED_AT" VARCHAR(100), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/AddUuidColumnToRulesProfilesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/AddUuidColumnToRulesProfilesTableTest/schema.sql deleted file mode 100644 index de92d69aeb0..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/AddUuidColumnToRulesProfilesTableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "RULES_PROFILES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "KEE" VARCHAR(255) NOT NULL, - "IS_BUILT_IN" BOOLEAN NOT NULL, - "RULES_UPDATED_AT" VARCHAR(100), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "RULES_PROFILES" ADD CONSTRAINT "PK_RULES_PROFILES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_QPROF_KEY" ON "RULES_PROFILES"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropIdColumnOfRulesProfilesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropIdColumnOfRulesProfilesTableTest/schema.sql deleted file mode 100644 index 0236b7e6554..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropIdColumnOfRulesProfilesTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "RULES_PROFILES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "IS_BUILT_IN" BOOLEAN NOT NULL, - "RULES_UPDATED_AT" VARCHAR(100), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "RULES_PROFILES" ADD CONSTRAINT "PK_RULES_PROFILES" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropKeeColumnOfRulesProfilesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropKeeColumnOfRulesProfilesTableTest/schema.sql deleted file mode 100644 index eeb2ebcbd94..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropKeeColumnOfRulesProfilesTableTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "RULES_PROFILES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "KEE" VARCHAR(255) NOT NULL, - "IS_BUILT_IN" BOOLEAN NOT NULL, - "RULES_UPDATED_AT" VARCHAR(100), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "RULES_PROFILES" ADD CONSTRAINT "PK_RULES_PROFILES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_QPROF_KEY" ON "RULES_PROFILES"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropPrimaryKeyOnIdColumnOfRulesProfilesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropPrimaryKeyOnIdColumnOfRulesProfilesTableTest/schema.sql deleted file mode 100644 index 20448a4d9fe..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropPrimaryKeyOnIdColumnOfRulesProfilesTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "RULES_PROFILES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "IS_BUILT_IN" BOOLEAN NOT NULL, - "RULES_UPDATED_AT" VARCHAR(100), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "RULES_PROFILES" ADD CONSTRAINT "PK_RULES_PROFILES" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropUniqueIndexOnKeeColumnOfRulesProfilesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropUniqueIndexOnKeeColumnOfRulesProfilesTableTest/schema.sql deleted file mode 100644 index eeb2ebcbd94..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/DropUniqueIndexOnKeeColumnOfRulesProfilesTableTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "RULES_PROFILES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "KEE" VARCHAR(255) NOT NULL, - "IS_BUILT_IN" BOOLEAN NOT NULL, - "RULES_UPDATED_AT" VARCHAR(100), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "RULES_PROFILES" ADD CONSTRAINT "PK_RULES_PROFILES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_QPROF_KEY" ON "RULES_PROFILES"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/MakeRulesProfilesUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/MakeRulesProfilesUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index fd1ad1ea6a2..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/MakeRulesProfilesUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "RULES_PROFILES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "KEE" VARCHAR(255) NOT NULL, - "IS_BUILT_IN" BOOLEAN NOT NULL, - "RULES_UPDATED_AT" VARCHAR(100), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "RULES_PROFILES" ADD CONSTRAINT "PK_RULES_PROFILES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_QPROF_KEY" ON "RULES_PROFILES"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/PopulateRulesProfilesUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/PopulateRulesProfilesUuidTest/schema.sql deleted file mode 100644 index fd1ad1ea6a2..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/PopulateRulesProfilesUuidTest/schema.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "RULES_PROFILES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "KEE" VARCHAR(255) NOT NULL, - "IS_BUILT_IN" BOOLEAN NOT NULL, - "RULES_UPDATED_AT" VARCHAR(100), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "RULES_PROFILES" ADD CONSTRAINT "PK_RULES_PROFILES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_QPROF_KEY" ON "RULES_PROFILES"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/AddProfileUuidColumnToActiveRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/AddProfileUuidColumnToActiveRulesTableTest/schema.sql deleted file mode 100644 index d2e7c11c080..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/AddProfileUuidColumnToActiveRulesTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "ACTIVE_RULES"( - "UUID" VARCHAR(40) NOT NULL, - "PROFILE_ID" INTEGER NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "FAILURE_LEVEL" INTEGER NOT NULL, - "INHERITANCE" VARCHAR(10), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_ID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/AddUniqueIndexOnProfileUuidColumnOfActiveRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/AddUniqueIndexOnProfileUuidColumnOfActiveRulesTableTest/schema.sql deleted file mode 100644 index 2dedcc6b5e2..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/AddUniqueIndexOnProfileUuidColumnOfActiveRulesTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "ACTIVE_RULES"( - "UUID" VARCHAR(40) NOT NULL, - "PROFILE_ID" INTEGER NOT NULL, - "PROFILE_UUID" VARCHAR(40), - "RULE_ID" INTEGER NOT NULL, - "FAILURE_LEVEL" INTEGER NOT NULL, - "INHERITANCE" VARCHAR(10), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/DropProfileIdColumnOfActiveRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/DropProfileIdColumnOfActiveRulesTableTest/schema.sql deleted file mode 100644 index 2adacc4076d..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/DropProfileIdColumnOfActiveRulesTableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "ACTIVE_RULES"( - "UUID" VARCHAR(40) NOT NULL, - "PROFILE_ID" INTEGER NOT NULL, - "PROFILE_UUID" VARCHAR(40) NOT NULL, - "RULE_ID" INTEGER NOT NULL, - "FAILURE_LEVEL" INTEGER NOT NULL, - "INHERITANCE" VARCHAR(10), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_UUID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/DropUniqueIndexOnProfileIdColumnOfActiveRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/DropUniqueIndexOnProfileIdColumnOfActiveRulesTableTest/schema.sql deleted file mode 100644 index d7d0db7aa73..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/DropUniqueIndexOnProfileIdColumnOfActiveRulesTableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "ACTIVE_RULES"( - "UUID" VARCHAR(40) NOT NULL, - "PROFILE_ID" INTEGER NOT NULL, - "PROFILE_UUID" VARCHAR(40), - "RULE_ID" INTEGER NOT NULL, - "FAILURE_LEVEL" INTEGER NOT NULL, - "INHERITANCE" VARCHAR(10), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_ID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/MakeActiveRulesProfileUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/MakeActiveRulesProfileUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index 161696a041f..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/MakeActiveRulesProfileUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,26 +0,0 @@ -CREATE TABLE "RULES_PROFILES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "KEE" VARCHAR(255) NOT NULL, - "IS_BUILT_IN" BOOLEAN NOT NULL, - "RULES_UPDATED_AT" VARCHAR(100), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "RULES_PROFILES" ADD CONSTRAINT "PK_RULES_PROFILES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_QPROF_KEY" ON "RULES_PROFILES"("KEE"); - -CREATE TABLE "ACTIVE_RULES"( - "UUID" VARCHAR(40) NOT NULL, - "PROFILE_ID" INTEGER NOT NULL, - "PROFILE_UUID" VARCHAR(40), - "RULE_ID" INTEGER NOT NULL, - "FAILURE_LEVEL" INTEGER NOT NULL, - "INHERITANCE" VARCHAR(10), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_ID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/PopulateActiveRulesProfileUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/PopulateActiveRulesProfileUuidTest/schema.sql deleted file mode 100644 index 161696a041f..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/activerules/PopulateActiveRulesProfileUuidTest/schema.sql +++ /dev/null @@ -1,26 +0,0 @@ -CREATE TABLE "RULES_PROFILES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "KEE" VARCHAR(255) NOT NULL, - "IS_BUILT_IN" BOOLEAN NOT NULL, - "RULES_UPDATED_AT" VARCHAR(100), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "RULES_PROFILES" ADD CONSTRAINT "PK_RULES_PROFILES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_QPROF_KEY" ON "RULES_PROFILES"("KEE"); - -CREATE TABLE "ACTIVE_RULES"( - "UUID" VARCHAR(40) NOT NULL, - "PROFILE_ID" INTEGER NOT NULL, - "PROFILE_UUID" VARCHAR(40), - "RULE_ID" INTEGER NOT NULL, - "FAILURE_LEVEL" INTEGER NOT NULL, - "INHERITANCE" VARCHAR(10), - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_ID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/orgqprofiles/PopulateOrgQProfilesRulesProfileUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/orgqprofiles/PopulateOrgQProfilesRulesProfileUuidTest/schema.sql deleted file mode 100644 index a1781cb90cc..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/orgqprofiles/PopulateOrgQProfilesRulesProfileUuidTest/schema.sql +++ /dev/null @@ -1,28 +0,0 @@ -CREATE TABLE "RULES_PROFILES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "KEE" VARCHAR(255) NOT NULL, - "IS_BUILT_IN" BOOLEAN NOT NULL, - "RULES_UPDATED_AT" VARCHAR(100), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "RULES_PROFILES" ADD CONSTRAINT "PK_RULES_PROFILES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_QPROF_KEY" ON "RULES_PROFILES"("KEE"); - -CREATE TABLE "ORG_QPROFILES"( - "UUID" VARCHAR(255) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "RULES_PROFILE_UUID" VARCHAR(255) NOT NULL, - "PARENT_UUID" VARCHAR(255), - "LAST_USED" BIGINT, - "USER_UPDATED_AT" BIGINT, - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -ALTER TABLE "ORG_QPROFILES" ADD CONSTRAINT "PK_ORG_QPROFILES" PRIMARY KEY("UUID"); -CREATE INDEX "QPROFILES_ORG_UUID" ON "ORG_QPROFILES"("ORGANIZATION_UUID"); -CREATE INDEX "QPROFILES_RP_UUID" ON "ORG_QPROFILES"("RULES_PROFILE_UUID"); -CREATE INDEX "ORG_QPROFILES_PARENT_UUID" ON "ORG_QPROFILES"("PARENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/qprofilechanges/PopulateQProfileChangesRulesProfileUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/qprofilechanges/PopulateQProfileChangesRulesProfileUuidTest/schema.sql deleted file mode 100644 index 75148b62b24..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/rulesprofiles/fk/qprofilechanges/PopulateQProfileChangesRulesProfileUuidTest/schema.sql +++ /dev/null @@ -1,24 +0,0 @@ -CREATE TABLE "RULES_PROFILES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "LANGUAGE" VARCHAR(20), - "KEE" VARCHAR(255) NOT NULL, - "IS_BUILT_IN" BOOLEAN NOT NULL, - "RULES_UPDATED_AT" VARCHAR(100), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -ALTER TABLE "RULES_PROFILES" ADD CONSTRAINT "PK_RULES_PROFILES" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "UNIQ_QPROF_KEY" ON "RULES_PROFILES"("KEE"); - -CREATE TABLE "QPROFILE_CHANGES"( - "KEE" VARCHAR(40) NOT NULL, - "RULES_PROFILE_UUID" VARCHAR(255) NOT NULL, - "CHANGE_TYPE" VARCHAR(20) NOT NULL, - "USER_UUID" VARCHAR(255), - "CHANGE_DATA" CLOB(2147483647), - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "QPROFILE_CHANGES" ADD CONSTRAINT "PK_QPROFILE_CHANGES" PRIMARY KEY("KEE"); -CREATE INDEX "QP_CHANGES_RULES_PROFILE_UUID" ON "QPROFILE_CHANGES"("RULES_PROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/snapshots/AddPrimaryKeyOnUuidColumnOfSnapshotsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/snapshots/AddPrimaryKeyOnUuidColumnOfSnapshotsTableTest/schema.sql deleted file mode 100644 index dcc23f6b586..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/snapshots/AddPrimaryKeyOnUuidColumnOfSnapshotsTableTest/schema.sql +++ /dev/null @@ -1,30 +0,0 @@ -CREATE TABLE "SNAPSHOTS"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "STATUS" VARCHAR(4) DEFAULT 'U' NOT NULL, - "ISLAST" BOOLEAN DEFAULT FALSE NOT NULL, - "VERSION" VARCHAR(500), - "PURGE_STATUS" INTEGER, - "BUILD_STRING" VARCHAR(100), - "REVISION" VARCHAR(100), - "BUILD_DATE" BIGINT, - "PERIOD1_MODE" VARCHAR(100), - "PERIOD1_PARAM" VARCHAR(100), - "PERIOD2_MODE" VARCHAR(100), - "PERIOD2_PARAM" VARCHAR(100), - "PERIOD3_MODE" VARCHAR(100), - "PERIOD3_PARAM" VARCHAR(100), - "PERIOD4_MODE" VARCHAR(100), - "PERIOD4_PARAM" VARCHAR(100), - "PERIOD5_MODE" VARCHAR(100), - "PERIOD5_PARAM" VARCHAR(100), - "PERIOD1_DATE" BIGINT, - "PERIOD2_DATE" BIGINT, - "PERIOD3_DATE" BIGINT, - "PERIOD4_DATE" BIGINT, - "PERIOD5_DATE" BIGINT, - "CREATED_AT" BIGINT -); -CREATE UNIQUE INDEX "ANALYSES_UUID" ON "SNAPSHOTS"("UUID"); -CREATE INDEX "SNAPSHOT_COMPONENT" ON "SNAPSHOTS"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/snapshots/DropIdColumnOfSnapshotsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/snapshots/DropIdColumnOfSnapshotsTableTest/schema.sql deleted file mode 100644 index c1891409f11..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/snapshots/DropIdColumnOfSnapshotsTableTest/schema.sql +++ /dev/null @@ -1,31 +0,0 @@ -CREATE TABLE "SNAPSHOTS"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "STATUS" VARCHAR(4) DEFAULT 'U' NOT NULL, - "ISLAST" BOOLEAN DEFAULT FALSE NOT NULL, - "VERSION" VARCHAR(500), - "PURGE_STATUS" INTEGER, - "BUILD_STRING" VARCHAR(100), - "REVISION" VARCHAR(100), - "BUILD_DATE" BIGINT, - "PERIOD1_MODE" VARCHAR(100), - "PERIOD1_PARAM" VARCHAR(100), - "PERIOD2_MODE" VARCHAR(100), - "PERIOD2_PARAM" VARCHAR(100), - "PERIOD3_MODE" VARCHAR(100), - "PERIOD3_PARAM" VARCHAR(100), - "PERIOD4_MODE" VARCHAR(100), - "PERIOD4_PARAM" VARCHAR(100), - "PERIOD5_MODE" VARCHAR(100), - "PERIOD5_PARAM" VARCHAR(100), - "PERIOD1_DATE" BIGINT, - "PERIOD2_DATE" BIGINT, - "PERIOD3_DATE" BIGINT, - "PERIOD4_DATE" BIGINT, - "PERIOD5_DATE" BIGINT, - "CREATED_AT" BIGINT -); -ALTER TABLE "SNAPSHOTS" ADD CONSTRAINT "PK_SNAPSHOTS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "ANALYSES_UUID" ON "SNAPSHOTS"("UUID"); -CREATE INDEX "SNAPSHOT_COMPONENT" ON "SNAPSHOTS"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/snapshots/DropPrimaryKeyOnIdColumnOfSnapshotsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/snapshots/DropPrimaryKeyOnIdColumnOfSnapshotsTableTest/schema.sql deleted file mode 100644 index 3d3e2694b15..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/snapshots/DropPrimaryKeyOnIdColumnOfSnapshotsTableTest/schema.sql +++ /dev/null @@ -1,31 +0,0 @@ -CREATE TABLE "SNAPSHOTS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "STATUS" VARCHAR(4) DEFAULT 'U' NOT NULL, - "ISLAST" BOOLEAN DEFAULT FALSE NOT NULL, - "VERSION" VARCHAR(500), - "PURGE_STATUS" INTEGER, - "BUILD_STRING" VARCHAR(100), - "REVISION" VARCHAR(100), - "BUILD_DATE" BIGINT, - "PERIOD1_MODE" VARCHAR(100), - "PERIOD1_PARAM" VARCHAR(100), - "PERIOD2_MODE" VARCHAR(100), - "PERIOD2_PARAM" VARCHAR(100), - "PERIOD3_MODE" VARCHAR(100), - "PERIOD3_PARAM" VARCHAR(100), - "PERIOD4_MODE" VARCHAR(100), - "PERIOD4_PARAM" VARCHAR(100), - "PERIOD5_MODE" VARCHAR(100), - "PERIOD5_PARAM" VARCHAR(100), - "PERIOD1_DATE" BIGINT, - "PERIOD2_DATE" BIGINT, - "PERIOD3_DATE" BIGINT, - "PERIOD4_DATE" BIGINT, - "PERIOD5_DATE" BIGINT, - "CREATED_AT" BIGINT -); -ALTER TABLE "SNAPSHOTS" ADD CONSTRAINT "PK_SNAPSHOTS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "ANALYSES_UUID" ON "SNAPSHOTS"("UUID"); -CREATE INDEX "SNAPSHOT_COMPONENT" ON "SNAPSHOTS"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/userroles/AddPrimaryKeyOnUuidColumnOfUserRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/userroles/AddPrimaryKeyOnUuidColumnOfUserRolesTableTest/schema.sql deleted file mode 100644 index 782ae4e6684..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/userroles/AddPrimaryKeyOnUuidColumnOfUserRolesTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "USER_ROLES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) -); -CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES"("USER_ID"); -CREATE INDEX "USER_ROLES_COMPONENT_UUID" ON "USER_ROLES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/userroles/AddUuidColumnToUserRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/userroles/AddUuidColumnToUserRolesTableTest/schema.sql deleted file mode 100644 index b30da4d7928..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/userroles/AddUuidColumnToUserRolesTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "USER_ROLES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) -); -ALTER TABLE "USER_ROLES" ADD CONSTRAINT "PK_USER_ROLES" PRIMARY KEY("ID"); -CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES"("USER_ID"); -CREATE INDEX "USER_ROLES_COMPONENT_UUID" ON "USER_ROLES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/userroles/DropIdColumnOfUserRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/userroles/DropIdColumnOfUserRolesTableTest/schema.sql deleted file mode 100644 index 334d2d2b80f..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/userroles/DropIdColumnOfUserRolesTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "USER_ROLES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) -); -ALTER TABLE "USER_ROLES" ADD CONSTRAINT "PK_USER_ROLES" PRIMARY KEY("UUID"); -CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES"("USER_ID"); -CREATE INDEX "USER_ROLES_COMPONENT_UUID" ON "USER_ROLES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/userroles/DropPrimaryKeyOnIdColumnOfUserRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/userroles/DropPrimaryKeyOnIdColumnOfUserRolesTableTest/schema.sql deleted file mode 100644 index 1970f132a00..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/userroles/DropPrimaryKeyOnIdColumnOfUserRolesTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "USER_ROLES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) -); -ALTER TABLE "USER_ROLES" ADD CONSTRAINT "PK_USER_ROLES" PRIMARY KEY("ID"); -CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES"("USER_ID"); -CREATE INDEX "USER_ROLES_COMPONENT_UUID" ON "USER_ROLES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/userroles/MakeUserRolesUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/userroles/MakeUserRolesUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index 80f78b06ede..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/userroles/MakeUserRolesUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "USER_ROLES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) -); -ALTER TABLE "USER_ROLES" ADD CONSTRAINT "PK_USER_ROLES" PRIMARY KEY("ID"); -CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES"("USER_ID"); -CREATE INDEX "USER_ROLES_COMPONENT_UUID" ON "USER_ROLES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/userroles/PopulateUserRolesUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/userroles/PopulateUserRolesUuidTest/schema.sql deleted file mode 100644 index 80f78b06ede..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/userroles/PopulateUserRolesUuidTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "USER_ROLES"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40) -); -ALTER TABLE "USER_ROLES" ADD CONSTRAINT "PK_USER_ROLES" PRIMARY KEY("ID"); -CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES"("USER_ID"); -CREATE INDEX "USER_ROLES_COMPONENT_UUID" ON "USER_ROLES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/AddPrimaryKeyOnUuidColumnOfUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/AddPrimaryKeyOnUuidColumnOfUsersTableTest/schema.sql deleted file mode 100644 index 3b7668e51e3..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/AddPrimaryKeyOnUuidColumnOfUsersTableTest/schema.sql +++ /dev/null @@ -1,29 +0,0 @@ -CREATE TABLE "USERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(255) NOT NULL, - "LOGIN" VARCHAR(255) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(100), - "SALT" VARCHAR(40), - "HASH_METHOD" VARCHAR(10), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_LOGIN" VARCHAR(255) NOT NULL, - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100) NOT NULL, - "EXTERNAL_ID" VARCHAR(255) NOT NULL, - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "HOMEPAGE_TYPE" VARCHAR(40), - "HOMEPAGE_PARAMETER" VARCHAR(40), - "LAST_CONNECTION_DATE" BIGINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS"("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS"("UPDATED_AT"); -CREATE UNIQUE INDEX "USERS_UUID" ON "USERS"("UUID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_ID" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_ID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_LOGIN" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_LOGIN"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/DropIdColumnOfUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/DropIdColumnOfUsersTableTest/schema.sql deleted file mode 100644 index c1eab3c95ac..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/DropIdColumnOfUsersTableTest/schema.sql +++ /dev/null @@ -1,30 +0,0 @@ -CREATE TABLE "USERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(255) NOT NULL, - "LOGIN" VARCHAR(255) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(100), - "SALT" VARCHAR(40), - "HASH_METHOD" VARCHAR(10), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_LOGIN" VARCHAR(255) NOT NULL, - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100) NOT NULL, - "EXTERNAL_ID" VARCHAR(255) NOT NULL, - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "HOMEPAGE_TYPE" VARCHAR(40), - "HOMEPAGE_PARAMETER" VARCHAR(40), - "LAST_CONNECTION_DATE" BIGINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "USERS" ADD CONSTRAINT "PK_USERS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS"("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS"("UPDATED_AT"); -CREATE UNIQUE INDEX "USERS_UUID" ON "USERS"("UUID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_ID" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_ID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_LOGIN" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_LOGIN"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/DropPrimaryKeyOnIdColumnOfUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/DropPrimaryKeyOnIdColumnOfUsersTableTest/schema.sql deleted file mode 100644 index 014607f5179..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/DropPrimaryKeyOnIdColumnOfUsersTableTest/schema.sql +++ /dev/null @@ -1,30 +0,0 @@ -CREATE TABLE "USERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(255) NOT NULL, - "LOGIN" VARCHAR(255) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(100), - "SALT" VARCHAR(40), - "HASH_METHOD" VARCHAR(10), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_LOGIN" VARCHAR(255) NOT NULL, - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100) NOT NULL, - "EXTERNAL_ID" VARCHAR(255) NOT NULL, - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "HOMEPAGE_TYPE" VARCHAR(40), - "HOMEPAGE_PARAMETER" VARCHAR(40), - "LAST_CONNECTION_DATE" BIGINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "USERS" ADD CONSTRAINT "PK_USERS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS"("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS"("UPDATED_AT"); -CREATE UNIQUE INDEX "USERS_UUID" ON "USERS"("UUID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_ID" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_ID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_LOGIN" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_LOGIN"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/DropUniqueIndexOnUuidColumnOfUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/DropUniqueIndexOnUuidColumnOfUsersTableTest/schema.sql deleted file mode 100644 index 3b7668e51e3..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/DropUniqueIndexOnUuidColumnOfUsersTableTest/schema.sql +++ /dev/null @@ -1,29 +0,0 @@ -CREATE TABLE "USERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(255) NOT NULL, - "LOGIN" VARCHAR(255) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(100), - "SALT" VARCHAR(40), - "HASH_METHOD" VARCHAR(10), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_LOGIN" VARCHAR(255) NOT NULL, - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100) NOT NULL, - "EXTERNAL_ID" VARCHAR(255) NOT NULL, - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "HOMEPAGE_TYPE" VARCHAR(40), - "HOMEPAGE_PARAMETER" VARCHAR(40), - "LAST_CONNECTION_DATE" BIGINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS"("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS"("UPDATED_AT"); -CREATE UNIQUE INDEX "USERS_UUID" ON "USERS"("UUID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_ID" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_ID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_LOGIN" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_LOGIN"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/AddIndexOnUserUuidOfGroupsUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/AddIndexOnUserUuidOfGroupsUsersTableTest/schema.sql deleted file mode 100644 index 87f8c34ea67..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/AddIndexOnUserUuidOfGroupsUsersTableTest/schema.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE "GROUPS_USERS"( - "USER_ID" BIGINT, - "GROUP_UUID" VARCHAR(40) NOT NULL, - "USER_UUID" VARCHAR(40) NOT NULL -); -CREATE INDEX "INDEX_GROUPS_USERS_GROUP_UUID" ON "GROUPS_USERS"("GROUP_UUID"); -CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS"("GROUP_UUID", "USER_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTableTest/schema.sql deleted file mode 100644 index 98085c9b74d..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTableTest/schema.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE "GROUPS_USERS"( - "USER_ID" BIGINT, - "GROUP_UUID" VARCHAR(40) NOT NULL, - "USER_UUID" VARCHAR(40) NOT NULL -); -CREATE INDEX "INDEX_GROUPS_USERS_USER_UUID" ON "GROUPS_USERS"("USER_UUID"); -CREATE INDEX "INDEX_GROUPS_USERS_GROUP_UUID" ON "GROUPS_USERS"("GROUP_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/AddUserUuidColumnToGroupsUsersTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/AddUserUuidColumnToGroupsUsersTest/schema.sql deleted file mode 100644 index a8f6820a912..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/AddUserUuidColumnToGroupsUsersTest/schema.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE "GROUPS_USERS"( - "USER_ID" BIGINT, - "GROUP_UUID" VARCHAR(40) NOT NULL -); -CREATE INDEX "INDEX_GROUPS_USERS_ON_USER_ID" ON "GROUPS_USERS"("USER_ID"); -CREATE INDEX "INDEX_GROUPS_USERS_GROUP_UUID" ON "GROUPS_USERS"("GROUP_UUID"); -CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS"("GROUP_UUID", "USER_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/DropIndexOnUserIdOfGroupsUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/DropIndexOnUserIdOfGroupsUsersTableTest/schema.sql deleted file mode 100644 index e0a585dd66e..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/DropIndexOnUserIdOfGroupsUsersTableTest/schema.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE "GROUPS_USERS"( - "USER_ID" BIGINT, - "GROUP_UUID" VARCHAR(40) NOT NULL, - "USER_UUID" VARCHAR(40) NOT NULL -); -CREATE INDEX "INDEX_GROUPS_USERS_ON_USER_ID" ON "GROUPS_USERS"("USER_ID"); -CREATE INDEX "INDEX_GROUPS_USERS_GROUP_UUID" ON "GROUPS_USERS"("GROUP_UUID"); -CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS"("GROUP_UUID", "USER_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTableTest/schema.sql deleted file mode 100644 index b71880d2f10..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTableTest/schema.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE "GROUPS_USERS"( - "USER_ID" BIGINT, - "GROUP_UUID" VARCHAR(40) NOT NULL, - "USER_UUID" VARCHAR(40) NOT NULL -); -CREATE INDEX "INDEX_GROUPS_USERS_USER_UUID" ON "GROUPS_USERS"("USER_UUID"); -CREATE INDEX "INDEX_GROUPS_USERS_GROUP_UUID" ON "GROUPS_USERS"("GROUP_UUID"); -CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS"("GROUP_UUID", "USER_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/DropUserIdColumnOfGroupsUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/DropUserIdColumnOfGroupsUsersTableTest/schema.sql deleted file mode 100644 index b74eac2c904..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/DropUserIdColumnOfGroupsUsersTableTest/schema.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE "GROUPS_USERS"( - "USER_ID" BIGINT, - "GROUP_UUID" VARCHAR(40) NOT NULL, - "USER_UUID" VARCHAR(40) NOT NULL -); -CREATE INDEX "INDEX_GROUPS_USERS_USER_UUID" ON "GROUPS_USERS"("USER_UUID"); -CREATE INDEX "INDEX_GROUPS_USERS_GROUP_UUID" ON "GROUPS_USERS"("GROUP_UUID"); -CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS"("GROUP_UUID", "USER_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/MakeGroupsUsersUserUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/MakeGroupsUsersUserUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index 167965e4750..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/MakeGroupsUsersUserUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE "GROUPS_USERS"( - "USER_ID" BIGINT, - "GROUP_UUID" VARCHAR(40) NOT NULL, - "USER_UUID" VARCHAR(40) -); -CREATE INDEX "INDEX_GROUPS_USERS_ON_USER_ID" ON "GROUPS_USERS"("USER_ID"); -CREATE INDEX "INDEX_GROUPS_USERS_ON_GROUP_UUID" ON "GROUPS_USERS"("GROUP_UUID"); -CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS"("GROUP_UUID", "USER_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/PopulateGroupsUsersUserUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/PopulateGroupsUsersUserUuidTest/schema.sql deleted file mode 100644 index 38059ac5a3a..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/groupsusers/PopulateGroupsUsersUserUuidTest/schema.sql +++ /dev/null @@ -1,40 +0,0 @@ -CREATE TABLE "USERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(255) NOT NULL, - "LOGIN" VARCHAR(255) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(100), - "SALT" VARCHAR(40), - "HASH_METHOD" VARCHAR(10), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_LOGIN" VARCHAR(255) NOT NULL, - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100) NOT NULL, - "EXTERNAL_ID" VARCHAR(255) NOT NULL, - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "HOMEPAGE_TYPE" VARCHAR(40), - "HOMEPAGE_PARAMETER" VARCHAR(40), - "LAST_CONNECTION_DATE" BIGINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "USERS" ADD CONSTRAINT "PK_USERS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS"("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS"("UPDATED_AT"); -CREATE UNIQUE INDEX "USERS_UUID" ON "USERS"("UUID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_ID" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_ID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_LOGIN" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_LOGIN"); - - -CREATE TABLE "GROUPS_USERS"( - "USER_ID" BIGINT, - "GROUP_UUID" VARCHAR(40) NOT NULL, - "USER_UUID" VARCHAR(40) -); -CREATE INDEX "INDEX_GROUPS_USERS_ON_USER_ID" ON "GROUPS_USERS"("USER_ID"); -CREATE INDEX "INDEX_GROUPS_USERS_ON_GROUP_UUID" ON "GROUPS_USERS"("GROUP_UUID"); -CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS"("GROUP_UUID", "USER_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/AddIndexOnUserUuidOfOrganizationMembersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/AddIndexOnUserUuidOfOrganizationMembersTableTest/schema.sql deleted file mode 100644 index 20cd2336941..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/AddIndexOnUserUuidOfOrganizationMembersTableTest/schema.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE "ORGANIZATION_MEMBERS"( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL, - "USER_UUID" VARCHAR(40) NOT NULL, -); -ALTER TABLE "ORGANIZATION_MEMBERS" ADD CONSTRAINT "PK_ORGANIZATION_MEMBERS" PRIMARY KEY("ORGANIZATION_UUID", "USER_ID"); - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTableTest/schema.sql deleted file mode 100644 index 3fa77611bd6..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTableTest/schema.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE "ORGANIZATION_MEMBERS"( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL, - "USER_UUID" VARCHAR(40) NOT NULL, -); -CREATE INDEX "ORG_MEMBERS_ON_USER_ID" ON "ORGANIZATION_MEMBERS"("USER_UUID"); - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/AddUserUuidColumnToOrganizationMembersTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/AddUserUuidColumnToOrganizationMembersTest/schema.sql deleted file mode 100644 index 1a0f1aa45a5..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/AddUserUuidColumnToOrganizationMembersTest/schema.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE "ORGANIZATION_MEMBERS"( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL -); -ALTER TABLE "ORGANIZATION_MEMBERS" ADD CONSTRAINT "PK_ORGANIZATION_MEMBERS" PRIMARY KEY("ORGANIZATION_UUID", "USER_ID"); -CREATE INDEX "IX_ORG_MEMBERS_ON_USER_ID" ON "ORGANIZATION_MEMBERS"("USER_ID"); - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/DropIndexOnUserIdOfOrganizationMembersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/DropIndexOnUserIdOfOrganizationMembersTableTest/schema.sql deleted file mode 100644 index 83a23943158..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/DropIndexOnUserIdOfOrganizationMembersTableTest/schema.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE "ORGANIZATION_MEMBERS"( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL, - "USER_UUID" VARCHAR(40) NOT NULL, -); -ALTER TABLE "ORGANIZATION_MEMBERS" ADD CONSTRAINT "PK_ORGANIZATION_MEMBERS" PRIMARY KEY("ORGANIZATION_UUID", "USER_ID"); -CREATE INDEX "IX_ORG_MEMBERS_ON_USER_ID" ON "ORGANIZATION_MEMBERS"("USER_ID"); - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTableTest/schema.sql deleted file mode 100644 index e72612d2481..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTableTest/schema.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE "ORGANIZATION_MEMBERS"( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL, - "USER_UUID" VARCHAR(40) NOT NULL, -); -ALTER TABLE "ORGANIZATION_MEMBERS" ADD CONSTRAINT "PK_ORGANIZATION_MEMBERS" PRIMARY KEY("ORGANIZATION_UUID", "USER_ID"); -CREATE INDEX "ORG_MEMBERS_ON_USER_UUID" ON "ORGANIZATION_MEMBERS"("USER_UUID"); - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/DropUserIdColumnOfOrganizationMembersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/DropUserIdColumnOfOrganizationMembersTableTest/schema.sql deleted file mode 100644 index 6f3084dc7ba..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/DropUserIdColumnOfOrganizationMembersTableTest/schema.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE "ORGANIZATION_MEMBERS"( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL, - "USER_UUID" VARCHAR(40) NOT NULL, -); -CREATE INDEX "ORG_MEMBERS_ON_USER_ID" ON "ORGANIZATION_MEMBERS"("USER_UUID"); -ALTER TABLE "ORGANIZATION_MEMBERS" ADD CONSTRAINT "PK_ORGANIZATION_MEMBERS" PRIMARY KEY("ORGANIZATION_UUID", "USER_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/MakeOrganizationMembersUserUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/MakeOrganizationMembersUserUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index 5951c00d434..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/MakeOrganizationMembersUserUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE "ORGANIZATION_MEMBERS"( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL, - "USER_UUID" VARCHAR(40), -); -ALTER TABLE "ORGANIZATION_MEMBERS" ADD CONSTRAINT "PK_ORGANIZATION_MEMBERS" PRIMARY KEY("ORGANIZATION_UUID", "USER_ID"); -CREATE INDEX "IX_ORG_MEMBERS_ON_USER_ID" ON "ORGANIZATION_MEMBERS"("USER_ID"); - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/PopulateOrganizationMembersUserUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/PopulateOrganizationMembersUserUuidTest/schema.sql deleted file mode 100644 index 3dbd7d9a215..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/organizationmembers/PopulateOrganizationMembersUserUuidTest/schema.sql +++ /dev/null @@ -1,40 +0,0 @@ -CREATE TABLE "USERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(255) NOT NULL, - "LOGIN" VARCHAR(255) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(100), - "SALT" VARCHAR(40), - "HASH_METHOD" VARCHAR(10), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_LOGIN" VARCHAR(255) NOT NULL, - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100) NOT NULL, - "EXTERNAL_ID" VARCHAR(255) NOT NULL, - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "HOMEPAGE_TYPE" VARCHAR(40), - "HOMEPAGE_PARAMETER" VARCHAR(40), - "LAST_CONNECTION_DATE" BIGINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "USERS" ADD CONSTRAINT "PK_USERS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS"("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS"("UPDATED_AT"); -CREATE UNIQUE INDEX "USERS_UUID" ON "USERS"("UUID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_ID" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_ID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_LOGIN" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_LOGIN"); - - -CREATE TABLE "ORGANIZATION_MEMBERS"( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL, - "USER_UUID" VARCHAR(40), -); -ALTER TABLE "ORGANIZATION_MEMBERS" ADD CONSTRAINT "PK_ORGANIZATION_MEMBERS" PRIMARY KEY("ORGANIZATION_UUID", "USER_ID"); -CREATE INDEX "IX_ORG_MEMBERS_ON_USER_ID" ON "ORGANIZATION_MEMBERS"("USER_ID"); - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/AddUserUuidColumnToPermTemplatesUsersTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/AddUserUuidColumnToPermTemplatesUsersTest/schema.sql deleted file mode 100644 index 10b095f9b4a..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/AddUserUuidColumnToPermTemplatesUsersTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_USERS"( - "USER_ID" INTEGER NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "PERM_TEMPLATES_USERS" ADD CONSTRAINT "PK_PERM_TEMPLATES_USERS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/DropUserIdColumnOfPermTemplatesUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/DropUserIdColumnOfPermTemplatesUsersTableTest/schema.sql deleted file mode 100644 index fc2cdb8b524..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/DropUserIdColumnOfPermTemplatesUsersTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_USERS"( - "USER_ID" INTEGER NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "UUID" VARCHAR(40) NOT NULL, - "USER_UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "PERM_TEMPLATES_USERS" ADD CONSTRAINT "PK_PERM_TEMPLATES_USERS" PRIMARY KEY("UUID"); - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/MakePermTemplatesUsersUserUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/MakePermTemplatesUsersUserUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index 752db98d466..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/MakePermTemplatesUsersUserUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PERM_TEMPLATES_USERS"( - "USER_ID" INTEGER NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "UUID" VARCHAR(40) NOT NULL, - "USER_UUID" VARCHAR(40) -); -ALTER TABLE "PERM_TEMPLATES_USERS" ADD CONSTRAINT "PK_PERM_TEMPLATES_USERS" PRIMARY KEY("UUID"); - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/PopulatePermTemplatesUsersUserUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/PopulatePermTemplatesUsersUserUuidTest/schema.sql deleted file mode 100644 index cd73faec4b4..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/permtemplatesusers/PopulatePermTemplatesUsersUserUuidTest/schema.sql +++ /dev/null @@ -1,42 +0,0 @@ -CREATE TABLE "USERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(255) NOT NULL, - "LOGIN" VARCHAR(255) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(100), - "SALT" VARCHAR(40), - "HASH_METHOD" VARCHAR(10), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_LOGIN" VARCHAR(255) NOT NULL, - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100) NOT NULL, - "EXTERNAL_ID" VARCHAR(255) NOT NULL, - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "HOMEPAGE_TYPE" VARCHAR(40), - "HOMEPAGE_PARAMETER" VARCHAR(40), - "LAST_CONNECTION_DATE" BIGINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "USERS" ADD CONSTRAINT "PK_USERS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS"("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS"("UPDATED_AT"); -CREATE UNIQUE INDEX "USERS_UUID" ON "USERS"("UUID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_ID" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_ID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_LOGIN" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_LOGIN"); - -CREATE TABLE "PERM_TEMPLATES_USERS"( - "USER_ID" INTEGER NOT NULL, - "TEMPLATE_ID" INTEGER NOT NULL, - "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "UUID" VARCHAR(40) NOT NULL, - "USER_UUID" VARCHAR(40) -); -ALTER TABLE "PERM_TEMPLATES_USERS" ADD CONSTRAINT "PK_PERM_TEMPLATES_USERS" PRIMARY KEY("UUID"); - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/AddUserUuidColumnToPropertiesUsersTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/AddUserUuidColumnToPropertiesUsersTest/schema.sql deleted file mode 100644 index e63f2fb66c8..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/AddUserUuidColumnToPropertiesUsersTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "PROPERTIES"( - "UUID" VARCHAR(40) NOT NULL, - "PROP_KEY" VARCHAR(512) NOT NULL, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB(2147483647), - "CREATED_AT" BIGINT NOT NULL, - "COMPONENT_UUID" VARCHAR(40) -); -ALTER TABLE "PROPERTIES" ADD CONSTRAINT "PK_PROPERTIES" PRIMARY KEY("UUID"); -CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES"("PROP_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/DropUserIdColumnOfPropertiesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/DropUserIdColumnOfPropertiesTableTest/schema.sql deleted file mode 100644 index a3d1fbfeeea..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/DropUserIdColumnOfPropertiesTableTest/schema.sql +++ /dev/null @@ -1,15 +0,0 @@ -CREATE TABLE "PROPERTIES"( - "UUID" VARCHAR(40) NOT NULL, - "PROP_KEY" VARCHAR(512) NOT NULL, - "USER_ID" INTEGER, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB(2147483647), - "CREATED_AT" BIGINT NOT NULL, - "COMPONENT_UUID" VARCHAR(40), - "USER_UUID" VARCHAR(40) -); -ALTER TABLE "PROPERTIES" ADD CONSTRAINT "PK_PROPERTIES" PRIMARY KEY("UUID"); -CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES"("PROP_KEY"); - - diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/PopulatePropertiesUserUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/PopulatePropertiesUserUuidTest/schema.sql deleted file mode 100644 index 7b392af768c..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/properties/PopulatePropertiesUserUuidTest/schema.sql +++ /dev/null @@ -1,44 +0,0 @@ -CREATE TABLE "USERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(255) NOT NULL, - "LOGIN" VARCHAR(255) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(100), - "SALT" VARCHAR(40), - "HASH_METHOD" VARCHAR(10), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_LOGIN" VARCHAR(255) NOT NULL, - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100) NOT NULL, - "EXTERNAL_ID" VARCHAR(255) NOT NULL, - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "HOMEPAGE_TYPE" VARCHAR(40), - "HOMEPAGE_PARAMETER" VARCHAR(40), - "LAST_CONNECTION_DATE" BIGINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "USERS" ADD CONSTRAINT "PK_USERS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS"("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS"("UPDATED_AT"); -CREATE UNIQUE INDEX "USERS_UUID" ON "USERS"("UUID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_ID" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_ID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_LOGIN" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_LOGIN"); - -CREATE TABLE "PROPERTIES"( - "UUID" VARCHAR(40) NOT NULL, - "PROP_KEY" VARCHAR(512) NOT NULL, - "USER_ID" INTEGER, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB(2147483647), - "CREATED_AT" BIGINT NOT NULL, - "COMPONENT_UUID" VARCHAR(40), - "USER_UUID" VARCHAR(40) -); -ALTER TABLE "PROPERTIES" ADD CONSTRAINT "PK_PROPERTIES" PRIMARY KEY("UUID"); -CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES"("PROP_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTableTest/schema.sql deleted file mode 100644 index 6111eb1f8e1..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTableTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "QPROFILE_EDIT_USERS"( - "UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL, - "QPROFILE_UUID" VARCHAR(255) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "USER_UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "QPROFILE_EDIT_USERS" ADD CONSTRAINT "PK_QPROFILE_EDIT_USERS" PRIMARY KEY("UUID"); -CREATE INDEX "QPROFILE_EDIT_USERS_QPROFILE" ON "QPROFILE_EDIT_USERS"("QPROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/AddUserUuidColumnToQProfileEditUsersTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/AddUserUuidColumnToQProfileEditUsersTest/schema.sql deleted file mode 100644 index 1149cf96ee7..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/AddUserUuidColumnToQProfileEditUsersTest/schema.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "QPROFILE_EDIT_USERS"( - "UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL, - "QPROFILE_UUID" VARCHAR(255) NOT NULL, - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "QPROFILE_EDIT_USERS" ADD CONSTRAINT "PK_QPROFILE_EDIT_USERS" PRIMARY KEY("UUID"); -CREATE INDEX "QPROFILE_EDIT_USERS_QPROFILE" ON "QPROFILE_EDIT_USERS"("QPROFILE_UUID"); -CREATE UNIQUE INDEX "QPROFILE_EDIT_USERS_UNIQUE" ON "QPROFILE_EDIT_USERS"("USER_ID", "QPROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTableTest/schema.sql deleted file mode 100644 index 94fa29f1c1a..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "QPROFILE_EDIT_USERS"( - "UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL, - "QPROFILE_UUID" VARCHAR(255) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "USER_UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "QPROFILE_EDIT_USERS" ADD CONSTRAINT "PK_QPROFILE_EDIT_USERS" PRIMARY KEY("UUID"); -CREATE INDEX "QPROFILE_EDIT_USERS_QPROFILE" ON "QPROFILE_EDIT_USERS"("QPROFILE_UUID"); -CREATE UNIQUE INDEX "QPROFILE_EDIT_USERS_UNIQUE" ON "QPROFILE_EDIT_USERS"("USER_ID", "QPROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/DropUserIdColumnOfQProfileEditUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/DropUserIdColumnOfQProfileEditUsersTableTest/schema.sql deleted file mode 100644 index e1a14b02b7b..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/DropUserIdColumnOfQProfileEditUsersTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "QPROFILE_EDIT_USERS"( - "UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL, - "QPROFILE_UUID" VARCHAR(255) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "USER_UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "QPROFILE_EDIT_USERS" ADD CONSTRAINT "PK_QPROFILE_EDIT_USERS" PRIMARY KEY("UUID"); -CREATE INDEX "QPROFILE_EDIT_USERS_QPROFILE" ON "QPROFILE_EDIT_USERS"("QPROFILE_UUID"); -CREATE UNIQUE INDEX "QPROFILE_EDIT_USERS_UNIQUE" ON "QPROFILE_EDIT_USERS"("USER_UUID", "QPROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/MakeQProfileEditUsersUserUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/MakeQProfileEditUsersUserUuidColumnNotNullableTest/schema.sql deleted file mode 100644 index d1a00b9e64b..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/MakeQProfileEditUsersUserUuidColumnNotNullableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "QPROFILE_EDIT_USERS"( - "UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL, - "QPROFILE_UUID" VARCHAR(255) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "USER_UUID" VARCHAR(40) -); -ALTER TABLE "QPROFILE_EDIT_USERS" ADD CONSTRAINT "PK_QPROFILE_EDIT_USERS" PRIMARY KEY("UUID"); -CREATE INDEX "QPROFILE_EDIT_USERS_QPROFILE" ON "QPROFILE_EDIT_USERS"("QPROFILE_UUID"); -CREATE UNIQUE INDEX "QPROFILE_EDIT_USERS_UNIQUE" ON "QPROFILE_EDIT_USERS"("USER_ID", "QPROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/PopulateQProfileEditUsersUserUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/PopulateQProfileEditUsersUserUuidTest/schema.sql deleted file mode 100644 index d10b8b5184c..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/qprofileeditusers/PopulateQProfileEditUsersUserUuidTest/schema.sql +++ /dev/null @@ -1,41 +0,0 @@ -CREATE TABLE "USERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(255) NOT NULL, - "LOGIN" VARCHAR(255) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(100), - "SALT" VARCHAR(40), - "HASH_METHOD" VARCHAR(10), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_LOGIN" VARCHAR(255) NOT NULL, - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100) NOT NULL, - "EXTERNAL_ID" VARCHAR(255) NOT NULL, - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "HOMEPAGE_TYPE" VARCHAR(40), - "HOMEPAGE_PARAMETER" VARCHAR(40), - "LAST_CONNECTION_DATE" BIGINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "USERS" ADD CONSTRAINT "PK_USERS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS"("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS"("UPDATED_AT"); -CREATE UNIQUE INDEX "USERS_UUID" ON "USERS"("UUID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_ID" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_ID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_LOGIN" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_LOGIN"); - -CREATE TABLE "QPROFILE_EDIT_USERS"( - "UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER NOT NULL, - "QPROFILE_UUID" VARCHAR(255) NOT NULL, - "CREATED_AT" BIGINT NOT NULL, - "USER_UUID" VARCHAR(40) -); -ALTER TABLE "QPROFILE_EDIT_USERS" ADD CONSTRAINT "PK_QPROFILE_EDIT_USERS" PRIMARY KEY("UUID"); -CREATE INDEX "QPROFILE_EDIT_USERS_QPROFILE" ON "QPROFILE_EDIT_USERS"("QPROFILE_UUID"); -CREATE UNIQUE INDEX "QPROFILE_EDIT_USERS_UNIQUE" ON "QPROFILE_EDIT_USERS"("USER_ID", "QPROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/AddIndexOnUserUuidOfUserRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/AddIndexOnUserUuidOfUserRolesTableTest/schema.sql deleted file mode 100644 index fee4bf2e2c9..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/AddIndexOnUserUuidOfUserRolesTableTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "USER_ROLES"( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40), - "UUID" VARCHAR(40) NOT NULL, - "USER_UUID" VARCHAR(40) -); -ALTER TABLE "USER_ROLES" ADD CONSTRAINT "PK_USER_ROLES" PRIMARY KEY("UUID"); -CREATE INDEX "USER_ROLES_COMPONENT_UUID" ON "USER_ROLES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/AddUserUuidColumnToUserRolesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/AddUserUuidColumnToUserRolesTest/schema.sql deleted file mode 100644 index b1619df129c..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/AddUserUuidColumnToUserRolesTest/schema.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "USER_ROLES"( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40), - "UUID" VARCHAR(40) NOT NULL -); -ALTER TABLE "USER_ROLES" ADD CONSTRAINT "PK_USER_ROLES" PRIMARY KEY("UUID"); -CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES"("USER_ID"); -CREATE INDEX "USER_ROLES_COMPONENT_UUID" ON "USER_ROLES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/DropIndexOnUserIdOfUserRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/DropIndexOnUserIdOfUserRolesTableTest/schema.sql deleted file mode 100644 index 6080af78618..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/DropIndexOnUserIdOfUserRolesTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "USER_ROLES"( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40), - "UUID" VARCHAR(40) NOT NULL, - "USER_UUID" VARCHAR(40) -); -ALTER TABLE "USER_ROLES" ADD CONSTRAINT "PK_USER_ROLES" PRIMARY KEY("UUID"); -CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES"("USER_ID"); -CREATE INDEX "USER_ROLES_COMPONENT_UUID" ON "USER_ROLES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/DropUserIdColumnOfUserRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/DropUserIdColumnOfUserRolesTableTest/schema.sql deleted file mode 100644 index 6080af78618..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/DropUserIdColumnOfUserRolesTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "USER_ROLES"( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40), - "UUID" VARCHAR(40) NOT NULL, - "USER_UUID" VARCHAR(40) -); -ALTER TABLE "USER_ROLES" ADD CONSTRAINT "PK_USER_ROLES" PRIMARY KEY("UUID"); -CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES"("USER_ID"); -CREATE INDEX "USER_ROLES_COMPONENT_UUID" ON "USER_ROLES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/PopulateUserRolesUserUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/PopulateUserRolesUserUuidTest/schema.sql deleted file mode 100644 index a1ad51f0b38..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/users/fk/userroles/PopulateUserRolesUserUuidTest/schema.sql +++ /dev/null @@ -1,42 +0,0 @@ -CREATE TABLE "USERS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(255) NOT NULL, - "LOGIN" VARCHAR(255) NOT NULL, - "ORGANIZATION_UUID" VARCHAR(40), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(100), - "SALT" VARCHAR(40), - "HASH_METHOD" VARCHAR(10), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_LOGIN" VARCHAR(255) NOT NULL, - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100) NOT NULL, - "EXTERNAL_ID" VARCHAR(255) NOT NULL, - "IS_ROOT" BOOLEAN NOT NULL, - "USER_LOCAL" BOOLEAN, - "ONBOARDED" BOOLEAN NOT NULL, - "HOMEPAGE_TYPE" VARCHAR(40), - "HOMEPAGE_PARAMETER" VARCHAR(40), - "LAST_CONNECTION_DATE" BIGINT, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -ALTER TABLE "USERS" ADD CONSTRAINT "PK_USERS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS"("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS"("UPDATED_AT"); -CREATE UNIQUE INDEX "USERS_UUID" ON "USERS"("UUID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_ID" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_ID"); -CREATE UNIQUE INDEX "UNIQ_EXTERNAL_LOGIN" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_LOGIN"); - -CREATE TABLE "USER_ROLES"( - "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, - "USER_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL, - "COMPONENT_UUID" VARCHAR(40), - "UUID" VARCHAR(40) NOT NULL, - "USER_UUID" VARCHAR(40) -); -ALTER TABLE "USER_ROLES" ADD CONSTRAINT "PK_USER_ROLES" PRIMARY KEY("UUID"); -CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES"("USER_ID"); -CREATE INDEX "USER_ROLES_COMPONENT_UUID" ON "USER_ROLES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/usertokens/AddPrimaryKeyOnUuidColumnOfUserTokensTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/usertokens/AddPrimaryKeyOnUuidColumnOfUserTokensTableTest/schema.sql deleted file mode 100644 index ca5001f995a..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/usertokens/AddPrimaryKeyOnUuidColumnOfUserTokensTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "USER_TOKENS"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "USER_UUID" VARCHAR(255) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "TOKEN_HASH" VARCHAR(255) NOT NULL, - "LAST_CONNECTION_DATE" BIGINT, - "CREATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "USER_TOKENS_USER_UUID_NAME" ON "USER_TOKENS"("USER_UUID", "NAME"); -CREATE UNIQUE INDEX "USER_TOKENS_TOKEN_HASH" ON "USER_TOKENS"("TOKEN_HASH"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/usertokens/AddUuidColumnToUserTokensTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/usertokens/AddUuidColumnToUserTokensTest/schema.sql deleted file mode 100644 index 485c3d4f80c..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/usertokens/AddUuidColumnToUserTokensTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "USER_TOKENS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "USER_UUID" VARCHAR(255) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "TOKEN_HASH" VARCHAR(255) NOT NULL, - "LAST_CONNECTION_DATE" BIGINT, - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "USER_TOKENS" ADD CONSTRAINT "PK_USER_TOKENS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "USER_TOKENS_USER_UUID_NAME" ON "USER_TOKENS"("USER_UUID", "NAME"); -CREATE UNIQUE INDEX "USER_TOKENS_TOKEN_HASH" ON "USER_TOKENS"("TOKEN_HASH"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/usertokens/DropIdColumnOfUserTokensTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/usertokens/DropIdColumnOfUserTokensTableTest/schema.sql deleted file mode 100644 index 894ee4b0fc4..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/usertokens/DropIdColumnOfUserTokensTableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "USER_TOKENS"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40) NOT NULL, - "USER_UUID" VARCHAR(255) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "TOKEN_HASH" VARCHAR(255) NOT NULL, - "LAST_CONNECTION_DATE" BIGINT, - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "USER_TOKENS" ADD CONSTRAINT "PK_USER_TOKENS" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "USER_TOKENS_USER_UUID_NAME" ON "USER_TOKENS"("USER_UUID", "NAME"); -CREATE UNIQUE INDEX "USER_TOKENS_TOKEN_HASH" ON "USER_TOKENS"("TOKEN_HASH"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/usertokens/DropPrimaryKeyOnIdColumnOfUserTokensTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/usertokens/DropPrimaryKeyOnIdColumnOfUserTokensTableTest/schema.sql deleted file mode 100644 index 485c3d4f80c..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/usertokens/DropPrimaryKeyOnIdColumnOfUserTokensTableTest/schema.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "USER_TOKENS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "USER_UUID" VARCHAR(255) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "TOKEN_HASH" VARCHAR(255) NOT NULL, - "LAST_CONNECTION_DATE" BIGINT, - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "USER_TOKENS" ADD CONSTRAINT "PK_USER_TOKENS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "USER_TOKENS_USER_UUID_NAME" ON "USER_TOKENS"("USER_UUID", "NAME"); -CREATE UNIQUE INDEX "USER_TOKENS_TOKEN_HASH" ON "USER_TOKENS"("TOKEN_HASH"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/usertokens/MakeUserTokensUuidNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/usertokens/MakeUserTokensUuidNotNullableTest/schema.sql deleted file mode 100644 index df2072a73cb..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/usertokens/MakeUserTokensUuidNotNullableTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "USER_TOKENS"( - "ID" INTEGER NOT NULL, - "UUID" VARCHAR(40), - "USER_UUID" VARCHAR(255) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "TOKEN_HASH" VARCHAR(255) NOT NULL, - "LAST_CONNECTION_DATE" BIGINT, - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "USER_TOKENS" ADD CONSTRAINT "PK_USER_TOKENS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "USER_TOKENS_USER_UUID_NAME" ON "USER_TOKENS"("USER_UUID", "NAME"); -CREATE UNIQUE INDEX "USER_TOKENS_TOKEN_HASH" ON "USER_TOKENS"("TOKEN_HASH"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/usertokens/PopulateUserTokensUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/usertokens/PopulateUserTokensUuidTest/schema.sql deleted file mode 100644 index b4869dc5a9c..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/usertokens/PopulateUserTokensUuidTest/schema.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "USER_TOKENS"( - "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), - "UUID" VARCHAR(40), - "USER_UUID" VARCHAR(255) NOT NULL, - "NAME" VARCHAR(100) NOT NULL, - "TOKEN_HASH" VARCHAR(255) NOT NULL, - "LAST_CONNECTION_DATE" BIGINT, - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "USER_TOKENS" ADD CONSTRAINT "PK_USER_TOKENS" PRIMARY KEY("ID"); -CREATE UNIQUE INDEX "USER_TOKENS_USER_UUID_NAME" ON "USER_TOKENS"("USER_UUID", "NAME"); -CREATE UNIQUE INDEX "USER_TOKENS_TOKEN_HASH" ON "USER_TOKENS"("TOKEN_HASH"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTableTest/schema.sql new file mode 100644 index 00000000000..814cb67b796 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTableTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "ACTIVE_RULE_PARAMETERS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "ACTIVE_RULE_ID" INTEGER NOT NULL, + "RULES_PARAMETER_ID" INTEGER NOT NULL, + "VALUE" VARCHAR(4000), + "RULES_PARAMETER_KEY" VARCHAR(128) +); + +CREATE INDEX "IX_ARP_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddUuidColumnToActiveRuleParametersTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddUuidColumnToActiveRuleParametersTest/schema.sql new file mode 100644 index 00000000000..8366c74f29d --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddUuidColumnToActiveRuleParametersTest/schema.sql @@ -0,0 +1,9 @@ +CREATE TABLE "ACTIVE_RULE_PARAMETERS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "ACTIVE_RULE_ID" INTEGER NOT NULL, + "RULES_PARAMETER_ID" INTEGER NOT NULL, + "VALUE" VARCHAR(4000), + "RULES_PARAMETER_KEY" VARCHAR(128) +); +ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("ID"); +CREATE INDEX "IX_ARP_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropIdColumnOfActiveRuleParametersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropIdColumnOfActiveRuleParametersTableTest/schema.sql new file mode 100644 index 00000000000..c95e98df88d --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropIdColumnOfActiveRuleParametersTableTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "ACTIVE_RULE_PARAMETERS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "ACTIVE_RULE_ID" INTEGER NOT NULL, + "RULES_PARAMETER_ID" INTEGER NOT NULL, + "VALUE" VARCHAR(4000), + "RULES_PARAMETER_KEY" VARCHAR(128) +); +ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("UUID"); +CREATE INDEX "IX_ARP_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropPrimaryKeyOnIdColumnOfActiveRuleParametersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropPrimaryKeyOnIdColumnOfActiveRuleParametersTableTest/schema.sql new file mode 100644 index 00000000000..88efe9d1252 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropPrimaryKeyOnIdColumnOfActiveRuleParametersTableTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "ACTIVE_RULE_PARAMETERS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "ACTIVE_RULE_ID" INTEGER NOT NULL, + "RULES_PARAMETER_ID" INTEGER NOT NULL, + "VALUE" VARCHAR(4000), + "RULES_PARAMETER_KEY" VARCHAR(128) +); +ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("ID"); +CREATE INDEX "IX_ARP_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/MakeActiveRuleParametersUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/MakeActiveRuleParametersUuidColumnNotNullableTest/schema.sql new file mode 100644 index 00000000000..e3fb5b749c3 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/MakeActiveRuleParametersUuidColumnNotNullableTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "ACTIVE_RULE_PARAMETERS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40), + "ACTIVE_RULE_ID" INTEGER NOT NULL, + "RULES_PARAMETER_ID" INTEGER NOT NULL, + "VALUE" VARCHAR(4000), + "RULES_PARAMETER_KEY" VARCHAR(128) +); +ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("ID"); +CREATE INDEX "IX_ARP_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/PopulateActiveRuleParametersUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/PopulateActiveRuleParametersUuidTest/schema.sql new file mode 100644 index 00000000000..e3fb5b749c3 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/PopulateActiveRuleParametersUuidTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "ACTIVE_RULE_PARAMETERS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40), + "ACTIVE_RULE_ID" INTEGER NOT NULL, + "RULES_PARAMETER_ID" INTEGER NOT NULL, + "VALUE" VARCHAR(4000), + "RULES_PARAMETER_KEY" VARCHAR(128) +); +ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("ID"); +CREATE INDEX "IX_ARP_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/AddActiveRuleUuidColumnToActiveRuleParametersTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/AddActiveRuleUuidColumnToActiveRuleParametersTest/schema.sql new file mode 100644 index 00000000000..04d58e9edf0 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/AddActiveRuleUuidColumnToActiveRuleParametersTest/schema.sql @@ -0,0 +1,9 @@ +CREATE TABLE "ACTIVE_RULE_PARAMETERS"( + "ACTIVE_RULE_ID" INTEGER NOT NULL, + "RULES_PARAMETER_ID" INTEGER NOT NULL, + "VALUE" VARCHAR(4000), + "RULES_PARAMETER_KEY" VARCHAR(128), + "UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("UUID"); +CREATE INDEX "IX_ARP_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/AddIndexOnActiveRuleUuidOfActiveRuleParametersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/AddIndexOnActiveRuleUuidOfActiveRuleParametersTableTest/schema.sql new file mode 100644 index 00000000000..b074136418d --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/AddIndexOnActiveRuleUuidOfActiveRuleParametersTableTest/schema.sql @@ -0,0 +1,9 @@ +CREATE TABLE "ACTIVE_RULE_PARAMETERS"( + "ACTIVE_RULE_ID" INTEGER NOT NULL, + "ACTIVE_RULE_UUID" VARCHAR(40) NOT NULL, + "RULES_PARAMETER_ID" INTEGER NOT NULL, + "VALUE" VARCHAR(4000), + "RULES_PARAMETER_KEY" VARCHAR(128), + "UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/AddPrimaryKeyOnUuidColumnOfActiveRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/AddPrimaryKeyOnUuidColumnOfActiveRulesTableTest/schema.sql new file mode 100644 index 00000000000..58802cb272e --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/AddPrimaryKeyOnUuidColumnOfActiveRulesTableTest/schema.sql @@ -0,0 +1,11 @@ +CREATE TABLE "ACTIVE_RULES"( + "ID" INTEGER NOT NULL, + "UUID" VARCHAR(40) NOT NULL, + "PROFILE_ID" INTEGER NOT NULL, + "RULE_ID" INTEGER NOT NULL, + "FAILURE_LEVEL" INTEGER NOT NULL, + "INHERITANCE" VARCHAR(10), + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT +); +CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_ID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/AddUuidColumnToActiveRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/AddUuidColumnToActiveRulesTableTest/schema.sql new file mode 100644 index 00000000000..f7f18747670 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/AddUuidColumnToActiveRulesTableTest/schema.sql @@ -0,0 +1,11 @@ +CREATE TABLE "ACTIVE_RULES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "PROFILE_ID" INTEGER NOT NULL, + "RULE_ID" INTEGER NOT NULL, + "FAILURE_LEVEL" INTEGER NOT NULL, + "INHERITANCE" VARCHAR(10), + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT +); +ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_ID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/DropActiveRuleIdColumnOfActiveRuleParametersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/DropActiveRuleIdColumnOfActiveRuleParametersTableTest/schema.sql new file mode 100644 index 00000000000..24d5888764c --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/DropActiveRuleIdColumnOfActiveRuleParametersTableTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "ACTIVE_RULE_PARAMETERS"( + "ACTIVE_RULE_ID" INTEGER NOT NULL, + "ACTIVE_RULE_UUID" VARCHAR(40) NOT NULL, + "RULES_PARAMETER_ID" INTEGER NOT NULL, + "VALUE" VARCHAR(4000), + "RULES_PARAMETER_KEY" VARCHAR(128), + "UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("UUID"); +CREATE INDEX "ARP_ACTIVE_RULE_UUID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/DropIdColumnOfActiveRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/DropIdColumnOfActiveRulesTableTest/schema.sql new file mode 100644 index 00000000000..faf2cd098e9 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/DropIdColumnOfActiveRulesTableTest/schema.sql @@ -0,0 +1,12 @@ +CREATE TABLE "ACTIVE_RULES"( + "ID" INTEGER NOT NULL, + "UUID" VARCHAR(40) NOT NULL, + "PROFILE_ID" INTEGER NOT NULL, + "RULE_ID" INTEGER NOT NULL, + "FAILURE_LEVEL" INTEGER NOT NULL, + "INHERITANCE" VARCHAR(10), + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT +); +ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("UUID"); +CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_ID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/DropIndexOnActiveRuleIdOfActiveRuleParametersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/DropIndexOnActiveRuleIdOfActiveRuleParametersTableTest/schema.sql new file mode 100644 index 00000000000..fe510a7faaf --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/DropIndexOnActiveRuleIdOfActiveRuleParametersTableTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "ACTIVE_RULE_PARAMETERS"( + "ACTIVE_RULE_ID" INTEGER NOT NULL, + "ACTIVE_RULE_UUID" VARCHAR(40) NOT NULL, + "RULES_PARAMETER_ID" INTEGER NOT NULL, + "VALUE" VARCHAR(4000), + "RULES_PARAMETER_KEY" VARCHAR(128), + "UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("UUID"); +CREATE INDEX "IX_ARP_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/DropPrimaryKeyOnIdColumnOfActiveRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/DropPrimaryKeyOnIdColumnOfActiveRulesTableTest/schema.sql new file mode 100644 index 00000000000..642bd8470a6 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/DropPrimaryKeyOnIdColumnOfActiveRulesTableTest/schema.sql @@ -0,0 +1,12 @@ +CREATE TABLE "ACTIVE_RULES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "PROFILE_ID" INTEGER NOT NULL, + "RULE_ID" INTEGER NOT NULL, + "FAILURE_LEVEL" INTEGER NOT NULL, + "INHERITANCE" VARCHAR(10), + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT +); +ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_ID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/MakeActiveRuleParametersActiveRuleUuidNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/MakeActiveRuleParametersActiveRuleUuidNotNullableTest/schema.sql new file mode 100644 index 00000000000..0f789b84e93 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/MakeActiveRuleParametersActiveRuleUuidNotNullableTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "ACTIVE_RULE_PARAMETERS"( + "ACTIVE_RULE_ID" INTEGER NOT NULL, + "ACTIVE_RULE_UUID" VARCHAR(40), + "RULES_PARAMETER_ID" INTEGER NOT NULL, + "VALUE" VARCHAR(4000), + "RULES_PARAMETER_KEY" VARCHAR(128), + "UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("UUID"); +CREATE INDEX "IX_ARP_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/MakeActiveRulesUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/MakeActiveRulesUuidColumnNotNullableTest/schema.sql new file mode 100644 index 00000000000..49569a9667a --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/MakeActiveRulesUuidColumnNotNullableTest/schema.sql @@ -0,0 +1,12 @@ +CREATE TABLE "ACTIVE_RULES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40), + "PROFILE_ID" INTEGER NOT NULL, + "RULE_ID" INTEGER NOT NULL, + "FAILURE_LEVEL" INTEGER NOT NULL, + "INHERITANCE" VARCHAR(10), + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT +); +ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_ID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/PopulateActiveRuleParametersActiveRuleUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/PopulateActiveRuleParametersActiveRuleUuidTest/schema.sql new file mode 100644 index 00000000000..5d00ec845ca --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/PopulateActiveRuleParametersActiveRuleUuidTest/schema.sql @@ -0,0 +1,23 @@ +CREATE TABLE "ACTIVE_RULE_PARAMETERS"( + "ACTIVE_RULE_ID" INTEGER NOT NULL, + "ACTIVE_RULE_UUID" VARCHAR(40), + "RULES_PARAMETER_ID" INTEGER NOT NULL, + "VALUE" VARCHAR(4000), + "RULES_PARAMETER_KEY" VARCHAR(128), + "UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("UUID"); +CREATE INDEX "IX_ARP_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_ID"); + +CREATE TABLE "ACTIVE_RULES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "PROFILE_ID" INTEGER NOT NULL, + "RULE_ID" INTEGER NOT NULL, + "FAILURE_LEVEL" INTEGER NOT NULL, + "INHERITANCE" VARCHAR(10), + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT +); +ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_ID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/PopulateActiveRulesUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/PopulateActiveRulesUuidTest/schema.sql new file mode 100644 index 00000000000..49569a9667a --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/activerules/PopulateActiveRulesUuidTest/schema.sql @@ -0,0 +1,12 @@ +CREATE TABLE "ACTIVE_RULES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40), + "PROFILE_ID" INTEGER NOT NULL, + "RULE_ID" INTEGER NOT NULL, + "FAILURE_LEVEL" INTEGER NOT NULL, + "INHERITANCE" VARCHAR(10), + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT +); +ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_ID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTableTest/schema.sql new file mode 100644 index 00000000000..22ed140880e --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTableTest/schema.sql @@ -0,0 +1,32 @@ +CREATE TABLE "CE_ACTIVITY"( + "ID" INTEGER NOT NULL, + "UUID" VARCHAR(40) NOT NULL, + "TASK_TYPE" VARCHAR(15) NOT NULL, + "MAIN_COMPONENT_UUID" VARCHAR(40), + "COMPONENT_UUID" VARCHAR(40), + "STATUS" VARCHAR(15) NOT NULL, + "MAIN_IS_LAST" BOOLEAN NOT NULL, + "MAIN_IS_LAST_KEY" VARCHAR(55) NOT NULL, + "IS_LAST" BOOLEAN NOT NULL, + "IS_LAST_KEY" VARCHAR(55) NOT NULL, + "SUBMITTER_UUID" VARCHAR(255), + "SUBMITTED_AT" BIGINT NOT NULL, + "STARTED_AT" BIGINT, + "EXECUTED_AT" BIGINT, + "EXECUTION_COUNT" INTEGER NOT NULL, + "EXECUTION_TIME_MS" BIGINT, + "ANALYSIS_UUID" VARCHAR(50), + "ERROR_MESSAGE" VARCHAR(1000), + "ERROR_STACKTRACE" CLOB(2147483647), + "ERROR_TYPE" VARCHAR(20), + "WORKER_UUID" VARCHAR(40), + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL +); +CREATE INDEX "CE_ACTIVITY_COMPONENT" ON "CE_ACTIVITY"("COMPONENT_UUID"); +CREATE INDEX "CE_ACTIVITY_ISLAST" ON "CE_ACTIVITY"("IS_LAST", "STATUS"); +CREATE INDEX "CE_ACTIVITY_ISLAST_KEY" ON "CE_ACTIVITY"("IS_LAST_KEY"); +CREATE INDEX "CE_ACTIVITY_MAIN_COMPONENT" ON "CE_ACTIVITY"("MAIN_COMPONENT_UUID"); +CREATE INDEX "CE_ACTIVITY_MAIN_ISLAST" ON "CE_ACTIVITY"("MAIN_IS_LAST", "STATUS"); +CREATE INDEX "CE_ACTIVITY_MAIN_ISLAST_KEY" ON "CE_ACTIVITY"("MAIN_IS_LAST_KEY"); +CREATE UNIQUE INDEX "CE_ACTIVITY_UUID" ON "CE_ACTIVITY"("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropIdColumnOfCeActivityTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropIdColumnOfCeActivityTableTest/schema.sql new file mode 100644 index 00000000000..9aa76b650fd --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropIdColumnOfCeActivityTableTest/schema.sql @@ -0,0 +1,33 @@ +CREATE TABLE "CE_ACTIVITY"( + "ID" INTEGER NOT NULL, + "UUID" VARCHAR(40) NOT NULL, + "TASK_TYPE" VARCHAR(15) NOT NULL, + "MAIN_COMPONENT_UUID" VARCHAR(40), + "COMPONENT_UUID" VARCHAR(40), + "STATUS" VARCHAR(15) NOT NULL, + "MAIN_IS_LAST" BOOLEAN NOT NULL, + "MAIN_IS_LAST_KEY" VARCHAR(55) NOT NULL, + "IS_LAST" BOOLEAN NOT NULL, + "IS_LAST_KEY" VARCHAR(55) NOT NULL, + "SUBMITTER_UUID" VARCHAR(255), + "SUBMITTED_AT" BIGINT NOT NULL, + "STARTED_AT" BIGINT, + "EXECUTED_AT" BIGINT, + "EXECUTION_COUNT" INTEGER NOT NULL, + "EXECUTION_TIME_MS" BIGINT, + "ANALYSIS_UUID" VARCHAR(50), + "ERROR_MESSAGE" VARCHAR(1000), + "ERROR_STACKTRACE" CLOB(2147483647), + "ERROR_TYPE" VARCHAR(20), + "WORKER_UUID" VARCHAR(40), + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL +); +ALTER TABLE "CE_ACTIVITY" ADD CONSTRAINT "PK_CE_ACTIVITY" PRIMARY KEY("UUID"); +CREATE INDEX "CE_ACTIVITY_COMPONENT" ON "CE_ACTIVITY"("COMPONENT_UUID"); +CREATE INDEX "CE_ACTIVITY_ISLAST" ON "CE_ACTIVITY"("IS_LAST", "STATUS"); +CREATE INDEX "CE_ACTIVITY_ISLAST_KEY" ON "CE_ACTIVITY"("IS_LAST_KEY"); +CREATE INDEX "CE_ACTIVITY_MAIN_COMPONENT" ON "CE_ACTIVITY"("MAIN_COMPONENT_UUID"); +CREATE INDEX "CE_ACTIVITY_MAIN_ISLAST" ON "CE_ACTIVITY"("MAIN_IS_LAST", "STATUS"); +CREATE INDEX "CE_ACTIVITY_MAIN_ISLAST_KEY" ON "CE_ACTIVITY"("MAIN_IS_LAST_KEY"); +CREATE UNIQUE INDEX "CE_ACTIVITY_UUID" ON "CE_ACTIVITY"("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTableTest/schema.sql new file mode 100644 index 00000000000..d8fec2db804 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTableTest/schema.sql @@ -0,0 +1,33 @@ +CREATE TABLE "CE_ACTIVITY"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "TASK_TYPE" VARCHAR(15) NOT NULL, + "MAIN_COMPONENT_UUID" VARCHAR(40), + "COMPONENT_UUID" VARCHAR(40), + "STATUS" VARCHAR(15) NOT NULL, + "MAIN_IS_LAST" BOOLEAN NOT NULL, + "MAIN_IS_LAST_KEY" VARCHAR(55) NOT NULL, + "IS_LAST" BOOLEAN NOT NULL, + "IS_LAST_KEY" VARCHAR(55) NOT NULL, + "SUBMITTER_UUID" VARCHAR(255), + "SUBMITTED_AT" BIGINT NOT NULL, + "STARTED_AT" BIGINT, + "EXECUTED_AT" BIGINT, + "EXECUTION_COUNT" INTEGER NOT NULL, + "EXECUTION_TIME_MS" BIGINT, + "ANALYSIS_UUID" VARCHAR(50), + "ERROR_MESSAGE" VARCHAR(1000), + "ERROR_STACKTRACE" CLOB(2147483647), + "ERROR_TYPE" VARCHAR(20), + "WORKER_UUID" VARCHAR(40), + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL +); +ALTER TABLE "CE_ACTIVITY" ADD CONSTRAINT "PK_CE_ACTIVITY" PRIMARY KEY("ID"); +CREATE INDEX "CE_ACTIVITY_COMPONENT" ON "CE_ACTIVITY"("COMPONENT_UUID"); +CREATE INDEX "CE_ACTIVITY_ISLAST" ON "CE_ACTIVITY"("IS_LAST", "STATUS"); +CREATE INDEX "CE_ACTIVITY_ISLAST_KEY" ON "CE_ACTIVITY"("IS_LAST_KEY"); +CREATE INDEX "CE_ACTIVITY_MAIN_COMPONENT" ON "CE_ACTIVITY"("MAIN_COMPONENT_UUID"); +CREATE INDEX "CE_ACTIVITY_MAIN_ISLAST" ON "CE_ACTIVITY"("MAIN_IS_LAST", "STATUS"); +CREATE INDEX "CE_ACTIVITY_MAIN_ISLAST_KEY" ON "CE_ACTIVITY"("MAIN_IS_LAST_KEY"); +CREATE UNIQUE INDEX "CE_ACTIVITY_UUID" ON "CE_ACTIVITY"("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/cequeue/AddPrimaryKeyOnUuidColumnOfCeQueueTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/cequeue/AddPrimaryKeyOnUuidColumnOfCeQueueTableTest/schema.sql new file mode 100644 index 00000000000..bf5f23f3e28 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/cequeue/AddPrimaryKeyOnUuidColumnOfCeQueueTableTest/schema.sql @@ -0,0 +1,16 @@ +CREATE TABLE "CE_QUEUE"( + "ID" INTEGER NOT NULL, + "UUID" VARCHAR(40) NOT NULL, + "TASK_TYPE" VARCHAR(15) NOT NULL, + "MAIN_COMPONENT_UUID" VARCHAR(40), + "COMPONENT_UUID" VARCHAR(40), + "STATUS" VARCHAR(15), + "SUBMITTER_UUID" VARCHAR(255), + "STARTED_AT" BIGINT, + "WORKER_UUID" VARCHAR(40), + "EXECUTION_COUNT" INTEGER NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL +); +CREATE INDEX "CE_QUEUE_MAIN_COMPONENT" ON "CE_QUEUE"("MAIN_COMPONENT_UUID"); +CREATE INDEX "CE_QUEUE_COMPONENT" ON "CE_QUEUE"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/cequeue/DropIdColumnOfCeQueueTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/cequeue/DropIdColumnOfCeQueueTableTest/schema.sql new file mode 100644 index 00000000000..48cfeb2001b --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/cequeue/DropIdColumnOfCeQueueTableTest/schema.sql @@ -0,0 +1,17 @@ +CREATE TABLE "CE_QUEUE"( + "ID" INTEGER NOT NULL, + "UUID" VARCHAR(40) NOT NULL, + "TASK_TYPE" VARCHAR(15) NOT NULL, + "MAIN_COMPONENT_UUID" VARCHAR(40), + "COMPONENT_UUID" VARCHAR(40), + "STATUS" VARCHAR(15), + "SUBMITTER_UUID" VARCHAR(255), + "STARTED_AT" BIGINT, + "WORKER_UUID" VARCHAR(40), + "EXECUTION_COUNT" INTEGER NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL +); +ALTER TABLE "CE_QUEUE" ADD CONSTRAINT "PK_CE_QUEUE" PRIMARY KEY("UUID"); +CREATE INDEX "CE_QUEUE_MAIN_COMPONENT" ON "CE_QUEUE"("MAIN_COMPONENT_UUID"); +CREATE INDEX "CE_QUEUE_COMPONENT" ON "CE_QUEUE"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/cequeue/DropPrimaryKeyOnIdColumnOfCeQueueTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/cequeue/DropPrimaryKeyOnIdColumnOfCeQueueTableTest/schema.sql new file mode 100644 index 00000000000..ca173102b08 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/cequeue/DropPrimaryKeyOnIdColumnOfCeQueueTableTest/schema.sql @@ -0,0 +1,17 @@ +CREATE TABLE "CE_QUEUE"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "TASK_TYPE" VARCHAR(15) NOT NULL, + "MAIN_COMPONENT_UUID" VARCHAR(40), + "COMPONENT_UUID" VARCHAR(40), + "STATUS" VARCHAR(15), + "SUBMITTER_UUID" VARCHAR(255), + "STARTED_AT" BIGINT, + "WORKER_UUID" VARCHAR(40), + "EXECUTION_COUNT" INTEGER NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL +); +ALTER TABLE "CE_QUEUE" ADD CONSTRAINT "PK_CE_QUEUE" PRIMARY KEY("ID"); +CREATE INDEX "CE_QUEUE_MAIN_COMPONENT" ON "CE_QUEUE"("MAIN_COMPONENT_UUID"); +CREATE INDEX "CE_QUEUE_COMPONENT" ON "CE_QUEUE"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/cequeue/DropUniqueIndexOnUuidColumnOfCeQueueTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/cequeue/DropUniqueIndexOnUuidColumnOfCeQueueTableTest/schema.sql new file mode 100644 index 00000000000..8ab0a1195b3 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/cequeue/DropUniqueIndexOnUuidColumnOfCeQueueTableTest/schema.sql @@ -0,0 +1,18 @@ +CREATE TABLE "CE_QUEUE"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "TASK_TYPE" VARCHAR(15) NOT NULL, + "MAIN_COMPONENT_UUID" VARCHAR(40), + "COMPONENT_UUID" VARCHAR(40), + "STATUS" VARCHAR(15), + "SUBMITTER_UUID" VARCHAR(255), + "STARTED_AT" BIGINT, + "WORKER_UUID" VARCHAR(40), + "EXECUTION_COUNT" INTEGER NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL +); +ALTER TABLE "CE_QUEUE" ADD CONSTRAINT "PK_CE_QUEUE" PRIMARY KEY("ID"); +CREATE INDEX "CE_QUEUE_MAIN_COMPONENT" ON "CE_QUEUE"("MAIN_COMPONENT_UUID"); +CREATE INDEX "CE_QUEUE_COMPONENT" ON "CE_QUEUE"("COMPONENT_UUID"); +CREATE UNIQUE INDEX "CE_QUEUE_UUID" ON "CE_QUEUE"("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTableTest/schema.sql new file mode 100644 index 00000000000..de4522b3c84 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTableTest/schema.sql @@ -0,0 +1,12 @@ +CREATE TABLE "DUPLICATIONS_INDEX"( + "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), + "ANALYSIS_UUID" VARCHAR(50) NOT NULL, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "HASH" VARCHAR(50) NOT NULL, + "INDEX_IN_FILE" INTEGER NOT NULL, + "START_LINE" INTEGER NOT NULL, + "END_LINE" INTEGER NOT NULL, + "UUID" VARCHAR(40) NOT NULL +); +CREATE INDEX "DUPLICATIONS_INDEX_HASH" ON "DUPLICATIONS_INDEX"("HASH"); +CREATE INDEX "DUPLICATION_ANALYSIS_COMPONENT" ON "DUPLICATIONS_INDEX"("ANALYSIS_UUID", "COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddUuidToDuplicationsIndexTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddUuidToDuplicationsIndexTableTest/schema.sql new file mode 100644 index 00000000000..f0001521878 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddUuidToDuplicationsIndexTableTest/schema.sql @@ -0,0 +1,13 @@ +CREATE TABLE "DUPLICATIONS_INDEX"( + "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), + "ANALYSIS_UUID" VARCHAR(50) NOT NULL, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "HASH" VARCHAR(50) NOT NULL, + "INDEX_IN_FILE" INTEGER NOT NULL, + "START_LINE" INTEGER NOT NULL, + "END_LINE" INTEGER NOT NULL +); +ALTER TABLE "DUPLICATIONS_INDEX" ADD CONSTRAINT "PK_DUPLICATIONS_INDEX" PRIMARY KEY("ID"); +CREATE INDEX "DUPLICATIONS_INDEX_HASH" ON "DUPLICATIONS_INDEX"("HASH"); +CREATE INDEX "DUPLICATION_ANALYSIS_COMPONENT" ON "DUPLICATIONS_INDEX"("ANALYSIS_UUID", "COMPONENT_UUID"); + diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropIdColumnOfDuplicationsIndexTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropIdColumnOfDuplicationsIndexTableTest/schema.sql new file mode 100644 index 00000000000..1399658a241 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropIdColumnOfDuplicationsIndexTableTest/schema.sql @@ -0,0 +1,13 @@ +CREATE TABLE "DUPLICATIONS_INDEX"( + "ID" BIGINT NOT NULL, + "ANALYSIS_UUID" VARCHAR(50) NOT NULL, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "HASH" VARCHAR(50) NOT NULL, + "INDEX_IN_FILE" INTEGER NOT NULL, + "START_LINE" INTEGER NOT NULL, + "END_LINE" INTEGER NOT NULL, + "UUID" VARCHAR(40) NOT NULL, +); +ALTER TABLE "DUPLICATIONS_INDEX" ADD CONSTRAINT "PK_DUPLICATIONS_INDEX" PRIMARY KEY("UUID"); +CREATE INDEX "DUPLICATIONS_INDEX_HASH" ON "DUPLICATIONS_INDEX"("HASH"); +CREATE INDEX "DUPLICATION_ANALYSIS_COMPONENT" ON "DUPLICATIONS_INDEX"("ANALYSIS_UUID", "COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropPrimaryKeyOnIdColumnOfDuplicationsIndexTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropPrimaryKeyOnIdColumnOfDuplicationsIndexTableTest/schema.sql new file mode 100644 index 00000000000..e8f7a1414be --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropPrimaryKeyOnIdColumnOfDuplicationsIndexTableTest/schema.sql @@ -0,0 +1,13 @@ +CREATE TABLE "DUPLICATIONS_INDEX"( + "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), + "ANALYSIS_UUID" VARCHAR(50) NOT NULL, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "HASH" VARCHAR(50) NOT NULL, + "INDEX_IN_FILE" INTEGER NOT NULL, + "START_LINE" INTEGER NOT NULL, + "END_LINE" INTEGER NOT NULL, + "UUID" VARCHAR(40) NOT NULL, +); +ALTER TABLE "DUPLICATIONS_INDEX" ADD CONSTRAINT "PK_DUPLICATIONS_INDEX" PRIMARY KEY("ID"); +CREATE INDEX "DUPLICATIONS_INDEX_HASH" ON "DUPLICATIONS_INDEX"("HASH"); +CREATE INDEX "DUPLICATION_ANALYSIS_COMPONENT" ON "DUPLICATIONS_INDEX"("ANALYSIS_UUID", "COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/MakeDuplicationsIndexUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/MakeDuplicationsIndexUuidColumnNotNullableTest/schema.sql new file mode 100644 index 00000000000..6432378da7b --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/MakeDuplicationsIndexUuidColumnNotNullableTest/schema.sql @@ -0,0 +1,13 @@ +CREATE TABLE "DUPLICATIONS_INDEX"( + "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), + "ANALYSIS_UUID" VARCHAR(50) NOT NULL, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "HASH" VARCHAR(50) NOT NULL, + "INDEX_IN_FILE" INTEGER NOT NULL, + "START_LINE" INTEGER NOT NULL, + "END_LINE" INTEGER NOT NULL, + "UUID" VARCHAR(40) +); +ALTER TABLE "DUPLICATIONS_INDEX" ADD CONSTRAINT "PK_DUPLICATIONS_INDEX" PRIMARY KEY("ID"); +CREATE INDEX "DUPLICATIONS_INDEX_HASH" ON "DUPLICATIONS_INDEX"("HASH"); +CREATE INDEX "DUPLICATION_ANALYSIS_COMPONENT" ON "DUPLICATIONS_INDEX"("ANALYSIS_UUID", "COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/PopulateDuplicationsIndexUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/PopulateDuplicationsIndexUuidTest/schema.sql new file mode 100644 index 00000000000..6432378da7b --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/PopulateDuplicationsIndexUuidTest/schema.sql @@ -0,0 +1,13 @@ +CREATE TABLE "DUPLICATIONS_INDEX"( + "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), + "ANALYSIS_UUID" VARCHAR(50) NOT NULL, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "HASH" VARCHAR(50) NOT NULL, + "INDEX_IN_FILE" INTEGER NOT NULL, + "START_LINE" INTEGER NOT NULL, + "END_LINE" INTEGER NOT NULL, + "UUID" VARCHAR(40) +); +ALTER TABLE "DUPLICATIONS_INDEX" ADD CONSTRAINT "PK_DUPLICATIONS_INDEX" PRIMARY KEY("ID"); +CREATE INDEX "DUPLICATIONS_INDEX_HASH" ON "DUPLICATIONS_INDEX"("HASH"); +CREATE INDEX "DUPLICATION_ANALYSIS_COMPONENT" ON "DUPLICATIONS_INDEX"("ANALYSIS_UUID", "COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/events/AddPrimaryKeyOnUuidColumnOfEventsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/events/AddPrimaryKeyOnUuidColumnOfEventsTableTest/schema.sql new file mode 100644 index 00000000000..bd6b897194c --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/events/AddPrimaryKeyOnUuidColumnOfEventsTableTest/schema.sql @@ -0,0 +1,15 @@ +CREATE TABLE "EVENTS"( + "ID" INTEGER NOT NULL, + "UUID" VARCHAR(40) NOT NULL, + "ANALYSIS_UUID" VARCHAR(50) NOT NULL, + "NAME" VARCHAR(400), + "CATEGORY" VARCHAR(50), + "DESCRIPTION" VARCHAR(4000), + "EVENT_DATA" VARCHAR(4000), + "EVENT_DATE" BIGINT NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "COMPONENT_UUID" VARCHAR(50) NOT NULL +); +CREATE UNIQUE INDEX "EVENTS_UUID" ON "EVENTS"("UUID"); +CREATE INDEX "EVENTS_ANALYSIS" ON "EVENTS"("ANALYSIS_UUID"); +CREATE INDEX "EVENTS_COMPONENT_UUID" ON "EVENTS"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/events/DropIdColumnOfEventsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/events/DropIdColumnOfEventsTableTest/schema.sql new file mode 100644 index 00000000000..ac79cfaaf79 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/events/DropIdColumnOfEventsTableTest/schema.sql @@ -0,0 +1,16 @@ +CREATE TABLE "EVENTS"( + "ID" INTEGER NOT NULL, + "UUID" VARCHAR(40) NOT NULL, + "ANALYSIS_UUID" VARCHAR(50) NOT NULL, + "NAME" VARCHAR(400), + "CATEGORY" VARCHAR(50), + "DESCRIPTION" VARCHAR(4000), + "EVENT_DATA" VARCHAR(4000), + "EVENT_DATE" BIGINT NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "COMPONENT_UUID" VARCHAR(50) NOT NULL +); +ALTER TABLE "EVENTS" ADD CONSTRAINT "PK_EVENTS" PRIMARY KEY("UUID"); +CREATE UNIQUE INDEX "EVENTS_UUID" ON "EVENTS"("UUID"); +CREATE INDEX "EVENTS_ANALYSIS" ON "EVENTS"("ANALYSIS_UUID"); +CREATE INDEX "EVENTS_COMPONENT_UUID" ON "EVENTS"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/events/DropPrimaryKeyOnIdColumnOfEventsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/events/DropPrimaryKeyOnIdColumnOfEventsTableTest/schema.sql new file mode 100644 index 00000000000..2f03d9d6661 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/events/DropPrimaryKeyOnIdColumnOfEventsTableTest/schema.sql @@ -0,0 +1,16 @@ +CREATE TABLE "EVENTS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "ANALYSIS_UUID" VARCHAR(50) NOT NULL, + "NAME" VARCHAR(400), + "CATEGORY" VARCHAR(50), + "DESCRIPTION" VARCHAR(4000), + "EVENT_DATA" VARCHAR(4000), + "EVENT_DATE" BIGINT NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "COMPONENT_UUID" VARCHAR(50) NOT NULL +); +ALTER TABLE "EVENTS" ADD CONSTRAINT "PK_EVENTS" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "EVENTS_UUID" ON "EVENTS"("UUID"); +CREATE INDEX "EVENTS_ANALYSIS" ON "EVENTS"("ANALYSIS_UUID"); +CREATE INDEX "EVENTS_COMPONENT_UUID" ON "EVENTS"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/filesources/AddPrimaryKeyOnUuidColumnOfFileSourcesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/filesources/AddPrimaryKeyOnUuidColumnOfFileSourcesTableTest/schema.sql new file mode 100644 index 00000000000..dfb2d817bc7 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/filesources/AddPrimaryKeyOnUuidColumnOfFileSourcesTableTest/schema.sql @@ -0,0 +1,18 @@ +CREATE TABLE "FILE_SOURCES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "PROJECT_UUID" VARCHAR(50) NOT NULL, + "FILE_UUID" VARCHAR(50) NOT NULL, + "LINE_HASHES" CLOB(2147483647), + "LINE_HASHES_VERSION" INTEGER, + "DATA_HASH" VARCHAR(50), + "SRC_HASH" VARCHAR(50), + "REVISION" VARCHAR(100), + "LINE_COUNT" INTEGER NOT NULL, + "BINARY_DATA" BLOB, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL +); +CREATE UNIQUE INDEX "FILE_SOURCES_FILE_UUID" ON "FILE_SOURCES"("FILE_UUID"); +CREATE INDEX "FILE_SOURCES_PROJECT_UUID" ON "FILE_SOURCES"("PROJECT_UUID"); +CREATE INDEX "FILE_SOURCES_UPDATED_AT" ON "FILE_SOURCES"("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/filesources/AddUuidColumnToFileSourcesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/filesources/AddUuidColumnToFileSourcesTableTest/schema.sql new file mode 100644 index 00000000000..179847ee2ce --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/filesources/AddUuidColumnToFileSourcesTableTest/schema.sql @@ -0,0 +1,18 @@ +CREATE TABLE "FILE_SOURCES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "PROJECT_UUID" VARCHAR(50) NOT NULL, + "FILE_UUID" VARCHAR(50) NOT NULL, + "LINE_HASHES" CLOB(2147483647), + "LINE_HASHES_VERSION" INTEGER, + "DATA_HASH" VARCHAR(50), + "SRC_HASH" VARCHAR(50), + "REVISION" VARCHAR(100), + "LINE_COUNT" INTEGER NOT NULL, + "BINARY_DATA" BLOB, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL +); +ALTER TABLE "FILE_SOURCES" ADD CONSTRAINT "PK_FILE_SOURCES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "FILE_SOURCES_FILE_UUID" ON "FILE_SOURCES"("FILE_UUID"); +CREATE INDEX "FILE_SOURCES_PROJECT_UUID" ON "FILE_SOURCES"("PROJECT_UUID"); +CREATE INDEX "FILE_SOURCES_UPDATED_AT" ON "FILE_SOURCES"("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/filesources/DropIdColumnOfFileSourcesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/filesources/DropIdColumnOfFileSourcesTableTest/schema.sql new file mode 100644 index 00000000000..3dab0132b33 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/filesources/DropIdColumnOfFileSourcesTableTest/schema.sql @@ -0,0 +1,19 @@ +CREATE TABLE "FILE_SOURCES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "PROJECT_UUID" VARCHAR(50) NOT NULL, + "FILE_UUID" VARCHAR(50) NOT NULL, + "LINE_HASHES" CLOB(2147483647), + "LINE_HASHES_VERSION" INTEGER, + "DATA_HASH" VARCHAR(50), + "SRC_HASH" VARCHAR(50), + "REVISION" VARCHAR(100), + "LINE_COUNT" INTEGER NOT NULL, + "BINARY_DATA" BLOB, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL +); +ALTER TABLE "FILE_SOURCES" ADD CONSTRAINT "PK_FILE_SOURCES" PRIMARY KEY("UUID"); +CREATE UNIQUE INDEX "FILE_SOURCES_FILE_UUID" ON "FILE_SOURCES"("FILE_UUID"); +CREATE INDEX "FILE_SOURCES_PROJECT_UUID" ON "FILE_SOURCES"("PROJECT_UUID"); +CREATE INDEX "FILE_SOURCES_UPDATED_AT" ON "FILE_SOURCES"("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/filesources/DropPrimaryKeyOnIdColumnOfFileSourcesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/filesources/DropPrimaryKeyOnIdColumnOfFileSourcesTableTest/schema.sql new file mode 100644 index 00000000000..a6a2a841f83 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/filesources/DropPrimaryKeyOnIdColumnOfFileSourcesTableTest/schema.sql @@ -0,0 +1,19 @@ +CREATE TABLE "FILE_SOURCES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "PROJECT_UUID" VARCHAR(50) NOT NULL, + "FILE_UUID" VARCHAR(50) NOT NULL, + "LINE_HASHES" CLOB(2147483647), + "LINE_HASHES_VERSION" INTEGER, + "DATA_HASH" VARCHAR(50), + "SRC_HASH" VARCHAR(50), + "REVISION" VARCHAR(100), + "LINE_COUNT" INTEGER NOT NULL, + "BINARY_DATA" BLOB, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL +); +ALTER TABLE "FILE_SOURCES" ADD CONSTRAINT "PK_FILE_SOURCES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "FILE_SOURCES_FILE_UUID" ON "FILE_SOURCES"("FILE_UUID"); +CREATE INDEX "FILE_SOURCES_PROJECT_UUID" ON "FILE_SOURCES"("PROJECT_UUID"); +CREATE INDEX "FILE_SOURCES_UPDATED_AT" ON "FILE_SOURCES"("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/filesources/MakeFileSourcesUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/filesources/MakeFileSourcesUuidColumnNotNullableTest/schema.sql new file mode 100644 index 00000000000..559418594f8 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/filesources/MakeFileSourcesUuidColumnNotNullableTest/schema.sql @@ -0,0 +1,19 @@ +CREATE TABLE "FILE_SOURCES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40), + "PROJECT_UUID" VARCHAR(50) NOT NULL, + "FILE_UUID" VARCHAR(50) NOT NULL, + "LINE_HASHES" CLOB(2147483647), + "LINE_HASHES_VERSION" INTEGER, + "DATA_HASH" VARCHAR(50), + "SRC_HASH" VARCHAR(50), + "REVISION" VARCHAR(100), + "LINE_COUNT" INTEGER NOT NULL, + "BINARY_DATA" BLOB, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL +); +ALTER TABLE "FILE_SOURCES" ADD CONSTRAINT "PK_FILE_SOURCES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "FILE_SOURCES_FILE_UUID" ON "FILE_SOURCES"("FILE_UUID"); +CREATE INDEX "FILE_SOURCES_PROJECT_UUID" ON "FILE_SOURCES"("PROJECT_UUID"); +CREATE INDEX "FILE_SOURCES_UPDATED_AT" ON "FILE_SOURCES"("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/filesources/PopulateFileSourcesUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/filesources/PopulateFileSourcesUuidTest/schema.sql new file mode 100644 index 00000000000..559418594f8 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/filesources/PopulateFileSourcesUuidTest/schema.sql @@ -0,0 +1,19 @@ +CREATE TABLE "FILE_SOURCES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40), + "PROJECT_UUID" VARCHAR(50) NOT NULL, + "FILE_UUID" VARCHAR(50) NOT NULL, + "LINE_HASHES" CLOB(2147483647), + "LINE_HASHES_VERSION" INTEGER, + "DATA_HASH" VARCHAR(50), + "SRC_HASH" VARCHAR(50), + "REVISION" VARCHAR(100), + "LINE_COUNT" INTEGER NOT NULL, + "BINARY_DATA" BLOB, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL +); +ALTER TABLE "FILE_SOURCES" ADD CONSTRAINT "PK_FILE_SOURCES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "FILE_SOURCES_FILE_UUID" ON "FILE_SOURCES"("FILE_UUID"); +CREATE INDEX "FILE_SOURCES_PROJECT_UUID" ON "FILE_SOURCES"("PROJECT_UUID"); +CREATE INDEX "FILE_SOURCES_UPDATED_AT" ON "FILE_SOURCES"("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/grouproles/AddPrimaryKeyOnUuidColumnOfGroupRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/grouproles/AddPrimaryKeyOnUuidColumnOfGroupRolesTableTest/schema.sql new file mode 100644 index 00000000000..3203c1421d1 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/grouproles/AddPrimaryKeyOnUuidColumnOfGroupRolesTableTest/schema.sql @@ -0,0 +1,11 @@ +CREATE TABLE "GROUP_ROLES"( + "ID" INTEGER NOT NULL, + "UUID" VARCHAR(40) NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "GROUP_ID" INTEGER, + "ROLE" VARCHAR(64) NOT NULL, + "COMPONENT_UUID" VARCHAR(40) +); + +CREATE INDEX "GROUP_ROLES_COMPONENT_UUID" ON "GROUP_ROLES"("COMPONENT_UUID"); +CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES"("ORGANIZATION_UUID", "GROUP_ID", "COMPONENT_UUID", "ROLE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/grouproles/AddUuidColumnToGroupRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/grouproles/AddUuidColumnToGroupRolesTableTest/schema.sql new file mode 100644 index 00000000000..b91324d4572 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/grouproles/AddUuidColumnToGroupRolesTableTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "GROUP_ROLES"( + "ID" INTEGER NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "GROUP_ID" INTEGER, + "ROLE" VARCHAR(64) NOT NULL, + "COMPONENT_UUID" VARCHAR(40) +); +ALTER TABLE "GROUP_ROLES" ADD CONSTRAINT "PK_GROUP_ROLES" PRIMARY KEY("ID"); +CREATE INDEX "GROUP_ROLES_COMPONENT_UUID" ON "GROUP_ROLES"("COMPONENT_UUID"); +CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES"("ORGANIZATION_UUID", "GROUP_ID", "COMPONENT_UUID", "ROLE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/grouproles/DropIdColumnOfGroupRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/grouproles/DropIdColumnOfGroupRolesTableTest/schema.sql new file mode 100644 index 00000000000..7ecca2b6b71 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/grouproles/DropIdColumnOfGroupRolesTableTest/schema.sql @@ -0,0 +1,11 @@ +CREATE TABLE "GROUP_ROLES"( + "ID" INTEGER NOT NULL, + "UUID" VARCHAR(40) NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "GROUP_ID" INTEGER, + "ROLE" VARCHAR(64) NOT NULL, + "COMPONENT_UUID" VARCHAR(40) +); +ALTER TABLE "GROUP_ROLES" ADD CONSTRAINT "PK_GROUP_ROLES" PRIMARY KEY("UUID"); +CREATE INDEX "GROUP_ROLES_COMPONENT_UUID" ON "GROUP_ROLES"("COMPONENT_UUID"); +CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES"("ORGANIZATION_UUID", "GROUP_ID", "COMPONENT_UUID", "ROLE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/grouproles/DropPrimaryKeyOnIdColumnOfGroupRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/grouproles/DropPrimaryKeyOnIdColumnOfGroupRolesTableTest/schema.sql new file mode 100644 index 00000000000..d7d1320aebe --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/grouproles/DropPrimaryKeyOnIdColumnOfGroupRolesTableTest/schema.sql @@ -0,0 +1,11 @@ +CREATE TABLE "GROUP_ROLES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "GROUP_ID" INTEGER, + "ROLE" VARCHAR(64) NOT NULL, + "COMPONENT_UUID" VARCHAR(40) +); +ALTER TABLE "GROUP_ROLES" ADD CONSTRAINT "PK_GROUP_ROLES" PRIMARY KEY("ID"); +CREATE INDEX "GROUP_ROLES_COMPONENT_UUID" ON "GROUP_ROLES"("COMPONENT_UUID"); +CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES"("ORGANIZATION_UUID", "GROUP_ID", "COMPONENT_UUID", "ROLE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/grouproles/MakeGroupRolesUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/grouproles/MakeGroupRolesUuidColumnNotNullableTest/schema.sql new file mode 100644 index 00000000000..7c73be272fd --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/grouproles/MakeGroupRolesUuidColumnNotNullableTest/schema.sql @@ -0,0 +1,11 @@ +CREATE TABLE "GROUP_ROLES"( + "ID" INTEGER NOT NULL, + "UUID" VARCHAR(40), + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "GROUP_ID" INTEGER, + "ROLE" VARCHAR(64) NOT NULL, + "COMPONENT_UUID" VARCHAR(40) +); +ALTER TABLE "GROUP_ROLES" ADD CONSTRAINT "PK_GROUP_ROLES" PRIMARY KEY("ID"); +CREATE INDEX "GROUP_ROLES_COMPONENT_UUID" ON "GROUP_ROLES"("COMPONENT_UUID"); +CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES"("ORGANIZATION_UUID", "GROUP_ID", "COMPONENT_UUID", "ROLE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/grouproles/PopulateGroupRolesUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/grouproles/PopulateGroupRolesUuidTest/schema.sql new file mode 100644 index 00000000000..7c73be272fd --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/grouproles/PopulateGroupRolesUuidTest/schema.sql @@ -0,0 +1,11 @@ +CREATE TABLE "GROUP_ROLES"( + "ID" INTEGER NOT NULL, + "UUID" VARCHAR(40), + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "GROUP_ID" INTEGER, + "ROLE" VARCHAR(64) NOT NULL, + "COMPONENT_UUID" VARCHAR(40) +); +ALTER TABLE "GROUP_ROLES" ADD CONSTRAINT "PK_GROUP_ROLES" PRIMARY KEY("ID"); +CREATE INDEX "GROUP_ROLES_COMPONENT_UUID" ON "GROUP_ROLES"("COMPONENT_UUID"); +CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES"("ORGANIZATION_UUID", "GROUP_ID", "COMPONENT_UUID", "ROLE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/AddPrimaryKeyOnUuidColumnOfGroupsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/AddPrimaryKeyOnUuidColumnOfGroupsTableTest/schema.sql new file mode 100644 index 00000000000..8b2000be3e9 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/AddPrimaryKeyOnUuidColumnOfGroupsTableTest/schema.sql @@ -0,0 +1,9 @@ +CREATE TABLE "GROUPS"( + "ID" INTEGER NOT NULL, + "UUID" VARCHAR(40) NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(500), + "DESCRIPTION" VARCHAR(200), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/AddUuidColumnToGroupsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/AddUuidColumnToGroupsTableTest/schema.sql new file mode 100644 index 00000000000..a20ddd6ac66 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/AddUuidColumnToGroupsTableTest/schema.sql @@ -0,0 +1,9 @@ +CREATE TABLE "GROUPS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(500), + "DESCRIPTION" VARCHAR(200), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "GROUPS" ADD CONSTRAINT "PK_GROUPS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/DropIdColumnOfGroupsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/DropIdColumnOfGroupsTableTest/schema.sql new file mode 100644 index 00000000000..963af911d8a --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/DropIdColumnOfGroupsTableTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "GROUPS"( + "ID" INTEGER NOT NULL, + "UUID" VARCHAR(40) NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(500), + "DESCRIPTION" VARCHAR(200), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "GROUPS" ADD CONSTRAINT "PK_GROUPS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/DropPrimaryKeyOnIdColumnOfGroupsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/DropPrimaryKeyOnIdColumnOfGroupsTableTest/schema.sql new file mode 100644 index 00000000000..3b127b99e7a --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/DropPrimaryKeyOnIdColumnOfGroupsTableTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "GROUPS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(500), + "DESCRIPTION" VARCHAR(200), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "GROUPS" ADD CONSTRAINT "PK_GROUPS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/MakeGroupsUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/MakeGroupsUuidColumnNotNullableTest/schema.sql new file mode 100644 index 00000000000..5c6c10fce76 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/MakeGroupsUuidColumnNotNullableTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "GROUPS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40), + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(500), + "DESCRIPTION" VARCHAR(200), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "GROUPS" ADD CONSTRAINT "PK_GROUPS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/PopulateGroupsUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/PopulateGroupsUuidTest/schema.sql new file mode 100644 index 00000000000..5c6c10fce76 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/PopulateGroupsUuidTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "GROUPS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40), + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(500), + "DESCRIPTION" VARCHAR(200), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "GROUPS" ADD CONSTRAINT "PK_GROUPS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/AddGroupUuidColumnToGroupRolesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/AddGroupUuidColumnToGroupRolesTest/schema.sql new file mode 100644 index 00000000000..3395ab556f2 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/AddGroupUuidColumnToGroupRolesTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "GROUP_ROLES"( + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "GROUP_ID" INTEGER, + "ROLE" VARCHAR(64) NOT NULL, + "COMPONENT_UUID" VARCHAR(40), + "UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "GROUP_ROLES" ADD CONSTRAINT "PK_GROUP_ROLES" PRIMARY KEY("UUID"); +CREATE INDEX "GROUP_ROLES_COMPONENT_UUID" ON "GROUP_ROLES"("COMPONENT_UUID"); +CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES"("ORGANIZATION_UUID", "GROUP_ID", "COMPONENT_UUID", "ROLE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/AddIndexOnGroupUuidOfGroupRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/AddIndexOnGroupUuidOfGroupRolesTableTest/schema.sql new file mode 100644 index 00000000000..f1f49219014 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/AddIndexOnGroupUuidOfGroupRolesTableTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "GROUP_ROLES"( + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "GROUP_ID" INTEGER, + "GROUP_UUID" VARCHAR(40) NOT NULL, + "ROLE" VARCHAR(64) NOT NULL, + "COMPONENT_UUID" VARCHAR(40), + "UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "GROUP_ROLES" ADD CONSTRAINT "PK_GROUP_ROLES" PRIMARY KEY("UUID"); +CREATE INDEX "GROUP_ROLES_COMPONENT_UUID" ON "GROUP_ROLES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/DropGroupIdColumnOfGroupRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/DropGroupIdColumnOfGroupRolesTableTest/schema.sql new file mode 100644 index 00000000000..2e809ae1a2e --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/DropGroupIdColumnOfGroupRolesTableTest/schema.sql @@ -0,0 +1,11 @@ +CREATE TABLE "GROUP_ROLES"( + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "GROUP_ID" INTEGER, + "GROUP_UUID" VARCHAR(40) NOT NULL, + "ROLE" VARCHAR(64) NOT NULL, + "COMPONENT_UUID" VARCHAR(40), + "UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "GROUP_ROLES" ADD CONSTRAINT "PK_GROUP_ROLES" PRIMARY KEY("UUID"); +CREATE INDEX "GROUP_ROLES_COMPONENT_UUID" ON "GROUP_ROLES"("COMPONENT_UUID"); +CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES"("ORGANIZATION_UUID", "GROUP_UUID", "COMPONENT_UUID", "ROLE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/DropIndexOnGroupIdOfGroupRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/DropIndexOnGroupIdOfGroupRolesTableTest/schema.sql new file mode 100644 index 00000000000..a17d5208a43 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/DropIndexOnGroupIdOfGroupRolesTableTest/schema.sql @@ -0,0 +1,11 @@ +CREATE TABLE "GROUP_ROLES"( + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "GROUP_ID" INTEGER, + "GROUP_UUID" VARCHAR(40) NOT NULL, + "ROLE" VARCHAR(64) NOT NULL, + "COMPONENT_UUID" VARCHAR(40), + "UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "GROUP_ROLES" ADD CONSTRAINT "PK_GROUP_ROLES" PRIMARY KEY("UUID"); +CREATE INDEX "GROUP_ROLES_COMPONENT_UUID" ON "GROUP_ROLES"("COMPONENT_UUID"); +CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES"("ORGANIZATION_UUID", "GROUP_ID", "COMPONENT_UUID", "ROLE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/PopulateGroupRolesGroupUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/PopulateGroupRolesGroupUuidTest/schema.sql new file mode 100644 index 00000000000..dbed7d09f4f --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/grouproles/PopulateGroupRolesGroupUuidTest/schema.sql @@ -0,0 +1,22 @@ +CREATE TABLE "GROUPS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(500), + "DESCRIPTION" VARCHAR(200), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "GROUPS" ADD CONSTRAINT "PK_GROUPS" PRIMARY KEY("ID"); + +CREATE TABLE "GROUP_ROLES"( + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "GROUP_ID" INTEGER, + "GROUP_UUID" VARCHAR(40), + "ROLE" VARCHAR(64) NOT NULL, + "COMPONENT_UUID" VARCHAR(40), + "UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "GROUP_ROLES" ADD CONSTRAINT "PK_GROUP_ROLES" PRIMARY KEY("UUID"); +CREATE INDEX "GROUP_ROLES_COMPONENT_UUID" ON "GROUP_ROLES"("COMPONENT_UUID"); +CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES"("ORGANIZATION_UUID", "GROUP_ID", "COMPONENT_UUID", "ROLE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/AddGroupUuidColumnToGroupsUsersTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/AddGroupUuidColumnToGroupsUsersTest/schema.sql new file mode 100644 index 00000000000..0d7bb6e917a --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/AddGroupUuidColumnToGroupsUsersTest/schema.sql @@ -0,0 +1,7 @@ +CREATE TABLE "GROUPS_USERS"( + "USER_ID" BIGINT, + "GROUP_ID" BIGINT +); +CREATE INDEX "INDEX_GROUPS_USERS_ON_USER_ID" ON "GROUPS_USERS"("USER_ID"); +CREATE INDEX "INDEX_GROUPS_USERS_ON_GROUP_ID" ON "GROUPS_USERS"("GROUP_ID"); +CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS"("GROUP_ID", "USER_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/AddIndexOnGroupUuidOfGroupsUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/AddIndexOnGroupUuidOfGroupsUsersTableTest/schema.sql new file mode 100644 index 00000000000..4f926b037ad --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/AddIndexOnGroupUuidOfGroupsUsersTableTest/schema.sql @@ -0,0 +1,6 @@ +CREATE TABLE "GROUPS_USERS"( + "USER_ID" BIGINT, + "GROUP_UUID" VARCHAR(40) NOT NULL, + "GROUP_ID" BIGINT +); +CREATE INDEX "INDEX_GROUPS_USERS_ON_USER_ID" ON "GROUPS_USERS"("USER_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/DropGroupIdColumnOfGroupsUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/DropGroupIdColumnOfGroupsUsersTableTest/schema.sql new file mode 100644 index 00000000000..6f1ef46cb30 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/DropGroupIdColumnOfGroupsUsersTableTest/schema.sql @@ -0,0 +1,8 @@ +CREATE TABLE "GROUPS_USERS"( + "USER_ID" BIGINT, + "GROUP_UUID" VARCHAR(40) NOT NULL, + "GROUP_ID" BIGINT +); +CREATE INDEX "INDEX_GROUPS_USERS_ON_USER_ID" ON "GROUPS_USERS"("USER_ID"); +CREATE INDEX "INDEX_GROUPS_USERS_GROUP_UUID" ON "GROUPS_USERS"("GROUP_UUID"); +CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS"("GROUP_UUID", "USER_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/DropIndexOnGroupIdOfGroupsUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/DropIndexOnGroupIdOfGroupsUsersTableTest/schema.sql new file mode 100644 index 00000000000..214ddd1af92 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/DropIndexOnGroupIdOfGroupsUsersTableTest/schema.sql @@ -0,0 +1,8 @@ +CREATE TABLE "GROUPS_USERS"( + "USER_ID" BIGINT, + "GROUP_UUID" VARCHAR(40) NOT NULL, + "GROUP_ID" BIGINT +); +CREATE INDEX "INDEX_GROUPS_USERS_ON_USER_ID" ON "GROUPS_USERS"("USER_ID"); +CREATE INDEX "INDEX_GROUPS_USERS_ON_GROUP_ID" ON "GROUPS_USERS"("GROUP_ID"); +CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS"("GROUP_ID", "USER_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/MakeGroupsUsersGroupUuidNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/MakeGroupsUsersGroupUuidNotNullableTest/schema.sql new file mode 100644 index 00000000000..4614b88b6f9 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/MakeGroupsUsersGroupUuidNotNullableTest/schema.sql @@ -0,0 +1,8 @@ +CREATE TABLE "GROUPS_USERS"( + "USER_ID" BIGINT, + "GROUP_UUID" VARCHAR(40), + "GROUP_ID" BIGINT +); +CREATE INDEX "INDEX_GROUPS_USERS_ON_USER_ID" ON "GROUPS_USERS"("USER_ID"); +CREATE INDEX "INDEX_GROUPS_USERS_ON_GROUP_ID" ON "GROUPS_USERS"("GROUP_ID"); +CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS"("GROUP_ID", "USER_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/PopulateGroupsUsersGroupUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/PopulateGroupsUsersGroupUuidTest/schema.sql new file mode 100644 index 00000000000..f3c7d7266a8 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/groupsusers/PopulateGroupsUsersGroupUuidTest/schema.sql @@ -0,0 +1,19 @@ +CREATE TABLE "GROUPS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(500), + "DESCRIPTION" VARCHAR(200), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "GROUPS" ADD CONSTRAINT "PK_GROUPS" PRIMARY KEY("ID"); + +CREATE TABLE "GROUPS_USERS"( + "USER_ID" BIGINT, + "GROUP_UUID" VARCHAR(40), + "GROUP_ID" BIGINT +); +CREATE INDEX "INDEX_GROUPS_USERS_ON_USER_ID" ON "GROUPS_USERS"("USER_ID"); +CREATE INDEX "INDEX_GROUPS_USERS_ON_GROUP_ID" ON "GROUPS_USERS"("GROUP_ID"); +CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS"("GROUP_ID", "USER_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/organizations/AddDefaultGroupUuidColumnToOrganizationsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/organizations/AddDefaultGroupUuidColumnToOrganizationsTest/schema.sql new file mode 100644 index 00000000000..169cf356975 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/organizations/AddDefaultGroupUuidColumnToOrganizationsTest/schema.sql @@ -0,0 +1,20 @@ +CREATE TABLE "ORGANIZATIONS"( + "UUID" VARCHAR(40) NOT NULL, + "KEE" VARCHAR(255) NOT NULL, + "NAME" VARCHAR(255) NOT NULL, + "DESCRIPTION" VARCHAR(256), + "URL" VARCHAR(256), + "AVATAR_URL" VARCHAR(256), + "GUARDED" BOOLEAN, + "DEFAULT_GROUP_ID" INTEGER, + "DEFAULT_QUALITY_GATE_UUID" VARCHAR(40) NOT NULL, + "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), + "DEFAULT_PERM_TEMPLATE_APP" VARCHAR(40), + "DEFAULT_PERM_TEMPLATE_PORT" VARCHAR(40), + "NEW_PROJECT_PRIVATE" BOOLEAN NOT NULL, + "SUBSCRIPTION" VARCHAR(40) NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL +); +ALTER TABLE "ORGANIZATIONS" ADD CONSTRAINT "PK_ORGANIZATIONS" PRIMARY KEY("UUID"); +CREATE UNIQUE INDEX "ORGANIZATION_KEY" ON "ORGANIZATIONS"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/organizations/DropDefaultGroupIdColumnOfOrganizationsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/organizations/DropDefaultGroupIdColumnOfOrganizationsTableTest/schema.sql new file mode 100644 index 00000000000..65e6acd5661 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/organizations/DropDefaultGroupIdColumnOfOrganizationsTableTest/schema.sql @@ -0,0 +1,21 @@ +CREATE TABLE "ORGANIZATIONS"( + "UUID" VARCHAR(40) NOT NULL, + "KEE" VARCHAR(255) NOT NULL, + "NAME" VARCHAR(255) NOT NULL, + "DESCRIPTION" VARCHAR(256), + "URL" VARCHAR(256), + "AVATAR_URL" VARCHAR(256), + "GUARDED" BOOLEAN, + "DEFAULT_GROUP_ID" INTEGER, + "DEFAULT_GROUP_UUID" VARCHAR(40), + "DEFAULT_QUALITY_GATE_UUID" VARCHAR(40) NOT NULL, + "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), + "DEFAULT_PERM_TEMPLATE_APP" VARCHAR(40), + "DEFAULT_PERM_TEMPLATE_PORT" VARCHAR(40), + "NEW_PROJECT_PRIVATE" BOOLEAN NOT NULL, + "SUBSCRIPTION" VARCHAR(40) NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL +); +ALTER TABLE "ORGANIZATIONS" ADD CONSTRAINT "PK_ORGANIZATIONS" PRIMARY KEY("UUID"); +CREATE UNIQUE INDEX "ORGANIZATION_KEY" ON "ORGANIZATIONS"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/organizations/PopulateOrganizationsDefaultGroupUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/organizations/PopulateOrganizationsDefaultGroupUuidTest/schema.sql new file mode 100644 index 00000000000..6ecb376b33b --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/organizations/PopulateOrganizationsDefaultGroupUuidTest/schema.sql @@ -0,0 +1,32 @@ +CREATE TABLE "GROUPS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(500), + "DESCRIPTION" VARCHAR(200), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "GROUPS" ADD CONSTRAINT "PK_GROUPS" PRIMARY KEY("ID"); + +CREATE TABLE "ORGANIZATIONS"( + "UUID" VARCHAR(40) NOT NULL, + "KEE" VARCHAR(255) NOT NULL, + "NAME" VARCHAR(255) NOT NULL, + "DESCRIPTION" VARCHAR(256), + "URL" VARCHAR(256), + "AVATAR_URL" VARCHAR(256), + "GUARDED" BOOLEAN, + "DEFAULT_GROUP_ID" INTEGER, + "DEFAULT_GROUP_UUID" VARCHAR(40), + "DEFAULT_QUALITY_GATE_UUID" VARCHAR(40) NOT NULL, + "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40), + "DEFAULT_PERM_TEMPLATE_APP" VARCHAR(40), + "DEFAULT_PERM_TEMPLATE_PORT" VARCHAR(40), + "NEW_PROJECT_PRIVATE" BOOLEAN NOT NULL, + "SUBSCRIPTION" VARCHAR(40) NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL +); +ALTER TABLE "ORGANIZATIONS" ADD CONSTRAINT "PK_ORGANIZATIONS" PRIMARY KEY("UUID"); +CREATE UNIQUE INDEX "ORGANIZATION_KEY" ON "ORGANIZATIONS"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/AddGroupUuidColumnToPermTemplatesGroupsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/AddGroupUuidColumnToPermTemplatesGroupsTest/schema.sql new file mode 100644 index 00000000000..f8f880ba7d6 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/AddGroupUuidColumnToPermTemplatesGroupsTest/schema.sql @@ -0,0 +1,9 @@ +CREATE TABLE "PERM_TEMPLATES_GROUPS"( + "GROUP_ID" INTEGER, + "TEMPLATE_ID" INTEGER NOT NULL, + "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP, + "UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "PERM_TEMPLATES_GROUPS" ADD CONSTRAINT "PK_PERM_TEMPLATES_GROUPS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/DropGroupIdColumnOfPermTemplatesGroupsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/DropGroupIdColumnOfPermTemplatesGroupsTableTest/schema.sql new file mode 100644 index 00000000000..fa92bad8669 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/DropGroupIdColumnOfPermTemplatesGroupsTableTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "PERM_TEMPLATES_GROUPS"( + "GROUP_ID" INTEGER, + "GROUP_UUID" VARCHAR(40), + "TEMPLATE_ID" INTEGER NOT NULL, + "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP, + "UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "PERM_TEMPLATES_GROUPS" ADD CONSTRAINT "PK_PERM_TEMPLATES_GROUPS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/PopulatePermTemplatesGroupsGroupUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/PopulatePermTemplatesGroupsGroupUuidTest/schema.sql new file mode 100644 index 00000000000..d7f1b662726 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/permtemplatesgroups/PopulatePermTemplatesGroupsGroupUuidTest/schema.sql @@ -0,0 +1,21 @@ +CREATE TABLE "GROUPS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(500), + "DESCRIPTION" VARCHAR(200), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "GROUPS" ADD CONSTRAINT "PK_GROUPS" PRIMARY KEY("ID"); + +CREATE TABLE "PERM_TEMPLATES_GROUPS"( + "GROUP_ID" INTEGER, + "GROUP_UUID" VARCHAR(40), + "TEMPLATE_ID" INTEGER NOT NULL, + "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP, + "UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "PERM_TEMPLATES_GROUPS" ADD CONSTRAINT "PK_PERM_TEMPLATES_GROUPS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/AddGroupUuidColumnToQProfileEditGroupsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/AddGroupUuidColumnToQProfileEditGroupsTest/schema.sql new file mode 100644 index 00000000000..b375127ef24 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/AddGroupUuidColumnToQProfileEditGroupsTest/schema.sql @@ -0,0 +1,9 @@ +CREATE TABLE "QPROFILE_EDIT_GROUPS"( + "UUID" VARCHAR(40) NOT NULL, + "GROUP_ID" INTEGER NOT NULL, + "QPROFILE_UUID" VARCHAR(255) NOT NULL, + "CREATED_AT" BIGINT NOT NULL +); +ALTER TABLE "QPROFILE_EDIT_GROUPS" ADD CONSTRAINT "PK_QPROFILE_EDIT_GROUPS" PRIMARY KEY("UUID"); +CREATE INDEX "QPROFILE_EDIT_GROUPS_QPROFILE" ON "QPROFILE_EDIT_GROUPS"("QPROFILE_UUID"); +CREATE UNIQUE INDEX "QPROFILE_EDIT_GROUPS_UNIQUE" ON "QPROFILE_EDIT_GROUPS"("GROUP_ID", "QPROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/AddIndexOnGroupUuidOfQProfileEditGroupsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/AddIndexOnGroupUuidOfQProfileEditGroupsTableTest/schema.sql new file mode 100644 index 00000000000..d7d22ae97b6 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/AddIndexOnGroupUuidOfQProfileEditGroupsTableTest/schema.sql @@ -0,0 +1,9 @@ +CREATE TABLE "QPROFILE_EDIT_GROUPS"( + "UUID" VARCHAR(40) NOT NULL, + "GROUP_ID" INTEGER NOT NULL, + "GROUP_UUID" VARCHAR(40) NOT NULL, + "QPROFILE_UUID" VARCHAR(255) NOT NULL, + "CREATED_AT" BIGINT NOT NULL +); +ALTER TABLE "QPROFILE_EDIT_GROUPS" ADD CONSTRAINT "PK_QPROFILE_EDIT_GROUPS" PRIMARY KEY("UUID"); +CREATE INDEX "QPROFILE_EDIT_GROUPS_QPROFILE" ON "QPROFILE_EDIT_GROUPS"("QPROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/DropGroupIdColumnOfQProfileEditGroupsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/DropGroupIdColumnOfQProfileEditGroupsTableTest/schema.sql new file mode 100644 index 00000000000..3a866c066ab --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/DropGroupIdColumnOfQProfileEditGroupsTableTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "QPROFILE_EDIT_GROUPS"( + "UUID" VARCHAR(40) NOT NULL, + "GROUP_ID" INTEGER NOT NULL, + "GROUP_UUID" VARCHAR(40) NOT NULL, + "QPROFILE_UUID" VARCHAR(255) NOT NULL, + "CREATED_AT" BIGINT NOT NULL +); +ALTER TABLE "QPROFILE_EDIT_GROUPS" ADD CONSTRAINT "PK_QPROFILE_EDIT_GROUPS" PRIMARY KEY("UUID"); +CREATE INDEX "QPROFILE_EDIT_GROUPS_QPROFILE" ON "QPROFILE_EDIT_GROUPS"("QPROFILE_UUID"); +CREATE UNIQUE INDEX "QPROFILE_EDIT_GROUPS_UNIQUE" ON "QPROFILE_EDIT_GROUPS"("GROUP_UUID", "QPROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/DropIndexOnGroupIdOfQProfileEditGroupsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/DropIndexOnGroupIdOfQProfileEditGroupsTableTest/schema.sql new file mode 100644 index 00000000000..e4deaa55ba0 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/DropIndexOnGroupIdOfQProfileEditGroupsTableTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "QPROFILE_EDIT_GROUPS"( + "UUID" VARCHAR(40) NOT NULL, + "GROUP_ID" INTEGER NOT NULL, + "GROUP_UUID" VARCHAR(40) NOT NULL, + "QPROFILE_UUID" VARCHAR(255) NOT NULL, + "CREATED_AT" BIGINT NOT NULL +); +ALTER TABLE "QPROFILE_EDIT_GROUPS" ADD CONSTRAINT "PK_QPROFILE_EDIT_GROUPS" PRIMARY KEY("UUID"); +CREATE INDEX "QPROFILE_EDIT_GROUPS_QPROFILE" ON "QPROFILE_EDIT_GROUPS"("QPROFILE_UUID"); +CREATE UNIQUE INDEX "QPROFILE_EDIT_GROUPS_UNIQUE" ON "QPROFILE_EDIT_GROUPS"("GROUP_ID", "QPROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/MakeQProfileEditGroupsGroupUuidNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/MakeQProfileEditGroupsGroupUuidNotNullableTest/schema.sql new file mode 100644 index 00000000000..f30b909de2e --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/MakeQProfileEditGroupsGroupUuidNotNullableTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "QPROFILE_EDIT_GROUPS"( + "UUID" VARCHAR(40) NOT NULL, + "GROUP_ID" INTEGER NOT NULL, + "GROUP_UUID" VARCHAR(40), + "QPROFILE_UUID" VARCHAR(255) NOT NULL, + "CREATED_AT" BIGINT NOT NULL +); +ALTER TABLE "QPROFILE_EDIT_GROUPS" ADD CONSTRAINT "PK_QPROFILE_EDIT_GROUPS" PRIMARY KEY("UUID"); +CREATE INDEX "QPROFILE_EDIT_GROUPS_QPROFILE" ON "QPROFILE_EDIT_GROUPS"("QPROFILE_UUID"); +CREATE UNIQUE INDEX "QPROFILE_EDIT_GROUPS_UNIQUE" ON "QPROFILE_EDIT_GROUPS"("GROUP_ID", "QPROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/PopulateQProfileEditGroupsGroupUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/PopulateQProfileEditGroupsGroupUuidTest/schema.sql new file mode 100644 index 00000000000..05b4a34f279 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/groups/qprofileeditgroups/PopulateQProfileEditGroupsGroupUuidTest/schema.sql @@ -0,0 +1,21 @@ +CREATE TABLE "GROUPS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(500), + "DESCRIPTION" VARCHAR(200), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "GROUPS" ADD CONSTRAINT "PK_GROUPS" PRIMARY KEY("ID"); + +CREATE TABLE "QPROFILE_EDIT_GROUPS"( + "UUID" VARCHAR(40) NOT NULL, + "GROUP_ID" INTEGER NOT NULL, + "GROUP_UUID" VARCHAR(40), + "QPROFILE_UUID" VARCHAR(255) NOT NULL, + "CREATED_AT" BIGINT NOT NULL +); +ALTER TABLE "QPROFILE_EDIT_GROUPS" ADD CONSTRAINT "PK_QPROFILE_EDIT_GROUPS" PRIMARY KEY("UUID"); +CREATE INDEX "QPROFILE_EDIT_GROUPS_QPROFILE" ON "QPROFILE_EDIT_GROUPS"("QPROFILE_UUID"); +CREATE UNIQUE INDEX "QPROFILE_EDIT_GROUPS_UNIQUE" ON "QPROFILE_EDIT_GROUPS"("GROUP_ID", "QPROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddPrimaryKeyOnUuidColumnOfIssueChangesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddPrimaryKeyOnUuidColumnOfIssueChangesTableTest/schema.sql new file mode 100644 index 00000000000..5b74206accb --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddPrimaryKeyOnUuidColumnOfIssueChangesTableTest/schema.sql @@ -0,0 +1,14 @@ +CREATE TABLE "ISSUE_CHANGES"( + "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "KEE" VARCHAR(50), + "ISSUE_KEY" VARCHAR(50) NOT NULL, + "USER_LOGIN" VARCHAR(255), + "CHANGE_TYPE" VARCHAR(20), + "CHANGE_DATA" CLOB(2147483647), + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "ISSUE_CHANGE_CREATION_DATE" BIGINT +); +CREATE INDEX "ISSUE_CHANGES_ISSUE_KEY" ON "ISSUE_CHANGES"("ISSUE_KEY"); +CREATE INDEX "ISSUE_CHANGES_KEE" ON "ISSUE_CHANGES"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddUuidColumnToIssueChangesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddUuidColumnToIssueChangesTableTest/schema.sql new file mode 100644 index 00000000000..6dea8cb9711 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddUuidColumnToIssueChangesTableTest/schema.sql @@ -0,0 +1,14 @@ +CREATE TABLE "ISSUE_CHANGES"( + "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), + "KEE" VARCHAR(50), + "ISSUE_KEY" VARCHAR(50) NOT NULL, + "USER_LOGIN" VARCHAR(255), + "CHANGE_TYPE" VARCHAR(20), + "CHANGE_DATA" CLOB(2147483647), + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "ISSUE_CHANGE_CREATION_DATE" BIGINT +); +ALTER TABLE "ISSUE_CHANGES" ADD CONSTRAINT "PK_ISSUE_CHANGES" PRIMARY KEY("ID"); +CREATE INDEX "ISSUE_CHANGES_ISSUE_KEY" ON "ISSUE_CHANGES"("ISSUE_KEY"); +CREATE INDEX "ISSUE_CHANGES_KEE" ON "ISSUE_CHANGES"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issuechanges/DropIdColumnOfIssueChangesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issuechanges/DropIdColumnOfIssueChangesTableTest/schema.sql new file mode 100644 index 00000000000..7b26191fc16 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issuechanges/DropIdColumnOfIssueChangesTableTest/schema.sql @@ -0,0 +1,15 @@ +CREATE TABLE "ISSUE_CHANGES"( + "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "KEE" VARCHAR(50), + "ISSUE_KEY" VARCHAR(50) NOT NULL, + "USER_LOGIN" VARCHAR(255), + "CHANGE_TYPE" VARCHAR(20), + "CHANGE_DATA" CLOB(2147483647), + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "ISSUE_CHANGE_CREATION_DATE" BIGINT +); +ALTER TABLE "ISSUE_CHANGES" ADD CONSTRAINT "PK_ISSUE_CHANGES" PRIMARY KEY("UUID"); +CREATE INDEX "ISSUE_CHANGES_ISSUE_KEY" ON "ISSUE_CHANGES"("ISSUE_KEY"); +CREATE INDEX "ISSUE_CHANGES_KEE" ON "ISSUE_CHANGES"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issuechanges/DropPrimaryKeyOnIdColumnOfIssueChangesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issuechanges/DropPrimaryKeyOnIdColumnOfIssueChangesTableTest/schema.sql new file mode 100644 index 00000000000..e19e2691124 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issuechanges/DropPrimaryKeyOnIdColumnOfIssueChangesTableTest/schema.sql @@ -0,0 +1,15 @@ +CREATE TABLE "ISSUE_CHANGES"( + "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "KEE" VARCHAR(50), + "ISSUE_KEY" VARCHAR(50) NOT NULL, + "USER_LOGIN" VARCHAR(255), + "CHANGE_TYPE" VARCHAR(20), + "CHANGE_DATA" CLOB(2147483647), + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "ISSUE_CHANGE_CREATION_DATE" BIGINT +); +ALTER TABLE "ISSUE_CHANGES" ADD CONSTRAINT "PK_ISSUE_CHANGES" PRIMARY KEY("ID"); +CREATE INDEX "ISSUE_CHANGES_ISSUE_KEY" ON "ISSUE_CHANGES"("ISSUE_KEY"); +CREATE INDEX "ISSUE_CHANGES_KEE" ON "ISSUE_CHANGES"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issuechanges/MakeIssueChangesUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issuechanges/MakeIssueChangesUuidColumnNotNullableTest/schema.sql new file mode 100644 index 00000000000..f48647de321 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issuechanges/MakeIssueChangesUuidColumnNotNullableTest/schema.sql @@ -0,0 +1,15 @@ +CREATE TABLE "ISSUE_CHANGES"( + "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40), + "KEE" VARCHAR(50), + "ISSUE_KEY" VARCHAR(50) NOT NULL, + "USER_LOGIN" VARCHAR(255), + "CHANGE_TYPE" VARCHAR(20), + "CHANGE_DATA" CLOB(2147483647), + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "ISSUE_CHANGE_CREATION_DATE" BIGINT +); +ALTER TABLE "ISSUE_CHANGES" ADD CONSTRAINT "PK_ISSUE_CHANGES" PRIMARY KEY("ID"); +CREATE INDEX "ISSUE_CHANGES_ISSUE_KEY" ON "ISSUE_CHANGES"("ISSUE_KEY"); +CREATE INDEX "ISSUE_CHANGES_KEE" ON "ISSUE_CHANGES"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issuechanges/PopulateIssueChangesUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issuechanges/PopulateIssueChangesUuidTest/schema.sql new file mode 100644 index 00000000000..f48647de321 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issuechanges/PopulateIssueChangesUuidTest/schema.sql @@ -0,0 +1,15 @@ +CREATE TABLE "ISSUE_CHANGES"( + "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40), + "KEE" VARCHAR(50), + "ISSUE_KEY" VARCHAR(50) NOT NULL, + "USER_LOGIN" VARCHAR(255), + "CHANGE_TYPE" VARCHAR(20), + "CHANGE_DATA" CLOB(2147483647), + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "ISSUE_CHANGE_CREATION_DATE" BIGINT +); +ALTER TABLE "ISSUE_CHANGES" ADD CONSTRAINT "PK_ISSUE_CHANGES" PRIMARY KEY("ID"); +CREATE INDEX "ISSUE_CHANGES_ISSUE_KEY" ON "ISSUE_CHANGES"("ISSUE_KEY"); +CREATE INDEX "ISSUE_CHANGES_KEE" ON "ISSUE_CHANGES"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issues/AddPrimaryKeyOnKeeColumnOfIssuesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issues/AddPrimaryKeyOnKeeColumnOfIssuesTableTest/schema.sql new file mode 100644 index 00000000000..c195339d1d7 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issues/AddPrimaryKeyOnKeeColumnOfIssuesTableTest/schema.sql @@ -0,0 +1,38 @@ +CREATE TABLE "ISSUES"( + "ID" BIGINT NOT NULL, + "KEE" VARCHAR(50) NOT NULL, + "RULE_ID" INTEGER, + "SEVERITY" VARCHAR(10), + "MANUAL_SEVERITY" BOOLEAN NOT NULL, + "MESSAGE" VARCHAR(4000), + "LINE" INTEGER, + "GAP" DOUBLE, + "STATUS" VARCHAR(20), + "RESOLUTION" VARCHAR(20), + "CHECKSUM" VARCHAR(1000), + "REPORTER" VARCHAR(255), + "ASSIGNEE" VARCHAR(255), + "AUTHOR_LOGIN" VARCHAR(255), + "ACTION_PLAN_KEY" VARCHAR(50), + "ISSUE_ATTRIBUTES" VARCHAR(4000), + "EFFORT" INTEGER, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "ISSUE_CREATION_DATE" BIGINT, + "ISSUE_UPDATE_DATE" BIGINT, + "ISSUE_CLOSE_DATE" BIGINT, + "TAGS" VARCHAR(4000), + "COMPONENT_UUID" VARCHAR(50), + "PROJECT_UUID" VARCHAR(50), + "LOCATIONS" BLOB, + "ISSUE_TYPE" TINYINT, + "FROM_HOTSPOT" BOOLEAN +); +CREATE INDEX "ISSUES_ASSIGNEE" ON "ISSUES"("ASSIGNEE"); +CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES"("COMPONENT_UUID"); +CREATE INDEX "ISSUES_CREATION_DATE" ON "ISSUES"("ISSUE_CREATION_DATE"); +CREATE UNIQUE INDEX "ISSUES_KEE" ON "ISSUES"("KEE"); +CREATE INDEX "ISSUES_PROJECT_UUID" ON "ISSUES"("PROJECT_UUID"); +CREATE INDEX "ISSUES_RESOLUTION" ON "ISSUES"("RESOLUTION"); +CREATE INDEX "ISSUES_RULE_ID" ON "ISSUES"("RULE_ID"); +CREATE INDEX "ISSUES_UPDATED_AT" ON "ISSUES"("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issues/DropIdColumnOfIssuesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issues/DropIdColumnOfIssuesTableTest/schema.sql new file mode 100644 index 00000000000..92fadc6580c --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issues/DropIdColumnOfIssuesTableTest/schema.sql @@ -0,0 +1,39 @@ +CREATE TABLE "ISSUES"( + "ID" BIGINT NOT NULL, + "KEE" VARCHAR(50) NOT NULL, + "RULE_ID" INTEGER, + "SEVERITY" VARCHAR(10), + "MANUAL_SEVERITY" BOOLEAN NOT NULL, + "MESSAGE" VARCHAR(4000), + "LINE" INTEGER, + "GAP" DOUBLE, + "STATUS" VARCHAR(20), + "RESOLUTION" VARCHAR(20), + "CHECKSUM" VARCHAR(1000), + "REPORTER" VARCHAR(255), + "ASSIGNEE" VARCHAR(255), + "AUTHOR_LOGIN" VARCHAR(255), + "ACTION_PLAN_KEY" VARCHAR(50), + "ISSUE_ATTRIBUTES" VARCHAR(4000), + "EFFORT" INTEGER, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "ISSUE_CREATION_DATE" BIGINT, + "ISSUE_UPDATE_DATE" BIGINT, + "ISSUE_CLOSE_DATE" BIGINT, + "TAGS" VARCHAR(4000), + "COMPONENT_UUID" VARCHAR(50), + "PROJECT_UUID" VARCHAR(50), + "LOCATIONS" BLOB, + "ISSUE_TYPE" TINYINT, + "FROM_HOTSPOT" BOOLEAN +); +ALTER TABLE "ISSUES" ADD CONSTRAINT "PK_ISSUES" PRIMARY KEY("KEE"); +CREATE INDEX "ISSUES_ASSIGNEE" ON "ISSUES"("ASSIGNEE"); +CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES"("COMPONENT_UUID"); +CREATE INDEX "ISSUES_CREATION_DATE" ON "ISSUES"("ISSUE_CREATION_DATE"); +CREATE UNIQUE INDEX "ISSUES_KEE" ON "ISSUES"("KEE"); +CREATE INDEX "ISSUES_PROJECT_UUID" ON "ISSUES"("PROJECT_UUID"); +CREATE INDEX "ISSUES_RESOLUTION" ON "ISSUES"("RESOLUTION"); +CREATE INDEX "ISSUES_RULE_ID" ON "ISSUES"("RULE_ID"); +CREATE INDEX "ISSUES_UPDATED_AT" ON "ISSUES"("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issues/DropPrimaryKeyOnIdColumnOfIssuesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issues/DropPrimaryKeyOnIdColumnOfIssuesTableTest/schema.sql new file mode 100644 index 00000000000..cf65bc42c84 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/issues/DropPrimaryKeyOnIdColumnOfIssuesTableTest/schema.sql @@ -0,0 +1,39 @@ +CREATE TABLE "ISSUES"( + "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), + "KEE" VARCHAR(50) NOT NULL, + "RULE_ID" INTEGER, + "SEVERITY" VARCHAR(10), + "MANUAL_SEVERITY" BOOLEAN NOT NULL, + "MESSAGE" VARCHAR(4000), + "LINE" INTEGER, + "GAP" DOUBLE, + "STATUS" VARCHAR(20), + "RESOLUTION" VARCHAR(20), + "CHECKSUM" VARCHAR(1000), + "REPORTER" VARCHAR(255), + "ASSIGNEE" VARCHAR(255), + "AUTHOR_LOGIN" VARCHAR(255), + "ACTION_PLAN_KEY" VARCHAR(50), + "ISSUE_ATTRIBUTES" VARCHAR(4000), + "EFFORT" INTEGER, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "ISSUE_CREATION_DATE" BIGINT, + "ISSUE_UPDATE_DATE" BIGINT, + "ISSUE_CLOSE_DATE" BIGINT, + "TAGS" VARCHAR(4000), + "COMPONENT_UUID" VARCHAR(50), + "PROJECT_UUID" VARCHAR(50), + "LOCATIONS" BLOB, + "ISSUE_TYPE" TINYINT, + "FROM_HOTSPOT" BOOLEAN +); +ALTER TABLE "ISSUES" ADD CONSTRAINT "PK_ISSUES" PRIMARY KEY("ID"); +CREATE INDEX "ISSUES_ASSIGNEE" ON "ISSUES"("ASSIGNEE"); +CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES"("COMPONENT_UUID"); +CREATE INDEX "ISSUES_CREATION_DATE" ON "ISSUES"("ISSUE_CREATION_DATE"); +CREATE UNIQUE INDEX "ISSUES_KEE" ON "ISSUES"("KEE"); +CREATE INDEX "ISSUES_PROJECT_UUID" ON "ISSUES"("PROJECT_UUID"); +CREATE INDEX "ISSUES_RESOLUTION" ON "ISSUES"("RESOLUTION"); +CREATE INDEX "ISSUES_RULE_ID" ON "ISSUES"("RULE_ID"); +CREATE INDEX "ISSUES_UPDATED_AT" ON "ISSUES"("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddPrimaryKeyOnUuidColumnOfManualMeasureTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddPrimaryKeyOnUuidColumnOfManualMeasureTableTest/schema.sql new file mode 100644 index 00000000000..d1048130fdd --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddPrimaryKeyOnUuidColumnOfManualMeasureTableTest/schema.sql @@ -0,0 +1,13 @@ +CREATE TABLE "MANUAL_MEASURES"( + "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), + "METRIC_ID" INTEGER NOT NULL, + "VALUE" DOUBLE, + "TEXT_VALUE" VARCHAR(4000), + "USER_UUID" VARCHAR(255), + "DESCRIPTION" VARCHAR(4000), + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "UUID" VARCHAR(40) NOT NULL +); +CREATE INDEX "MANUAL_MEASURES_COMPONENT_UUID" ON "MANUAL_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddUuidToManualMeasuresTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddUuidToManualMeasuresTest/schema.sql new file mode 100644 index 00000000000..91889223c63 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddUuidToManualMeasuresTest/schema.sql @@ -0,0 +1,13 @@ +CREATE TABLE "MANUAL_MEASURES"( + "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), + "METRIC_ID" INTEGER NOT NULL, + "VALUE" DOUBLE, + "TEXT_VALUE" VARCHAR(4000), + "USER_UUID" VARCHAR(255), + "DESCRIPTION" VARCHAR(4000), + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "COMPONENT_UUID" VARCHAR(50) NOT NULL +); +ALTER TABLE "MANUAL_MEASURES" ADD CONSTRAINT "PK_MANUAL_MEASURES" PRIMARY KEY("ID"); +CREATE INDEX "MANUAL_MEASURES_COMPONENT_UUID" ON "MANUAL_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropIdColumnOfManualMeasuresTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropIdColumnOfManualMeasuresTableTest/schema.sql new file mode 100644 index 00000000000..d1048130fdd --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropIdColumnOfManualMeasuresTableTest/schema.sql @@ -0,0 +1,13 @@ +CREATE TABLE "MANUAL_MEASURES"( + "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), + "METRIC_ID" INTEGER NOT NULL, + "VALUE" DOUBLE, + "TEXT_VALUE" VARCHAR(4000), + "USER_UUID" VARCHAR(255), + "DESCRIPTION" VARCHAR(4000), + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "UUID" VARCHAR(40) NOT NULL +); +CREATE INDEX "MANUAL_MEASURES_COMPONENT_UUID" ON "MANUAL_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropPrimaryKeyOnIdColumnOfManualMeasuresTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropPrimaryKeyOnIdColumnOfManualMeasuresTableTest/schema.sql new file mode 100644 index 00000000000..dae762bdba3 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropPrimaryKeyOnIdColumnOfManualMeasuresTableTest/schema.sql @@ -0,0 +1,14 @@ +CREATE TABLE "MANUAL_MEASURES"( + "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), + "METRIC_ID" INTEGER NOT NULL, + "VALUE" DOUBLE, + "TEXT_VALUE" VARCHAR(4000), + "USER_UUID" VARCHAR(255), + "DESCRIPTION" VARCHAR(4000), + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "MANUAL_MEASURES" ADD CONSTRAINT "PK_MANUAL_MEASURES" PRIMARY KEY("ID"); +CREATE INDEX "MANUAL_MEASURES_COMPONENT_UUID" ON "MANUAL_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/manualmeasures/MakeManualMeasuresUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/manualmeasures/MakeManualMeasuresUuidColumnNotNullableTest/schema.sql new file mode 100644 index 00000000000..c9ff15f330d --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/manualmeasures/MakeManualMeasuresUuidColumnNotNullableTest/schema.sql @@ -0,0 +1,14 @@ +CREATE TABLE "MANUAL_MEASURES"( + "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), + "METRIC_ID" INTEGER NOT NULL, + "VALUE" DOUBLE, + "TEXT_VALUE" VARCHAR(4000), + "USER_UUID" VARCHAR(255), + "DESCRIPTION" VARCHAR(4000), + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "UUID" VARCHAR(40) +); +ALTER TABLE "MANUAL_MEASURES" ADD CONSTRAINT "PK_MANUAL_MEASURES" PRIMARY KEY("ID"); +CREATE INDEX "MANUAL_MEASURES_COMPONENT_UUID" ON "MANUAL_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/manualmeasures/PopulateManualMeasuresUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/manualmeasures/PopulateManualMeasuresUuidTest/schema.sql new file mode 100644 index 00000000000..c9ff15f330d --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/manualmeasures/PopulateManualMeasuresUuidTest/schema.sql @@ -0,0 +1,14 @@ +CREATE TABLE "MANUAL_MEASURES"( + "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), + "METRIC_ID" INTEGER NOT NULL, + "VALUE" DOUBLE, + "TEXT_VALUE" VARCHAR(4000), + "USER_UUID" VARCHAR(255), + "DESCRIPTION" VARCHAR(4000), + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "UUID" VARCHAR(40) +); +ALTER TABLE "MANUAL_MEASURES" ADD CONSTRAINT "PK_MANUAL_MEASURES" PRIMARY KEY("ID"); +CREATE INDEX "MANUAL_MEASURES_COMPONENT_UUID" ON "MANUAL_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/AddPrimaryKeyOnUuidColumnOfMetricsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/AddPrimaryKeyOnUuidColumnOfMetricsTableTest/schema.sql new file mode 100644 index 00000000000..51a7ed18a25 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/AddPrimaryKeyOnUuidColumnOfMetricsTableTest/schema.sql @@ -0,0 +1,20 @@ +CREATE TABLE "METRICS"( + "ID" INTEGER NOT NULL, + "UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(64) NOT NULL, + "DESCRIPTION" VARCHAR(255), + "DIRECTION" INTEGER DEFAULT 0 NOT NULL, + "DOMAIN" VARCHAR(64), + "SHORT_NAME" VARCHAR(64), + "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, + "VAL_TYPE" VARCHAR(8), + "USER_MANAGED" BOOLEAN DEFAULT FALSE, + "ENABLED" BOOLEAN DEFAULT TRUE, + "WORST_VALUE" DOUBLE, + "BEST_VALUE" DOUBLE, + "OPTIMIZED_BEST_VALUE" BOOLEAN, + "HIDDEN" BOOLEAN, + "DELETE_HISTORICAL_DATA" BOOLEAN, + "DECIMAL_SCALE" INTEGER +); +CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/AddUuidColumnToMetricsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/AddUuidColumnToMetricsTableTest/schema.sql new file mode 100644 index 00000000000..8ca314830d2 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/AddUuidColumnToMetricsTableTest/schema.sql @@ -0,0 +1,20 @@ +CREATE TABLE "METRICS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "NAME" VARCHAR(64) NOT NULL, + "DESCRIPTION" VARCHAR(255), + "DIRECTION" INTEGER DEFAULT 0 NOT NULL, + "DOMAIN" VARCHAR(64), + "SHORT_NAME" VARCHAR(64), + "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, + "VAL_TYPE" VARCHAR(8), + "USER_MANAGED" BOOLEAN DEFAULT FALSE, + "ENABLED" BOOLEAN DEFAULT TRUE, + "WORST_VALUE" DOUBLE, + "BEST_VALUE" DOUBLE, + "OPTIMIZED_BEST_VALUE" BOOLEAN, + "HIDDEN" BOOLEAN, + "DELETE_HISTORICAL_DATA" BOOLEAN, + "DECIMAL_SCALE" INTEGER +); +ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/DropIdColumnOfMetricsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/DropIdColumnOfMetricsTableTest/schema.sql new file mode 100644 index 00000000000..cc5c53aec36 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/DropIdColumnOfMetricsTableTest/schema.sql @@ -0,0 +1,21 @@ +CREATE TABLE "METRICS"( + "ID" INTEGER NOT NULL, + "UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(64) NOT NULL, + "DESCRIPTION" VARCHAR(255), + "DIRECTION" INTEGER DEFAULT 0 NOT NULL, + "DOMAIN" VARCHAR(64), + "SHORT_NAME" VARCHAR(64), + "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, + "VAL_TYPE" VARCHAR(8), + "USER_MANAGED" BOOLEAN DEFAULT FALSE, + "ENABLED" BOOLEAN DEFAULT TRUE, + "WORST_VALUE" DOUBLE, + "BEST_VALUE" DOUBLE, + "OPTIMIZED_BEST_VALUE" BOOLEAN, + "HIDDEN" BOOLEAN, + "DELETE_HISTORICAL_DATA" BOOLEAN, + "DECIMAL_SCALE" INTEGER +); +ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("UUID"); +CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/DropPrimaryKeyOnIdColumnOfMetricsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/DropPrimaryKeyOnIdColumnOfMetricsTableTest/schema.sql new file mode 100644 index 00000000000..a5940e9702e --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/DropPrimaryKeyOnIdColumnOfMetricsTableTest/schema.sql @@ -0,0 +1,21 @@ +CREATE TABLE "METRICS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(64) NOT NULL, + "DESCRIPTION" VARCHAR(255), + "DIRECTION" INTEGER DEFAULT 0 NOT NULL, + "DOMAIN" VARCHAR(64), + "SHORT_NAME" VARCHAR(64), + "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, + "VAL_TYPE" VARCHAR(8), + "USER_MANAGED" BOOLEAN DEFAULT FALSE, + "ENABLED" BOOLEAN DEFAULT TRUE, + "WORST_VALUE" DOUBLE, + "BEST_VALUE" DOUBLE, + "OPTIMIZED_BEST_VALUE" BOOLEAN, + "HIDDEN" BOOLEAN, + "DELETE_HISTORICAL_DATA" BOOLEAN, + "DECIMAL_SCALE" INTEGER +); +ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/MakeMetricsUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/MakeMetricsUuidColumnNotNullableTest/schema.sql new file mode 100644 index 00000000000..5e215f6a7a9 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/MakeMetricsUuidColumnNotNullableTest/schema.sql @@ -0,0 +1,21 @@ +CREATE TABLE "METRICS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40), + "NAME" VARCHAR(64) NOT NULL, + "DESCRIPTION" VARCHAR(255), + "DIRECTION" INTEGER DEFAULT 0 NOT NULL, + "DOMAIN" VARCHAR(64), + "SHORT_NAME" VARCHAR(64), + "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, + "VAL_TYPE" VARCHAR(8), + "USER_MANAGED" BOOLEAN DEFAULT FALSE, + "ENABLED" BOOLEAN DEFAULT TRUE, + "WORST_VALUE" DOUBLE, + "BEST_VALUE" DOUBLE, + "OPTIMIZED_BEST_VALUE" BOOLEAN, + "HIDDEN" BOOLEAN, + "DELETE_HISTORICAL_DATA" BOOLEAN, + "DECIMAL_SCALE" INTEGER +); +ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/PopulateMetricsUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/PopulateMetricsUuidTest/schema.sql new file mode 100644 index 00000000000..5e215f6a7a9 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/PopulateMetricsUuidTest/schema.sql @@ -0,0 +1,21 @@ +CREATE TABLE "METRICS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40), + "NAME" VARCHAR(64) NOT NULL, + "DESCRIPTION" VARCHAR(255), + "DIRECTION" INTEGER DEFAULT 0 NOT NULL, + "DOMAIN" VARCHAR(64), + "SHORT_NAME" VARCHAR(64), + "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, + "VAL_TYPE" VARCHAR(8), + "USER_MANAGED" BOOLEAN DEFAULT FALSE, + "ENABLED" BOOLEAN DEFAULT TRUE, + "WORST_VALUE" DOUBLE, + "BEST_VALUE" DOUBLE, + "OPTIMIZED_BEST_VALUE" BOOLEAN, + "HIDDEN" BOOLEAN, + "DELETE_HISTORICAL_DATA" BOOLEAN, + "DECIMAL_SCALE" INTEGER +); +ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddIndexOnMetricUuidOfLiveMeasuresTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddIndexOnMetricUuidOfLiveMeasuresTableTest/schema.sql new file mode 100644 index 00000000000..b624715d6c6 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddIndexOnMetricUuidOfLiveMeasuresTableTest/schema.sql @@ -0,0 +1,16 @@ +CREATE TABLE "LIVE_MEASURES"( + "UUID" VARCHAR(40) NOT NULL, + "PROJECT_UUID" VARCHAR(50) NOT NULL, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "METRIC_ID" INTEGER NOT NULL, + "METRIC_UUID" VARCHAR NOT NULL, + "VALUE" DOUBLE, + "TEXT_VALUE" VARCHAR(4000), + "VARIATION" DOUBLE, + "MEASURE_DATA" BLOB, + "UPDATE_MARKER" VARCHAR(40), + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL +); +ALTER TABLE "LIVE_MEASURES" ADD CONSTRAINT "PK_LIVE_MEASURES" PRIMARY KEY("UUID"); +CREATE INDEX "LIVE_MEASURES_PROJECT" ON "LIVE_MEASURES"("PROJECT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddMetricUuidColumnToLiveMeasuresTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddMetricUuidColumnToLiveMeasuresTest/schema.sql new file mode 100644 index 00000000000..e969dd3add3 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddMetricUuidColumnToLiveMeasuresTest/schema.sql @@ -0,0 +1,16 @@ +CREATE TABLE "LIVE_MEASURES"( + "UUID" VARCHAR(40) NOT NULL, + "PROJECT_UUID" VARCHAR(50) NOT NULL, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "METRIC_ID" INTEGER NOT NULL, + "VALUE" DOUBLE, + "TEXT_VALUE" VARCHAR(4000), + "VARIATION" DOUBLE, + "MEASURE_DATA" BLOB, + "UPDATE_MARKER" VARCHAR(40), + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL +); +ALTER TABLE "LIVE_MEASURES" ADD CONSTRAINT "PK_LIVE_MEASURES" PRIMARY KEY("UUID"); +CREATE INDEX "LIVE_MEASURES_PROJECT" ON "LIVE_MEASURES"("PROJECT_UUID"); +CREATE UNIQUE INDEX "LIVE_MEASURES_COMPONENT" ON "LIVE_MEASURES"("COMPONENT_UUID", "METRIC_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/DropIndexOnMetricIdOfLiveMeasuresTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/DropIndexOnMetricIdOfLiveMeasuresTableTest/schema.sql new file mode 100644 index 00000000000..79dd9a63064 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/DropIndexOnMetricIdOfLiveMeasuresTableTest/schema.sql @@ -0,0 +1,17 @@ +CREATE TABLE "LIVE_MEASURES"( + "UUID" VARCHAR(40) NOT NULL, + "PROJECT_UUID" VARCHAR(50) NOT NULL, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "METRIC_ID" INTEGER NOT NULL, + "METRIC_UUID" VARCHAR NOT NULL, + "VALUE" DOUBLE, + "TEXT_VALUE" VARCHAR(4000), + "VARIATION" DOUBLE, + "MEASURE_DATA" BLOB, + "UPDATE_MARKER" VARCHAR(40), + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL +); +ALTER TABLE "LIVE_MEASURES" ADD CONSTRAINT "PK_LIVE_MEASURES" PRIMARY KEY("UUID"); +CREATE INDEX "LIVE_MEASURES_PROJECT" ON "LIVE_MEASURES"("PROJECT_UUID"); +CREATE UNIQUE INDEX "LIVE_MEASURES_COMPONENT" ON "LIVE_MEASURES"("COMPONENT_UUID", "METRIC_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/DropMetricIdColumnOfLiveMeasuresTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/DropMetricIdColumnOfLiveMeasuresTableTest/schema.sql new file mode 100644 index 00000000000..5b750f3ece5 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/DropMetricIdColumnOfLiveMeasuresTableTest/schema.sql @@ -0,0 +1,17 @@ +CREATE TABLE "LIVE_MEASURES"( + "UUID" VARCHAR(40) NOT NULL, + "PROJECT_UUID" VARCHAR(50) NOT NULL, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "METRIC_ID" INTEGER NOT NULL, + "METRIC_UUID" VARCHAR NOT NULL, + "VALUE" DOUBLE, + "TEXT_VALUE" VARCHAR(4000), + "VARIATION" DOUBLE, + "MEASURE_DATA" BLOB, + "UPDATE_MARKER" VARCHAR(40), + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL +); +ALTER TABLE "LIVE_MEASURES" ADD CONSTRAINT "PK_LIVE_MEASURES" PRIMARY KEY("UUID"); +CREATE INDEX "LIVE_MEASURES_PROJECT" ON "LIVE_MEASURES"("PROJECT_UUID"); +CREATE UNIQUE INDEX "LIVE_MEASURES_COMPONENT" ON "LIVE_MEASURES"("COMPONENT_UUID", "METRIC_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/MakeLiveMeasuresMetricUuidNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/MakeLiveMeasuresMetricUuidNotNullableTest/schema.sql new file mode 100644 index 00000000000..dd1e89afe4c --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/MakeLiveMeasuresMetricUuidNotNullableTest/schema.sql @@ -0,0 +1,17 @@ +CREATE TABLE "LIVE_MEASURES"( + "UUID" VARCHAR(40) NOT NULL, + "PROJECT_UUID" VARCHAR(50) NOT NULL, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "METRIC_ID" INTEGER NOT NULL, + "METRIC_UUID" VARCHAR(40), + "VALUE" DOUBLE, + "TEXT_VALUE" VARCHAR(4000), + "VARIATION" DOUBLE, + "MEASURE_DATA" BLOB, + "UPDATE_MARKER" VARCHAR(40), + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL +); +ALTER TABLE "LIVE_MEASURES" ADD CONSTRAINT "PK_LIVE_MEASURES" PRIMARY KEY("UUID"); +CREATE INDEX "LIVE_MEASURES_PROJECT" ON "LIVE_MEASURES"("PROJECT_UUID"); +CREATE UNIQUE INDEX "LIVE_MEASURES_COMPONENT" ON "LIVE_MEASURES"("COMPONENT_UUID", "METRIC_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/PopulateLiveMeasuresMetricUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/PopulateLiveMeasuresMetricUuidTest/schema.sql new file mode 100644 index 00000000000..85b848f4614 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/PopulateLiveMeasuresMetricUuidTest/schema.sql @@ -0,0 +1,39 @@ +CREATE TABLE "LIVE_MEASURES"( + "UUID" VARCHAR(40) NOT NULL, + "PROJECT_UUID" VARCHAR(50) NOT NULL, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "METRIC_ID" INTEGER NOT NULL, + "METRIC_UUID" VARCHAR(40), + "VALUE" DOUBLE, + "TEXT_VALUE" VARCHAR(4000), + "VARIATION" DOUBLE, + "MEASURE_DATA" BLOB, + "UPDATE_MARKER" VARCHAR(40), + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL +); +ALTER TABLE "LIVE_MEASURES" ADD CONSTRAINT "PK_LIVE_MEASURES" PRIMARY KEY("UUID"); +CREATE INDEX "LIVE_MEASURES_PROJECT" ON "LIVE_MEASURES"("PROJECT_UUID"); +CREATE UNIQUE INDEX "LIVE_MEASURES_COMPONENT" ON "LIVE_MEASURES"("COMPONENT_UUID", "METRIC_ID"); + +CREATE TABLE "METRICS"( + "ID" INTEGER NOT NULL, + "UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(64) NOT NULL, + "DESCRIPTION" VARCHAR(255), + "DIRECTION" INTEGER DEFAULT 0 NOT NULL, + "DOMAIN" VARCHAR(64), + "SHORT_NAME" VARCHAR(64), + "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, + "VAL_TYPE" VARCHAR(8), + "USER_MANAGED" BOOLEAN DEFAULT FALSE, + "ENABLED" BOOLEAN DEFAULT TRUE, + "WORST_VALUE" DOUBLE, + "BEST_VALUE" DOUBLE, + "OPTIMIZED_BEST_VALUE" BOOLEAN, + "HIDDEN" BOOLEAN, + "DELETE_HISTORICAL_DATA" BOOLEAN, + "DECIMAL_SCALE" INTEGER +); +ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/AddMetricUuidColumnToManualMeasuresTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/AddMetricUuidColumnToManualMeasuresTest/schema.sql new file mode 100644 index 00000000000..37a120d6215 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/AddMetricUuidColumnToManualMeasuresTest/schema.sql @@ -0,0 +1,35 @@ +CREATE TABLE "MANUAL_MEASURES"( + "UUID" VARCHAR(40) NOT NULL, + "METRIC_ID" INTEGER NOT NULL, + "VALUE" DOUBLE, + "TEXT_VALUE" VARCHAR(4000), + "USER_UUID" VARCHAR(255), + "DESCRIPTION" VARCHAR(4000), + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "COMPONENT_UUID" VARCHAR(50) NOT NULL +); +ALTER TABLE "MANUAL_MEASURES" ADD CONSTRAINT "PK_MANUAL_MEASURES" PRIMARY KEY("UUID"); +CREATE INDEX "MANUAL_MEASURES_COMPONENT_UUID" ON "MANUAL_MEASURES"("COMPONENT_UUID"); + +CREATE TABLE "METRICS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "NAME" VARCHAR(64) NOT NULL, + "DESCRIPTION" VARCHAR(255), + "DIRECTION" INTEGER DEFAULT 0 NOT NULL, + "DOMAIN" VARCHAR(64), + "SHORT_NAME" VARCHAR(64), + "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, + "VAL_TYPE" VARCHAR(8), + "USER_MANAGED" BOOLEAN DEFAULT FALSE, + "ENABLED" BOOLEAN DEFAULT TRUE, + "WORST_VALUE" DOUBLE, + "BEST_VALUE" DOUBLE, + "OPTIMIZED_BEST_VALUE" BOOLEAN, + "HIDDEN" BOOLEAN, + "DELETE_HISTORICAL_DATA" BOOLEAN, + "DECIMAL_SCALE" INTEGER, + "UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/DropMetricIdColumnOfManualMeasuresTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/DropMetricIdColumnOfManualMeasuresTableTest/schema.sql new file mode 100644 index 00000000000..3bb1010e374 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/DropMetricIdColumnOfManualMeasuresTableTest/schema.sql @@ -0,0 +1,36 @@ +CREATE TABLE "MANUAL_MEASURES"( + "UUID" VARCHAR(40) NOT NULL, + "METRIC_UUID" VARCHAR(40) NOT NULL, + "METRIC_ID" INTEGER NOT NULL, + "VALUE" DOUBLE, + "TEXT_VALUE" VARCHAR(4000), + "USER_UUID" VARCHAR(255), + "DESCRIPTION" VARCHAR(4000), + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "COMPONENT_UUID" VARCHAR(50) NOT NULL +); +ALTER TABLE "MANUAL_MEASURES" ADD CONSTRAINT "PK_MANUAL_MEASURES" PRIMARY KEY("UUID"); +CREATE INDEX "MANUAL_MEASURES_COMPONENT_UUID" ON "MANUAL_MEASURES"("COMPONENT_UUID"); + +CREATE TABLE "METRICS"( + "ID" INTEGER NOT NULL, + "NAME" VARCHAR(64) NOT NULL, + "DESCRIPTION" VARCHAR(255), + "DIRECTION" INTEGER DEFAULT 0 NOT NULL, + "DOMAIN" VARCHAR(64), + "SHORT_NAME" VARCHAR(64), + "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, + "VAL_TYPE" VARCHAR(8), + "USER_MANAGED" BOOLEAN DEFAULT FALSE, + "ENABLED" BOOLEAN DEFAULT TRUE, + "WORST_VALUE" DOUBLE, + "BEST_VALUE" DOUBLE, + "OPTIMIZED_BEST_VALUE" BOOLEAN, + "HIDDEN" BOOLEAN, + "DELETE_HISTORICAL_DATA" BOOLEAN, + "DECIMAL_SCALE" INTEGER, + "UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("UUID"); +CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/MakeManualMeasuresMetricUuidNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/MakeManualMeasuresMetricUuidNotNullableTest/schema.sql new file mode 100644 index 00000000000..fe619cf50f2 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/MakeManualMeasuresMetricUuidNotNullableTest/schema.sql @@ -0,0 +1,36 @@ +CREATE TABLE "MANUAL_MEASURES"( + "UUID" VARCHAR(40) NOT NULL, + "METRIC_UUID" VARCHAR(40), + "METRIC_ID" INTEGER NOT NULL, + "VALUE" DOUBLE, + "TEXT_VALUE" VARCHAR(4000), + "USER_UUID" VARCHAR(255), + "DESCRIPTION" VARCHAR(4000), + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "COMPONENT_UUID" VARCHAR(50) NOT NULL +); +ALTER TABLE "MANUAL_MEASURES" ADD CONSTRAINT "PK_MANUAL_MEASURES" PRIMARY KEY("UUID"); +CREATE INDEX "MANUAL_MEASURES_COMPONENT_UUID" ON "MANUAL_MEASURES"("COMPONENT_UUID"); + +CREATE TABLE "METRICS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "NAME" VARCHAR(64) NOT NULL, + "DESCRIPTION" VARCHAR(255), + "DIRECTION" INTEGER DEFAULT 0 NOT NULL, + "DOMAIN" VARCHAR(64), + "SHORT_NAME" VARCHAR(64), + "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, + "VAL_TYPE" VARCHAR(8), + "USER_MANAGED" BOOLEAN DEFAULT FALSE, + "ENABLED" BOOLEAN DEFAULT TRUE, + "WORST_VALUE" DOUBLE, + "BEST_VALUE" DOUBLE, + "OPTIMIZED_BEST_VALUE" BOOLEAN, + "HIDDEN" BOOLEAN, + "DELETE_HISTORICAL_DATA" BOOLEAN, + "DECIMAL_SCALE" INTEGER, + "UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/PopulateManualMeasuresMetricUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/PopulateManualMeasuresMetricUuidTest/schema.sql new file mode 100644 index 00000000000..fe619cf50f2 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/manualmeasures/PopulateManualMeasuresMetricUuidTest/schema.sql @@ -0,0 +1,36 @@ +CREATE TABLE "MANUAL_MEASURES"( + "UUID" VARCHAR(40) NOT NULL, + "METRIC_UUID" VARCHAR(40), + "METRIC_ID" INTEGER NOT NULL, + "VALUE" DOUBLE, + "TEXT_VALUE" VARCHAR(4000), + "USER_UUID" VARCHAR(255), + "DESCRIPTION" VARCHAR(4000), + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "COMPONENT_UUID" VARCHAR(50) NOT NULL +); +ALTER TABLE "MANUAL_MEASURES" ADD CONSTRAINT "PK_MANUAL_MEASURES" PRIMARY KEY("UUID"); +CREATE INDEX "MANUAL_MEASURES_COMPONENT_UUID" ON "MANUAL_MEASURES"("COMPONENT_UUID"); + +CREATE TABLE "METRICS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "NAME" VARCHAR(64) NOT NULL, + "DESCRIPTION" VARCHAR(255), + "DIRECTION" INTEGER DEFAULT 0 NOT NULL, + "DOMAIN" VARCHAR(64), + "SHORT_NAME" VARCHAR(64), + "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, + "VAL_TYPE" VARCHAR(8), + "USER_MANAGED" BOOLEAN DEFAULT FALSE, + "ENABLED" BOOLEAN DEFAULT TRUE, + "WORST_VALUE" DOUBLE, + "BEST_VALUE" DOUBLE, + "OPTIMIZED_BEST_VALUE" BOOLEAN, + "HIDDEN" BOOLEAN, + "DELETE_HISTORICAL_DATA" BOOLEAN, + "DECIMAL_SCALE" INTEGER, + "UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddIndexOnMetricUuidOfProjectMeasuresTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddIndexOnMetricUuidOfProjectMeasuresTableTest/schema.sql new file mode 100644 index 00000000000..bcd93c5d249 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddIndexOnMetricUuidOfProjectMeasuresTableTest/schema.sql @@ -0,0 +1,21 @@ +CREATE TABLE "PROJECT_MEASURES"( + "VALUE" DOUBLE, + "METRIC_UUID" VARCHAR(40) NOT NULL, + "METRIC_ID" INTEGER NOT NULL, + "ANALYSIS_UUID" VARCHAR(50) NOT NULL, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "TEXT_VALUE" VARCHAR(4000), + "ALERT_STATUS" VARCHAR(5), + "ALERT_TEXT" VARCHAR(4000), + "DESCRIPTION" VARCHAR(4000), + "PERSON_ID" INTEGER, + "VARIATION_VALUE_1" DOUBLE, + "VARIATION_VALUE_2" DOUBLE, + "VARIATION_VALUE_3" DOUBLE, + "VARIATION_VALUE_4" DOUBLE, + "VARIATION_VALUE_5" DOUBLE, + "MEASURE_DATA" BLOB, + "UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "PROJECT_MEASURES" ADD CONSTRAINT "PK_PROJECT_MEASURES" PRIMARY KEY("UUID"); +CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddMetricUuidColumnToProjectMeasuresTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddMetricUuidColumnToProjectMeasuresTest/schema.sql new file mode 100644 index 00000000000..847518066d5 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/AddMetricUuidColumnToProjectMeasuresTest/schema.sql @@ -0,0 +1,21 @@ +CREATE TABLE "PROJECT_MEASURES"( + "VALUE" DOUBLE, + "METRIC_ID" INTEGER NOT NULL, + "ANALYSIS_UUID" VARCHAR(50) NOT NULL, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "TEXT_VALUE" VARCHAR(4000), + "ALERT_STATUS" VARCHAR(5), + "ALERT_TEXT" VARCHAR(4000), + "DESCRIPTION" VARCHAR(4000), + "PERSON_ID" INTEGER, + "VARIATION_VALUE_1" DOUBLE, + "VARIATION_VALUE_2" DOUBLE, + "VARIATION_VALUE_3" DOUBLE, + "VARIATION_VALUE_4" DOUBLE, + "VARIATION_VALUE_5" DOUBLE, + "MEASURE_DATA" BLOB, + "UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "PROJECT_MEASURES" ADD CONSTRAINT "PK_PROJECT_MEASURES" PRIMARY KEY("UUID"); +CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES"("ANALYSIS_UUID", "METRIC_ID"); +CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DropIndexOnMetricIdOfProjectMeasuresTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DropIndexOnMetricIdOfProjectMeasuresTableTest/schema.sql new file mode 100644 index 00000000000..90d0eb46d3e --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DropIndexOnMetricIdOfProjectMeasuresTableTest/schema.sql @@ -0,0 +1,22 @@ +CREATE TABLE "PROJECT_MEASURES"( + "VALUE" DOUBLE, + "METRIC_UUID" VARCHAR(40) NOT NULL, + "METRIC_ID" INTEGER NOT NULL, + "ANALYSIS_UUID" VARCHAR(50) NOT NULL, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "TEXT_VALUE" VARCHAR(4000), + "ALERT_STATUS" VARCHAR(5), + "ALERT_TEXT" VARCHAR(4000), + "DESCRIPTION" VARCHAR(4000), + "PERSON_ID" INTEGER, + "VARIATION_VALUE_1" DOUBLE, + "VARIATION_VALUE_2" DOUBLE, + "VARIATION_VALUE_3" DOUBLE, + "VARIATION_VALUE_4" DOUBLE, + "VARIATION_VALUE_5" DOUBLE, + "MEASURE_DATA" BLOB, + "UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "PROJECT_MEASURES" ADD CONSTRAINT "PK_PROJECT_MEASURES" PRIMARY KEY("UUID"); +CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES"("ANALYSIS_UUID", "METRIC_ID"); +CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DropMetricIdColumnOfProjectMeasuresTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DropMetricIdColumnOfProjectMeasuresTableTest/schema.sql new file mode 100644 index 00000000000..55356e78300 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/DropMetricIdColumnOfProjectMeasuresTableTest/schema.sql @@ -0,0 +1,22 @@ +CREATE TABLE "PROJECT_MEASURES"( + "VALUE" DOUBLE, + "METRIC_UUID" VARCHAR(40) NOT NULL, + "METRIC_ID" INTEGER NOT NULL, + "ANALYSIS_UUID" VARCHAR(50) NOT NULL, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "TEXT_VALUE" VARCHAR(4000), + "ALERT_STATUS" VARCHAR(5), + "ALERT_TEXT" VARCHAR(4000), + "DESCRIPTION" VARCHAR(4000), + "PERSON_ID" INTEGER, + "VARIATION_VALUE_1" DOUBLE, + "VARIATION_VALUE_2" DOUBLE, + "VARIATION_VALUE_3" DOUBLE, + "VARIATION_VALUE_4" DOUBLE, + "VARIATION_VALUE_5" DOUBLE, + "MEASURE_DATA" BLOB, + "UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "PROJECT_MEASURES" ADD CONSTRAINT "PK_PROJECT_MEASURES" PRIMARY KEY("UUID"); +CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES"("ANALYSIS_UUID", "METRIC_UUID"); +CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/MakeProjectMeasuresMetricUuidNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/MakeProjectMeasuresMetricUuidNotNullableTest/schema.sql new file mode 100644 index 00000000000..d78a04c7c95 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/MakeProjectMeasuresMetricUuidNotNullableTest/schema.sql @@ -0,0 +1,22 @@ +CREATE TABLE "PROJECT_MEASURES"( + "VALUE" DOUBLE, + "METRIC_UUID" VARCHAR(40), + "METRIC_ID" INTEGER NOT NULL, + "ANALYSIS_UUID" VARCHAR(50) NOT NULL, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "TEXT_VALUE" VARCHAR(4000), + "ALERT_STATUS" VARCHAR(5), + "ALERT_TEXT" VARCHAR(4000), + "DESCRIPTION" VARCHAR(4000), + "PERSON_ID" INTEGER, + "VARIATION_VALUE_1" DOUBLE, + "VARIATION_VALUE_2" DOUBLE, + "VARIATION_VALUE_3" DOUBLE, + "VARIATION_VALUE_4" DOUBLE, + "VARIATION_VALUE_5" DOUBLE, + "MEASURE_DATA" BLOB, + "UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "PROJECT_MEASURES" ADD CONSTRAINT "PK_PROJECT_MEASURES" PRIMARY KEY("UUID"); +CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES"("ANALYSIS_UUID", "METRIC_ID"); +CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/PopulateProjectMeasuresMetricUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/PopulateProjectMeasuresMetricUuidTest/schema.sql new file mode 100644 index 00000000000..ae7f3c32c33 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/projectmeasures/PopulateProjectMeasuresMetricUuidTest/schema.sql @@ -0,0 +1,44 @@ +CREATE TABLE "PROJECT_MEASURES"( + "VALUE" DOUBLE, + "METRIC_UUID" VARCHAR(40), + "METRIC_ID" INTEGER NOT NULL, + "ANALYSIS_UUID" VARCHAR(50) NOT NULL, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "TEXT_VALUE" VARCHAR(4000), + "ALERT_STATUS" VARCHAR(5), + "ALERT_TEXT" VARCHAR(4000), + "DESCRIPTION" VARCHAR(4000), + "PERSON_ID" INTEGER, + "VARIATION_VALUE_1" DOUBLE, + "VARIATION_VALUE_2" DOUBLE, + "VARIATION_VALUE_3" DOUBLE, + "VARIATION_VALUE_4" DOUBLE, + "VARIATION_VALUE_5" DOUBLE, + "MEASURE_DATA" BLOB, + "UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "PROJECT_MEASURES" ADD CONSTRAINT "PK_PROJECT_MEASURES" PRIMARY KEY("UUID"); +CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES"("ANALYSIS_UUID", "METRIC_ID"); +CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES"("COMPONENT_UUID"); + +CREATE TABLE "METRICS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40), + "NAME" VARCHAR(64) NOT NULL, + "DESCRIPTION" VARCHAR(255), + "DIRECTION" INTEGER DEFAULT 0 NOT NULL, + "DOMAIN" VARCHAR(64), + "SHORT_NAME" VARCHAR(64), + "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, + "VAL_TYPE" VARCHAR(8), + "USER_MANAGED" BOOLEAN DEFAULT FALSE, + "ENABLED" BOOLEAN DEFAULT TRUE, + "WORST_VALUE" DOUBLE, + "BEST_VALUE" DOUBLE, + "OPTIMIZED_BEST_VALUE" BOOLEAN, + "HIDDEN" BOOLEAN, + "DELETE_HISTORICAL_DATA" BOOLEAN, + "DECIMAL_SCALE" INTEGER +); +ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/AddMetricUuidColumnToQualityGateConditionsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/AddMetricUuidColumnToQualityGateConditionsTest/schema.sql new file mode 100644 index 00000000000..dff1d72e573 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/AddMetricUuidColumnToQualityGateConditionsTest/schema.sql @@ -0,0 +1,34 @@ +CREATE TABLE "QUALITY_GATE_CONDITIONS"( + "UUID" VARCHAR(40) NOT NULL, + "QGATE_ID" INTEGER, + "METRIC_ID" INTEGER, + "PERIOD" INTEGER, + "OPERATOR" VARCHAR(3), + "VALUE_ERROR" VARCHAR(64), + "VALUE_WARNING" VARCHAR(64), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "QUALITY_GATE_CONDITIONS" ADD CONSTRAINT "PK_QUALITY_GATE_CONDITIONS" PRIMARY KEY("UUID"); + +CREATE TABLE "METRICS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(64) NOT NULL, + "DESCRIPTION" VARCHAR(255), + "DIRECTION" INTEGER DEFAULT 0 NOT NULL, + "DOMAIN" VARCHAR(64), + "SHORT_NAME" VARCHAR(64), + "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, + "VAL_TYPE" VARCHAR(8), + "USER_MANAGED" BOOLEAN DEFAULT FALSE, + "ENABLED" BOOLEAN DEFAULT TRUE, + "WORST_VALUE" DOUBLE, + "BEST_VALUE" DOUBLE, + "OPTIMIZED_BEST_VALUE" BOOLEAN, + "HIDDEN" BOOLEAN, + "DELETE_HISTORICAL_DATA" BOOLEAN, + "DECIMAL_SCALE" INTEGER +); +ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/DropMetricIdColumnOfQualityGateConditionsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/DropMetricIdColumnOfQualityGateConditionsTableTest/schema.sql new file mode 100644 index 00000000000..aa2aaf71563 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/DropMetricIdColumnOfQualityGateConditionsTableTest/schema.sql @@ -0,0 +1,35 @@ +CREATE TABLE "QUALITY_GATE_CONDITIONS"( + "UUID" VARCHAR(40) NOT NULL, + "QGATE_ID" INTEGER, + "METRIC_UUID" VARCHAR(40) NOT NULL, + "METRIC_ID" INTEGER, + "PERIOD" INTEGER, + "OPERATOR" VARCHAR(3), + "VALUE_ERROR" VARCHAR(64), + "VALUE_WARNING" VARCHAR(64), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "QUALITY_GATE_CONDITIONS" ADD CONSTRAINT "PK_QUALITY_GATE_CONDITIONS" PRIMARY KEY("UUID"); + +CREATE TABLE "METRICS"( + "ID" INTEGER NOT NULL, + "UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(64) NOT NULL, + "DESCRIPTION" VARCHAR(255), + "DIRECTION" INTEGER DEFAULT 0 NOT NULL, + "DOMAIN" VARCHAR(64), + "SHORT_NAME" VARCHAR(64), + "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, + "VAL_TYPE" VARCHAR(8), + "USER_MANAGED" BOOLEAN DEFAULT FALSE, + "ENABLED" BOOLEAN DEFAULT TRUE, + "WORST_VALUE" DOUBLE, + "BEST_VALUE" DOUBLE, + "OPTIMIZED_BEST_VALUE" BOOLEAN, + "HIDDEN" BOOLEAN, + "DELETE_HISTORICAL_DATA" BOOLEAN, + "DECIMAL_SCALE" INTEGER +); +ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("UUID"); +CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/MakeQualityGateConditionsMetricUuidNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/MakeQualityGateConditionsMetricUuidNotNullableTest/schema.sql new file mode 100644 index 00000000000..2b5a222cb91 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/MakeQualityGateConditionsMetricUuidNotNullableTest/schema.sql @@ -0,0 +1,35 @@ +CREATE TABLE "QUALITY_GATE_CONDITIONS"( + "UUID" VARCHAR(40) NOT NULL, + "QGATE_ID" INTEGER, + "METRIC_UUID" VARCHAR(40), + "METRIC_ID" INTEGER, + "PERIOD" INTEGER, + "OPERATOR" VARCHAR(3), + "VALUE_ERROR" VARCHAR(64), + "VALUE_WARNING" VARCHAR(64), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "QUALITY_GATE_CONDITIONS" ADD CONSTRAINT "PK_QUALITY_GATE_CONDITIONS" PRIMARY KEY("UUID"); + +CREATE TABLE "METRICS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(64) NOT NULL, + "DESCRIPTION" VARCHAR(255), + "DIRECTION" INTEGER DEFAULT 0 NOT NULL, + "DOMAIN" VARCHAR(64), + "SHORT_NAME" VARCHAR(64), + "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, + "VAL_TYPE" VARCHAR(8), + "USER_MANAGED" BOOLEAN DEFAULT FALSE, + "ENABLED" BOOLEAN DEFAULT TRUE, + "WORST_VALUE" DOUBLE, + "BEST_VALUE" DOUBLE, + "OPTIMIZED_BEST_VALUE" BOOLEAN, + "HIDDEN" BOOLEAN, + "DELETE_HISTORICAL_DATA" BOOLEAN, + "DECIMAL_SCALE" INTEGER +); +ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/PopulateQualityGateConditionsMetricUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/PopulateQualityGateConditionsMetricUuidTest/schema.sql new file mode 100644 index 00000000000..2b5a222cb91 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/metrics/qualitygateconditions/PopulateQualityGateConditionsMetricUuidTest/schema.sql @@ -0,0 +1,35 @@ +CREATE TABLE "QUALITY_GATE_CONDITIONS"( + "UUID" VARCHAR(40) NOT NULL, + "QGATE_ID" INTEGER, + "METRIC_UUID" VARCHAR(40), + "METRIC_ID" INTEGER, + "PERIOD" INTEGER, + "OPERATOR" VARCHAR(3), + "VALUE_ERROR" VARCHAR(64), + "VALUE_WARNING" VARCHAR(64), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "QUALITY_GATE_CONDITIONS" ADD CONSTRAINT "PK_QUALITY_GATE_CONDITIONS" PRIMARY KEY("UUID"); + +CREATE TABLE "METRICS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(64) NOT NULL, + "DESCRIPTION" VARCHAR(255), + "DIRECTION" INTEGER DEFAULT 0 NOT NULL, + "DOMAIN" VARCHAR(64), + "SHORT_NAME" VARCHAR(64), + "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL, + "VAL_TYPE" VARCHAR(8), + "USER_MANAGED" BOOLEAN DEFAULT FALSE, + "ENABLED" BOOLEAN DEFAULT TRUE, + "WORST_VALUE" DOUBLE, + "BEST_VALUE" DOUBLE, + "OPTIMIZED_BEST_VALUE" BOOLEAN, + "HIDDEN" BOOLEAN, + "DELETE_HISTORICAL_DATA" BOOLEAN, + "DECIMAL_SCALE" INTEGER +); +ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/notifications/AddPrimaryKeyOnUuidColumnOfNotificationTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/notifications/AddPrimaryKeyOnUuidColumnOfNotificationTableTest/schema.sql new file mode 100644 index 00000000000..530b33a0863 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/notifications/AddPrimaryKeyOnUuidColumnOfNotificationTableTest/schema.sql @@ -0,0 +1,6 @@ +CREATE TABLE "NOTIFICATIONS"( + "ID" INTEGER NOT NULL, + "DATA" BLOB, + "UUID" VARCHAR(40) NOT NULL, + "CREATED_AT" BIGINT NOT NULL +); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/notifications/AddUuidAndCreatedAtColumnsToNotificationTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/notifications/AddUuidAndCreatedAtColumnsToNotificationTest/schema.sql new file mode 100644 index 00000000000..bde193df885 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/notifications/AddUuidAndCreatedAtColumnsToNotificationTest/schema.sql @@ -0,0 +1,5 @@ +CREATE TABLE "NOTIFICATIONS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "DATA" BLOB +); +ALTER TABLE "NOTIFICATIONS" ADD CONSTRAINT "PK_NOTIFICATIONS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/notifications/DropIdColumnOfNotificationTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/notifications/DropIdColumnOfNotificationTableTest/schema.sql new file mode 100644 index 00000000000..b007218aa89 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/notifications/DropIdColumnOfNotificationTableTest/schema.sql @@ -0,0 +1,7 @@ +CREATE TABLE "NOTIFICATIONS"( + "ID" INTEGER NOT NULL, + "DATA" BLOB, + "UUID" VARCHAR(40) NOT NULL, + "CREATED_AT" BIGINT NOT NULL +); +ALTER TABLE "NOTIFICATIONS" ADD CONSTRAINT "PK_NOTIFICATIONS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/notifications/DropPrimaryKeyOnIdColumnOfNotificationTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/notifications/DropPrimaryKeyOnIdColumnOfNotificationTableTest/schema.sql new file mode 100644 index 00000000000..082c809f6e0 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/notifications/DropPrimaryKeyOnIdColumnOfNotificationTableTest/schema.sql @@ -0,0 +1,7 @@ +CREATE TABLE "NOTIFICATIONS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "DATA" BLOB +); +ALTER TABLE "NOTIFICATIONS" ADD CONSTRAINT "PK_NOTIFICATIONS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/notifications/MakeNotificationUuidAndCreatedAtColumnsNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/notifications/MakeNotificationUuidAndCreatedAtColumnsNotNullableTest/schema.sql new file mode 100644 index 00000000000..3e3bae5d79d --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/notifications/MakeNotificationUuidAndCreatedAtColumnsNotNullableTest/schema.sql @@ -0,0 +1,7 @@ +CREATE TABLE "NOTIFICATIONS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40), + "CREATED_AT" BIGINT, + "DATA" BLOB +); +ALTER TABLE "NOTIFICATIONS" ADD CONSTRAINT "PK_NOTIFICATIONS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/notifications/PopulateNotificationUuidAndCreatedAtTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/notifications/PopulateNotificationUuidAndCreatedAtTest/schema.sql new file mode 100644 index 00000000000..ca8451dbfd5 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/notifications/PopulateNotificationUuidAndCreatedAtTest/schema.sql @@ -0,0 +1,7 @@ +CREATE TABLE "NOTIFICATIONS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40), + "CREATED_AT" BIGINT NULL, + "DATA" BLOB +); +ALTER TABLE "NOTIFICATIONS" ADD CONSTRAINT "PK_NOTIFICATIONS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTableTest/schema.sql new file mode 100644 index 00000000000..52bb4a2e2c5 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTableTest/schema.sql @@ -0,0 +1,12 @@ +CREATE TABLE "PERMISSION_TEMPLATES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(100) NOT NULL, + "KEE" VARCHAR(100) NOT NULL, + "DESCRIPTION" VARCHAR(4000), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP, + "KEY_PATTERN" VARCHAR(500) +); + diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddUuidColumnToPermissionTemplatesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddUuidColumnToPermissionTemplatesTest/schema.sql new file mode 100644 index 00000000000..0a21fe126d2 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddUuidColumnToPermissionTemplatesTest/schema.sql @@ -0,0 +1,11 @@ +CREATE TABLE "PERMISSION_TEMPLATES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(100) NOT NULL, + "KEE" VARCHAR(100) NOT NULL, + "DESCRIPTION" VARCHAR(4000), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP, + "KEY_PATTERN" VARCHAR(500) +); +ALTER TABLE "PERMISSION_TEMPLATES" ADD CONSTRAINT "PK_PERMISSION_TEMPLATES" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropIdColumnOfPermissionTemplatesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropIdColumnOfPermissionTemplatesTableTest/schema.sql new file mode 100644 index 00000000000..abff11e7672 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropIdColumnOfPermissionTemplatesTableTest/schema.sql @@ -0,0 +1,12 @@ +CREATE TABLE "PERMISSION_TEMPLATES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(100) NOT NULL, + "KEE" VARCHAR(100) NOT NULL, + "DESCRIPTION" VARCHAR(4000), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP, + "KEY_PATTERN" VARCHAR(500) +); +ALTER TABLE "PERMISSION_TEMPLATES" ADD CONSTRAINT "PK_PERMISSION_TEMPLATES" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropKeeColumnOfPermissionTemplatesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropKeeColumnOfPermissionTemplatesTableTest/schema.sql new file mode 100644 index 00000000000..10c79779e6d --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropKeeColumnOfPermissionTemplatesTableTest/schema.sql @@ -0,0 +1,11 @@ +CREATE TABLE "PERMISSION_TEMPLATES"( + "UUID" VARCHAR(40) NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(100) NOT NULL, + "KEE" VARCHAR(100) NOT NULL, + "DESCRIPTION" VARCHAR(4000), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP, + "KEY_PATTERN" VARCHAR(500) +); +ALTER TABLE "PERMISSION_TEMPLATES" ADD CONSTRAINT "PK_PERMISSION_TEMPLATES" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropPrimaryKeyOnIdColumnOfPermissionTemplatesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropPrimaryKeyOnIdColumnOfPermissionTemplatesTableTest/schema.sql new file mode 100644 index 00000000000..ed17fd38257 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropPrimaryKeyOnIdColumnOfPermissionTemplatesTableTest/schema.sql @@ -0,0 +1,12 @@ +CREATE TABLE "PERMISSION_TEMPLATES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(100) NOT NULL, + "KEE" VARCHAR(100) NOT NULL, + "DESCRIPTION" VARCHAR(4000), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP, + "KEY_PATTERN" VARCHAR(500) +); +ALTER TABLE "PERMISSION_TEMPLATES" ADD CONSTRAINT "PK_PERMISSION_TEMPLATES" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/MakePermissionTemplateUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/MakePermissionTemplateUuidColumnNotNullableTest/schema.sql new file mode 100644 index 00000000000..a9667137aec --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/MakePermissionTemplateUuidColumnNotNullableTest/schema.sql @@ -0,0 +1,12 @@ +CREATE TABLE "PERMISSION_TEMPLATES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40), + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(100) NOT NULL, + "KEE" VARCHAR(100) NOT NULL, + "DESCRIPTION" VARCHAR(4000), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP, + "KEY_PATTERN" VARCHAR(500) +); +ALTER TABLE "PERMISSION_TEMPLATES" ADD CONSTRAINT "PK_PERMISSION_TEMPLATES" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/PopulatePermissionTemplatesUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/PopulatePermissionTemplatesUuidTest/schema.sql new file mode 100644 index 00000000000..a9667137aec --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/PopulatePermissionTemplatesUuidTest/schema.sql @@ -0,0 +1,12 @@ +CREATE TABLE "PERMISSION_TEMPLATES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40), + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(100) NOT NULL, + "KEE" VARCHAR(100) NOT NULL, + "DESCRIPTION" VARCHAR(4000), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP, + "KEY_PATTERN" VARCHAR(500) +); +ALTER TABLE "PERMISSION_TEMPLATES" ADD CONSTRAINT "PK_PERMISSION_TEMPLATES" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/AddTemplateUuidColumnToPermTemplatesGroupsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/AddTemplateUuidColumnToPermTemplatesGroupsTest/schema.sql new file mode 100644 index 00000000000..8fc600ae7dd --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/AddTemplateUuidColumnToPermTemplatesGroupsTest/schema.sql @@ -0,0 +1,9 @@ +CREATE TABLE "PERM_TEMPLATES_GROUPS"( + "UUID" VARCHAR(40) NOT NULL, + "GROUP_ID" INTEGER, + "TEMPLATE_ID" INTEGER NOT NULL, + "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "PERM_TEMPLATES_GROUPS" ADD CONSTRAINT "PK_PERM_TEMPLATES_GROUPS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/DropTemplateIdColumnOfPermTemplatesGroupsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/DropTemplateIdColumnOfPermTemplatesGroupsTableTest/schema.sql new file mode 100644 index 00000000000..9be99ebafe8 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/DropTemplateIdColumnOfPermTemplatesGroupsTableTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "PERM_TEMPLATES_GROUPS"( + "UUID" VARCHAR(40) NOT NULL, + "GROUP_ID" INTEGER, + "TEMPLATE_UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_ID" INTEGER NOT NULL, + "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "PERM_TEMPLATES_GROUPS" ADD CONSTRAINT "PK_PERM_TEMPLATES_GROUPS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/MakePermTemplatesGroupsTemplateUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/MakePermTemplatesGroupsTemplateUuidColumnNotNullableTest/schema.sql new file mode 100644 index 00000000000..a3174f7b947 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/MakePermTemplatesGroupsTemplateUuidColumnNotNullableTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "PERM_TEMPLATES_GROUPS"( + "UUID" VARCHAR(40) NOT NULL, + "GROUP_ID" INTEGER, + "TEMPLATE_UUID" VARCHAR(40), + "TEMPLATE_ID" INTEGER NOT NULL, + "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "PERM_TEMPLATES_GROUPS" ADD CONSTRAINT "PK_PERM_TEMPLATES_GROUPS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/PopulatePermTemplatesGroupsTemplateUuidColumnTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/PopulatePermTemplatesGroupsTemplateUuidColumnTest/schema.sql new file mode 100644 index 00000000000..5f566add810 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesgroups/PopulatePermTemplatesGroupsTemplateUuidColumnTest/schema.sql @@ -0,0 +1,23 @@ +CREATE TABLE "PERM_TEMPLATES_GROUPS"( + "UUID" VARCHAR(40) NOT NULL, + "GROUP_ID" INTEGER, + "TEMPLATE_UUID" VARCHAR(40), + "TEMPLATE_ID" INTEGER NOT NULL, + "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "PERM_TEMPLATES_GROUPS" ADD CONSTRAINT "PK_PERM_TEMPLATES_GROUPS" PRIMARY KEY("UUID"); + +CREATE TABLE "PERMISSION_TEMPLATES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(100) NOT NULL, + "KEE" VARCHAR(100) NOT NULL, + "DESCRIPTION" VARCHAR(4000), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP, + "KEY_PATTERN" VARCHAR(500) +); +ALTER TABLE "PERMISSION_TEMPLATES" ADD CONSTRAINT "PK_PERMISSION_TEMPLATES" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/AddTemplateUuidColumnToPermTemplatesUsersTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/AddTemplateUuidColumnToPermTemplatesUsersTest/schema.sql new file mode 100644 index 00000000000..e9a334d0030 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/AddTemplateUuidColumnToPermTemplatesUsersTest/schema.sql @@ -0,0 +1,9 @@ +CREATE TABLE "PERM_TEMPLATES_USERS"( + "UUID" VARCHAR(40) NOT NULL, + "USER_ID" INTEGER NOT NULL, + "TEMPLATE_ID" INTEGER NOT NULL, + "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "PERM_TEMPLATES_USERS" ADD CONSTRAINT "PK_PERM_TEMPLATES_USERS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/DropTemplateIdColumnOfPermTemplatesUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/DropTemplateIdColumnOfPermTemplatesUsersTableTest/schema.sql new file mode 100644 index 00000000000..af182cb58ab --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/DropTemplateIdColumnOfPermTemplatesUsersTableTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "PERM_TEMPLATES_USERS"( + "UUID" VARCHAR(40) NOT NULL, + "USER_ID" INTEGER NOT NULL, + "TEMPLATE_UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_ID" INTEGER NOT NULL, + "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "PERM_TEMPLATES_USERS" ADD CONSTRAINT "PK_PERM_TEMPLATES_USERS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/MakePermTemplatesUsersTemplateUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/MakePermTemplatesUsersTemplateUuidColumnNotNullableTest/schema.sql new file mode 100644 index 00000000000..d175d8aa1aa --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/MakePermTemplatesUsersTemplateUuidColumnNotNullableTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "PERM_TEMPLATES_USERS"( + "UUID" VARCHAR(40) NOT NULL, + "USER_ID" INTEGER NOT NULL, + "TEMPLATE_UUID" VARCHAR(40), + "TEMPLATE_ID" INTEGER NOT NULL, + "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "PERM_TEMPLATES_USERS" ADD CONSTRAINT "PK_PERM_TEMPLATES_USERS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/PopulatePermTemplatesUsersTemplateUuidColumnTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/PopulatePermTemplatesUsersTemplateUuidColumnTest/schema.sql new file mode 100644 index 00000000000..055479cfb13 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtemplatesusers/PopulatePermTemplatesUsersTemplateUuidColumnTest/schema.sql @@ -0,0 +1,23 @@ +CREATE TABLE "PERMISSION_TEMPLATES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(100) NOT NULL, + "KEE" VARCHAR(100) NOT NULL, + "DESCRIPTION" VARCHAR(4000), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP, + "KEY_PATTERN" VARCHAR(500) +); +ALTER TABLE "PERMISSION_TEMPLATES" ADD CONSTRAINT "PK_PERMISSION_TEMPLATES" PRIMARY KEY("ID"); + +CREATE TABLE "PERM_TEMPLATES_USERS"( + "UUID" VARCHAR(40) NOT NULL, + "USER_ID" INTEGER NOT NULL, + "TEMPLATE_UUID" VARCHAR(40), + "TEMPLATE_ID" INTEGER NOT NULL, + "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "PERM_TEMPLATES_USERS" ADD CONSTRAINT "PK_PERM_TEMPLATES_USERS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/AddTemplateUuidColumnToPermTplCharacteristicsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/AddTemplateUuidColumnToPermTplCharacteristicsTest/schema.sql new file mode 100644 index 00000000000..bd692486b2a --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/AddTemplateUuidColumnToPermTplCharacteristicsTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "PERM_TPL_CHARACTERISTICS"( + "UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_ID" INTEGER NOT NULL, + "PERMISSION_KEY" VARCHAR(64) NOT NULL, + "WITH_PROJECT_CREATOR" BOOLEAN DEFAULT FALSE NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL +); +ALTER TABLE "PERM_TPL_CHARACTERISTICS" ADD CONSTRAINT "PK_PERM_TPL_CHARACTERISTICS" PRIMARY KEY("UUID"); +CREATE UNIQUE INDEX "UNIQ_PERM_TPL_CHARAC" ON "PERM_TPL_CHARACTERISTICS"("TEMPLATE_ID", "PERMISSION_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest/schema.sql new file mode 100644 index 00000000000..648fb65271a --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/AddUniqueIndexOnTemplateUuidAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest/schema.sql @@ -0,0 +1,11 @@ +CREATE TABLE "PERM_TPL_CHARACTERISTICS"( + "UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_ID" INTEGER NOT NULL, + "TEMPLATE_UUID" VARCHAR(40) NOT NULL, + "PERMISSION_KEY" VARCHAR(64) NOT NULL, + "WITH_PROJECT_CREATOR" BOOLEAN DEFAULT FALSE NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL +); +ALTER TABLE "PERM_TPL_CHARACTERISTICS" ADD CONSTRAINT "PK_PERM_TPL_CHARACTERISTICS" PRIMARY KEY("UUID"); +CREATE UNIQUE INDEX "UNIQ_PERM_TPL_CHARAC" ON "PERM_TPL_CHARACTERISTICS"("TEMPLATE_ID", "PERMISSION_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/DropTemplateIdColumnOfPermTplCharacteristicsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/DropTemplateIdColumnOfPermTplCharacteristicsTableTest/schema.sql new file mode 100644 index 00000000000..f61883e3019 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/DropTemplateIdColumnOfPermTplCharacteristicsTableTest/schema.sql @@ -0,0 +1,11 @@ +CREATE TABLE "PERM_TPL_CHARACTERISTICS"( + "UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_ID" INTEGER NOT NULL, + "PERMISSION_KEY" VARCHAR(64) NOT NULL, + "WITH_PROJECT_CREATOR" BOOLEAN DEFAULT FALSE NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL +); +ALTER TABLE "PERM_TPL_CHARACTERISTICS" ADD CONSTRAINT "PK_PERM_TPL_CHARACTERISTICS" PRIMARY KEY("UUID"); +CREATE UNIQUE INDEX "UNIQ_PERM_TPL_CHARAC" ON "PERM_TPL_CHARACTERISTICS"("TEMPLATE_UUID", "PERMISSION_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest/schema.sql new file mode 100644 index 00000000000..47559a2cab0 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/DropUniqueIndexOnTemplateIdAndPermissionKeyColumnsOfPermTplCharacteristicsTableTest/schema.sql @@ -0,0 +1,11 @@ +CREATE TABLE "PERM_TPL_CHARACTERISTICS"( + "UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_UUID" INTEGER NOT NULL, + "TEMPLATE_ID" VARCHAR(40) NOT NULL, + "PERMISSION_KEY" VARCHAR(64) NOT NULL, + "WITH_PROJECT_CREATOR" BOOLEAN DEFAULT FALSE NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL +); +ALTER TABLE "PERM_TPL_CHARACTERISTICS" ADD CONSTRAINT "PK_PERM_TPL_CHARACTERISTICS" PRIMARY KEY("UUID"); +CREATE UNIQUE INDEX "UNIQ_PERM_TPL_CHARAC" ON "PERM_TPL_CHARACTERISTICS"("TEMPLATE_ID", "PERMISSION_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/MakePermTplCharacteristicsTemplateUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/MakePermTplCharacteristicsTemplateUuidColumnNotNullableTest/schema.sql new file mode 100644 index 00000000000..5e36ef16eff --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/MakePermTplCharacteristicsTemplateUuidColumnNotNullableTest/schema.sql @@ -0,0 +1,11 @@ +CREATE TABLE "PERM_TPL_CHARACTERISTICS"( + "UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_ID" INTEGER NOT NULL, + "TEMPLATE_UUID" VARCHAR(40), + "PERMISSION_KEY" VARCHAR(64) NOT NULL, + "WITH_PROJECT_CREATOR" BOOLEAN DEFAULT FALSE NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL +); +ALTER TABLE "PERM_TPL_CHARACTERISTICS" ADD CONSTRAINT "PK_PERM_TPL_CHARACTERISTICS" PRIMARY KEY("UUID"); +CREATE UNIQUE INDEX "UNIQ_PERM_TPL_CHARAC" ON "PERM_TPL_CHARACTERISTICS"("TEMPLATE_ID", "PERMISSION_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/PopulatePermTplCharacteristicsTemplateUuidColumnTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/PopulatePermTplCharacteristicsTemplateUuidColumnTest/schema.sql new file mode 100644 index 00000000000..2443d0d12c8 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/fk/permtplcharacteristics/PopulatePermTplCharacteristicsTemplateUuidColumnTest/schema.sql @@ -0,0 +1,24 @@ +CREATE TABLE "PERMISSION_TEMPLATES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(100) NOT NULL, + "KEE" VARCHAR(100) NOT NULL, + "DESCRIPTION" VARCHAR(4000), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP, + "KEY_PATTERN" VARCHAR(500) +); +ALTER TABLE "PERMISSION_TEMPLATES" ADD CONSTRAINT "PK_PERMISSION_TEMPLATES" PRIMARY KEY("ID"); + +CREATE TABLE "PERM_TPL_CHARACTERISTICS"( + "UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_ID" INTEGER NOT NULL, + "TEMPLATE_UUID" VARCHAR(40), + "PERMISSION_KEY" VARCHAR(64) NOT NULL, + "WITH_PROJECT_CREATOR" BOOLEAN DEFAULT FALSE NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL +); +ALTER TABLE "PERM_TPL_CHARACTERISTICS" ADD CONSTRAINT "PK_PERM_TPL_CHARACTERISTICS" PRIMARY KEY("UUID"); +CREATE UNIQUE INDEX "UNIQ_PERM_TPL_CHARAC" ON "PERM_TPL_CHARACTERISTICS"("TEMPLATE_ID", "PERMISSION_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTableTest/schema.sql new file mode 100644 index 00000000000..f3319b5bc6f --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTableTest/schema.sql @@ -0,0 +1,9 @@ +CREATE TABLE "PERM_TEMPLATES_GROUPS"( + "ID" INTEGER NOT NULL, + "UUID" VARCHAR(40) NOT NULL, + "GROUP_ID" INTEGER, + "TEMPLATE_ID" INTEGER NOT NULL, + "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddUuidColumnToPermTemplatesGroupsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddUuidColumnToPermTemplatesGroupsTableTest/schema.sql new file mode 100644 index 00000000000..fa6baad81b0 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddUuidColumnToPermTemplatesGroupsTableTest/schema.sql @@ -0,0 +1,9 @@ +CREATE TABLE "PERM_TEMPLATES_GROUPS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "GROUP_ID" INTEGER, + "TEMPLATE_ID" INTEGER NOT NULL, + "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "PERM_TEMPLATES_GROUPS" ADD CONSTRAINT "PK_PERM_TEMPLATES_GROUPS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropIdColumnOfPermTemplatesGroupsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropIdColumnOfPermTemplatesGroupsTableTest/schema.sql new file mode 100644 index 00000000000..395419e5803 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropIdColumnOfPermTemplatesGroupsTableTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "PERM_TEMPLATES_GROUPS"( + "ID" INTEGER NOT NULL, + "UUID" VARCHAR(40) NOT NULL, + "GROUP_ID" INTEGER, + "TEMPLATE_ID" INTEGER NOT NULL, + "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "PERM_TEMPLATES_GROUPS" ADD CONSTRAINT "PK_PERM_TEMPLATES_GROUPS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTableTest/schema.sql new file mode 100644 index 00000000000..dcef0db3e5e --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTableTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "PERM_TEMPLATES_GROUPS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "GROUP_ID" INTEGER, + "TEMPLATE_ID" INTEGER NOT NULL, + "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "PERM_TEMPLATES_GROUPS" ADD CONSTRAINT "PK_PERM_TEMPLATES_GROUPS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/MakePermTemplatesGroupsUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/MakePermTemplatesGroupsUuidColumnNotNullableTest/schema.sql new file mode 100644 index 00000000000..a1d04848527 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/MakePermTemplatesGroupsUuidColumnNotNullableTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "PERM_TEMPLATES_GROUPS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40), + "GROUP_ID" INTEGER, + "TEMPLATE_ID" INTEGER NOT NULL, + "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "PERM_TEMPLATES_GROUPS" ADD CONSTRAINT "PK_PERM_TEMPLATES_GROUPS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/PopulatePermTemplatesGroupsUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/PopulatePermTemplatesGroupsUuidTest/schema.sql new file mode 100644 index 00000000000..a1d04848527 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/PopulatePermTemplatesGroupsUuidTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "PERM_TEMPLATES_GROUPS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40), + "GROUP_ID" INTEGER, + "TEMPLATE_ID" INTEGER NOT NULL, + "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "PERM_TEMPLATES_GROUPS" ADD CONSTRAINT "PK_PERM_TEMPLATES_GROUPS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTableTest/schema.sql new file mode 100644 index 00000000000..d51c8ba2245 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTableTest/schema.sql @@ -0,0 +1,9 @@ +CREATE TABLE "PERM_TEMPLATES_USERS"( + "ID" INTEGER NOT NULL, + "UUID" VARCHAR(40) NOT NULL, + "USER_ID" INTEGER NOT NULL, + "TEMPLATE_ID" INTEGER NOT NULL, + "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddUuidColumnToPermTemplatesUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddUuidColumnToPermTemplatesUsersTableTest/schema.sql new file mode 100644 index 00000000000..285b963b8cd --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddUuidColumnToPermTemplatesUsersTableTest/schema.sql @@ -0,0 +1,9 @@ +CREATE TABLE "PERM_TEMPLATES_USERS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "USER_ID" INTEGER NOT NULL, + "TEMPLATE_ID" INTEGER NOT NULL, + "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "PERM_TEMPLATES_USERS" ADD CONSTRAINT "PK_PERM_TEMPLATES_USERS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropIdColumnOfPermTemplatesUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropIdColumnOfPermTemplatesUsersTableTest/schema.sql new file mode 100644 index 00000000000..f2974f76813 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropIdColumnOfPermTemplatesUsersTableTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "PERM_TEMPLATES_USERS"( + "ID" INTEGER NOT NULL, + "UUID" VARCHAR(40) NOT NULL, + "USER_ID" INTEGER NOT NULL, + "TEMPLATE_ID" INTEGER NOT NULL, + "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "PERM_TEMPLATES_USERS" ADD CONSTRAINT "PK_PERM_TEMPLATES_USERS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTableTest/schema.sql new file mode 100644 index 00000000000..dc2d8b31e74 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTableTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "PERM_TEMPLATES_USERS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "USER_ID" INTEGER NOT NULL, + "TEMPLATE_ID" INTEGER NOT NULL, + "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "PERM_TEMPLATES_USERS" ADD CONSTRAINT "PK_PERM_TEMPLATES_USERS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/MakePermTemplatesUsersUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/MakePermTemplatesUsersUuidColumnNotNullableTest/schema.sql new file mode 100644 index 00000000000..23c2c4f21e6 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/MakePermTemplatesUsersUuidColumnNotNullableTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "PERM_TEMPLATES_USERS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40), + "USER_ID" INTEGER NOT NULL, + "TEMPLATE_ID" INTEGER NOT NULL, + "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "PERM_TEMPLATES_USERS" ADD CONSTRAINT "PK_PERM_TEMPLATES_USERS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/PopulatePermTemplatesUsersUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/PopulatePermTemplatesUsersUuidTest/schema.sql new file mode 100644 index 00000000000..23c2c4f21e6 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/PopulatePermTemplatesUsersUuidTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "PERM_TEMPLATES_USERS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40), + "USER_ID" INTEGER NOT NULL, + "TEMPLATE_ID" INTEGER NOT NULL, + "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "PERM_TEMPLATES_USERS" ADD CONSTRAINT "PK_PERM_TEMPLATES_USERS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTableTest/schema.sql new file mode 100644 index 00000000000..e8784cadf0c --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTableTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "PERM_TPL_CHARACTERISTICS"( + "ID" INTEGER NOT NULL, + "UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_ID" INTEGER NOT NULL, + "PERMISSION_KEY" VARCHAR(64) NOT NULL, + "WITH_PROJECT_CREATOR" BOOLEAN DEFAULT FALSE NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL +); +CREATE UNIQUE INDEX "UNIQ_PERM_TPL_CHARAC" ON "PERM_TPL_CHARACTERISTICS"("TEMPLATE_ID", "PERMISSION_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddUuidColumnToPermTplCharacteristicsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddUuidColumnToPermTplCharacteristicsTableTest/schema.sql new file mode 100644 index 00000000000..174c2e880c9 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddUuidColumnToPermTplCharacteristicsTableTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "PERM_TPL_CHARACTERISTICS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "TEMPLATE_ID" INTEGER NOT NULL, + "PERMISSION_KEY" VARCHAR(64) NOT NULL, + "WITH_PROJECT_CREATOR" BOOLEAN DEFAULT FALSE NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL +); +ALTER TABLE "PERM_TPL_CHARACTERISTICS" ADD CONSTRAINT "PK_PERM_TPL_CHARACTERISTICS" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "UNIQ_PERM_TPL_CHARAC" ON "PERM_TPL_CHARACTERISTICS"("TEMPLATE_ID", "PERMISSION_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropIdColumnOfPermTplCharacteristicsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropIdColumnOfPermTplCharacteristicsTableTest/schema.sql new file mode 100644 index 00000000000..8fad4d5a96c --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropIdColumnOfPermTplCharacteristicsTableTest/schema.sql @@ -0,0 +1,11 @@ +CREATE TABLE "PERM_TPL_CHARACTERISTICS"( + "ID" INTEGER NOT NULL, + "UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_ID" INTEGER NOT NULL, + "PERMISSION_KEY" VARCHAR(64) NOT NULL, + "WITH_PROJECT_CREATOR" BOOLEAN DEFAULT FALSE NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL +); +ALTER TABLE "PERM_TPL_CHARACTERISTICS" ADD CONSTRAINT "PK_PERM_TPL_CHARACTERISTICS" PRIMARY KEY("UUID"); +CREATE UNIQUE INDEX "UNIQ_PERM_TPL_CHARAC" ON "PERM_TPL_CHARACTERISTICS"("TEMPLATE_ID", "PERMISSION_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTableTest/schema.sql new file mode 100644 index 00000000000..3cf4c91cf61 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTableTest/schema.sql @@ -0,0 +1,11 @@ +CREATE TABLE "PERM_TPL_CHARACTERISTICS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_ID" INTEGER NOT NULL, + "PERMISSION_KEY" VARCHAR(64) NOT NULL, + "WITH_PROJECT_CREATOR" BOOLEAN DEFAULT FALSE NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL +); +ALTER TABLE "PERM_TPL_CHARACTERISTICS" ADD CONSTRAINT "PK_PERM_TPL_CHARACTERISTICS" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "UNIQ_PERM_TPL_CHARAC" ON "PERM_TPL_CHARACTERISTICS"("TEMPLATE_ID", "PERMISSION_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/MakePermTplCharacteristicsUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/MakePermTplCharacteristicsUuidColumnNotNullableTest/schema.sql new file mode 100644 index 00000000000..ea986ff54d8 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/MakePermTplCharacteristicsUuidColumnNotNullableTest/schema.sql @@ -0,0 +1,11 @@ +CREATE TABLE "PERM_TPL_CHARACTERISTICS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40), + "TEMPLATE_ID" INTEGER NOT NULL, + "PERMISSION_KEY" VARCHAR(64) NOT NULL, + "WITH_PROJECT_CREATOR" BOOLEAN DEFAULT FALSE NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL +); +ALTER TABLE "PERM_TPL_CHARACTERISTICS" ADD CONSTRAINT "PK_PERM_TPL_CHARACTERISTICS" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "UNIQ_PERM_TPL_CHARAC" ON "PERM_TPL_CHARACTERISTICS"("TEMPLATE_ID", "PERMISSION_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/PopulatePermTplCharacteristicsUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/PopulatePermTplCharacteristicsUuidTest/schema.sql new file mode 100644 index 00000000000..ea986ff54d8 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/PopulatePermTplCharacteristicsUuidTest/schema.sql @@ -0,0 +1,11 @@ +CREATE TABLE "PERM_TPL_CHARACTERISTICS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40), + "TEMPLATE_ID" INTEGER NOT NULL, + "PERMISSION_KEY" VARCHAR(64) NOT NULL, + "WITH_PROJECT_CREATOR" BOOLEAN DEFAULT FALSE NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL +); +ALTER TABLE "PERM_TPL_CHARACTERISTICS" ADD CONSTRAINT "PK_PERM_TPL_CHARACTERISTICS" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "UNIQ_PERM_TPL_CHARAC" ON "PERM_TPL_CHARACTERISTICS"("TEMPLATE_ID", "PERMISSION_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddPrimaryKeyOnUuidColumnOfProjectMeasureTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddPrimaryKeyOnUuidColumnOfProjectMeasureTableTest/schema.sql new file mode 100644 index 00000000000..81664d485b2 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddPrimaryKeyOnUuidColumnOfProjectMeasureTableTest/schema.sql @@ -0,0 +1,21 @@ +CREATE TABLE "PROJECT_MEASURES"( + "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "VALUE" DOUBLE, + "METRIC_ID" INTEGER NOT NULL, + "ANALYSIS_UUID" VARCHAR(50) NOT NULL, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "TEXT_VALUE" VARCHAR(4000), + "ALERT_STATUS" VARCHAR(5), + "ALERT_TEXT" VARCHAR(4000), + "DESCRIPTION" VARCHAR(4000), + "PERSON_ID" INTEGER, + "VARIATION_VALUE_1" DOUBLE, + "VARIATION_VALUE_2" DOUBLE, + "VARIATION_VALUE_3" DOUBLE, + "VARIATION_VALUE_4" DOUBLE, + "VARIATION_VALUE_5" DOUBLE, + "MEASURE_DATA" BLOB +); +CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES"("ANALYSIS_UUID", "METRIC_ID"); +CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddUuidToProjectMeasuresTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddUuidToProjectMeasuresTest/schema.sql new file mode 100644 index 00000000000..3ff9ce0fef9 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddUuidToProjectMeasuresTest/schema.sql @@ -0,0 +1,21 @@ +CREATE TABLE "PROJECT_MEASURES"( + "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), + "VALUE" DOUBLE, + "METRIC_ID" INTEGER NOT NULL, + "ANALYSIS_UUID" VARCHAR(50) NOT NULL, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "TEXT_VALUE" VARCHAR(4000), + "ALERT_STATUS" VARCHAR(5), + "ALERT_TEXT" VARCHAR(4000), + "DESCRIPTION" VARCHAR(4000), + "PERSON_ID" INTEGER, + "VARIATION_VALUE_1" DOUBLE, + "VARIATION_VALUE_2" DOUBLE, + "VARIATION_VALUE_3" DOUBLE, + "VARIATION_VALUE_4" DOUBLE, + "VARIATION_VALUE_5" DOUBLE, + "MEASURE_DATA" BLOB +); +ALTER TABLE "PROJECT_MEASURES" ADD CONSTRAINT "PK_PROJECT_MEASURES" PRIMARY KEY("ID"); +CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES"("ANALYSIS_UUID", "METRIC_ID"); +CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropIdColumnOfProjectMeasuresTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropIdColumnOfProjectMeasuresTableTest/schema.sql new file mode 100644 index 00000000000..f66002cb755 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropIdColumnOfProjectMeasuresTableTest/schema.sql @@ -0,0 +1,22 @@ +CREATE TABLE "PROJECT_MEASURES"( + "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "VALUE" DOUBLE, + "METRIC_ID" INTEGER NOT NULL, + "ANALYSIS_UUID" VARCHAR(50) NOT NULL, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "TEXT_VALUE" VARCHAR(4000), + "ALERT_STATUS" VARCHAR(5), + "ALERT_TEXT" VARCHAR(4000), + "DESCRIPTION" VARCHAR(4000), + "PERSON_ID" INTEGER, + "VARIATION_VALUE_1" DOUBLE, + "VARIATION_VALUE_2" DOUBLE, + "VARIATION_VALUE_3" DOUBLE, + "VARIATION_VALUE_4" DOUBLE, + "VARIATION_VALUE_5" DOUBLE, + "MEASURE_DATA" BLOB +); +ALTER TABLE "PROJECT_MEASURES" ADD CONSTRAINT "PK_PROJECT_MEASURES" PRIMARY KEY("UUID"); +CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES"("ANALYSIS_UUID", "METRIC_ID"); +CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropPrimaryKeyOnIdColumnOfProjectMeasuresTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropPrimaryKeyOnIdColumnOfProjectMeasuresTableTest/schema.sql new file mode 100644 index 00000000000..fd01be5f1bd --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropPrimaryKeyOnIdColumnOfProjectMeasuresTableTest/schema.sql @@ -0,0 +1,22 @@ +CREATE TABLE "PROJECT_MEASURES"( + "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "VALUE" DOUBLE, + "METRIC_ID" INTEGER NOT NULL, + "ANALYSIS_UUID" VARCHAR(50) NOT NULL, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "TEXT_VALUE" VARCHAR(4000), + "ALERT_STATUS" VARCHAR(5), + "ALERT_TEXT" VARCHAR(4000), + "DESCRIPTION" VARCHAR(4000), + "PERSON_ID" INTEGER, + "VARIATION_VALUE_1" DOUBLE, + "VARIATION_VALUE_2" DOUBLE, + "VARIATION_VALUE_3" DOUBLE, + "VARIATION_VALUE_4" DOUBLE, + "VARIATION_VALUE_5" DOUBLE, + "MEASURE_DATA" BLOB +); +ALTER TABLE "PROJECT_MEASURES" ADD CONSTRAINT "PK_PROJECT_MEASURES" PRIMARY KEY("ID"); +CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES"("ANALYSIS_UUID", "METRIC_ID"); +CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/MakeProjectMeasuresUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/MakeProjectMeasuresUuidColumnNotNullableTest/schema.sql new file mode 100644 index 00000000000..ba02385e040 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/MakeProjectMeasuresUuidColumnNotNullableTest/schema.sql @@ -0,0 +1,22 @@ +CREATE TABLE "PROJECT_MEASURES"( + "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40), + "VALUE" DOUBLE, + "METRIC_ID" INTEGER NOT NULL, + "ANALYSIS_UUID" VARCHAR(50) NOT NULL, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "TEXT_VALUE" VARCHAR(4000), + "ALERT_STATUS" VARCHAR(5), + "ALERT_TEXT" VARCHAR(4000), + "DESCRIPTION" VARCHAR(4000), + "PERSON_ID" INTEGER, + "VARIATION_VALUE_1" DOUBLE, + "VARIATION_VALUE_2" DOUBLE, + "VARIATION_VALUE_3" DOUBLE, + "VARIATION_VALUE_4" DOUBLE, + "VARIATION_VALUE_5" DOUBLE, + "MEASURE_DATA" BLOB +); +ALTER TABLE "PROJECT_MEASURES" ADD CONSTRAINT "PK_PROJECT_MEASURES" PRIMARY KEY("ID"); +CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES"("ANALYSIS_UUID", "METRIC_ID"); +CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/PopulateProjectMeasuresUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/PopulateProjectMeasuresUuidTest/schema.sql new file mode 100644 index 00000000000..ba02385e040 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectmeasures/PopulateProjectMeasuresUuidTest/schema.sql @@ -0,0 +1,22 @@ +CREATE TABLE "PROJECT_MEASURES"( + "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40), + "VALUE" DOUBLE, + "METRIC_ID" INTEGER NOT NULL, + "ANALYSIS_UUID" VARCHAR(50) NOT NULL, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "TEXT_VALUE" VARCHAR(4000), + "ALERT_STATUS" VARCHAR(5), + "ALERT_TEXT" VARCHAR(4000), + "DESCRIPTION" VARCHAR(4000), + "PERSON_ID" INTEGER, + "VARIATION_VALUE_1" DOUBLE, + "VARIATION_VALUE_2" DOUBLE, + "VARIATION_VALUE_3" DOUBLE, + "VARIATION_VALUE_4" DOUBLE, + "VARIATION_VALUE_5" DOUBLE, + "MEASURE_DATA" BLOB +); +ALTER TABLE "PROJECT_MEASURES" ADD CONSTRAINT "PK_PROJECT_MEASURES" PRIMARY KEY("ID"); +CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES"("ANALYSIS_UUID", "METRIC_ID"); +CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTableTest/schema.sql new file mode 100644 index 00000000000..b294830aee9 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTableTest/schema.sql @@ -0,0 +1,7 @@ +CREATE TABLE "PROJECT_QPROFILES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "PROJECT_UUID" VARCHAR(50) NOT NULL, + "PROFILE_KEY" VARCHAR(50) NOT NULL +); +CREATE UNIQUE INDEX "UNIQ_PROJECT_QPROFILES" ON "PROJECT_QPROFILES"("PROJECT_UUID", "PROFILE_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddUuidColumnToProjectQProfilesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddUuidColumnToProjectQProfilesTableTest/schema.sql new file mode 100644 index 00000000000..c7530b1d254 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddUuidColumnToProjectQProfilesTableTest/schema.sql @@ -0,0 +1,7 @@ +CREATE TABLE "PROJECT_QPROFILES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "PROJECT_UUID" VARCHAR(50) NOT NULL, + "PROFILE_KEY" VARCHAR(50) NOT NULL +); +ALTER TABLE "PROJECT_QPROFILES" ADD CONSTRAINT "PK_PROJECT_QPROFILES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "UNIQ_PROJECT_QPROFILES" ON "PROJECT_QPROFILES"("PROJECT_UUID", "PROFILE_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropIdColumnOfProjectQProfilesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropIdColumnOfProjectQProfilesTableTest/schema.sql new file mode 100644 index 00000000000..d531ef1fa69 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropIdColumnOfProjectQProfilesTableTest/schema.sql @@ -0,0 +1,8 @@ +CREATE TABLE "PROJECT_QPROFILES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "PROJECT_UUID" VARCHAR(50) NOT NULL, + "PROFILE_KEY" VARCHAR(50) NOT NULL +); +ALTER TABLE "PROJECT_QPROFILES" ADD CONSTRAINT "PK_PROJECT_QPROFILES" PRIMARY KEY("UUID"); +CREATE UNIQUE INDEX "UNIQ_PROJECT_QPROFILES" ON "PROJECT_QPROFILES"("PROJECT_UUID", "PROFILE_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest/schema.sql new file mode 100644 index 00000000000..75824e05246 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest/schema.sql @@ -0,0 +1,8 @@ +CREATE TABLE "PROJECT_QPROFILES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "PROJECT_UUID" VARCHAR(50) NOT NULL, + "PROFILE_KEY" VARCHAR(50) NOT NULL +); +ALTER TABLE "PROJECT_QPROFILES" ADD CONSTRAINT "PK_PROJECT_QPROFILES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "UNIQ_PROJECT_QPROFILES" ON "PROJECT_QPROFILES"("PROJECT_UUID", "PROFILE_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/MakeProjectQProfilesUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/MakeProjectQProfilesUuidColumnNotNullableTest/schema.sql new file mode 100644 index 00000000000..f961bdc422c --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/MakeProjectQProfilesUuidColumnNotNullableTest/schema.sql @@ -0,0 +1,8 @@ +CREATE TABLE "PROJECT_QPROFILES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40), + "PROJECT_UUID" VARCHAR(50) NOT NULL, + "PROFILE_KEY" VARCHAR(50) NOT NULL +); +ALTER TABLE "PROJECT_QPROFILES" ADD CONSTRAINT "PK_PROJECT_QPROFILES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "UNIQ_PROJECT_QPROFILES" ON "PROJECT_QPROFILES"("PROJECT_UUID", "PROFILE_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/PopulateProjectQProfilesUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/PopulateProjectQProfilesUuidTest/schema.sql new file mode 100644 index 00000000000..f961bdc422c --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/PopulateProjectQProfilesUuidTest/schema.sql @@ -0,0 +1,8 @@ +CREATE TABLE "PROJECT_QPROFILES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40), + "PROJECT_UUID" VARCHAR(50) NOT NULL, + "PROFILE_KEY" VARCHAR(50) NOT NULL +); +ALTER TABLE "PROJECT_QPROFILES" ADD CONSTRAINT "PK_PROJECT_QPROFILES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "UNIQ_PROJECT_QPROFILES" ON "PROJECT_QPROFILES"("PROJECT_UUID", "PROFILE_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/AddPrimaryKeyOnUuidColumnOfPropertiesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/AddPrimaryKeyOnUuidColumnOfPropertiesTableTest/schema.sql new file mode 100644 index 00000000000..e2598421ec2 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/AddPrimaryKeyOnUuidColumnOfPropertiesTableTest/schema.sql @@ -0,0 +1,12 @@ +CREATE TABLE "PROPERTIES"( + "ID" INTEGER NOT NULL, + "UUID" VARCHAR(40) NOT NULL, + "PROP_KEY" VARCHAR(512) NOT NULL, + "RESOURCE_ID" BIGINT, + "USER_ID" BIGINT, + "IS_EMPTY" BOOLEAN NOT NULL, + "TEXT_VALUE" VARCHAR(4000), + "CLOB_VALUE" CLOB(2147483647), + "CREATED_AT" BIGINT NOT NULL +); +CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES"("PROP_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/AddUuidColumnToPropertiesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/AddUuidColumnToPropertiesTest/schema.sql new file mode 100644 index 00000000000..2ac16011ffb --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/AddUuidColumnToPropertiesTest/schema.sql @@ -0,0 +1,12 @@ +CREATE TABLE "PROPERTIES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "PROP_KEY" VARCHAR(512) NOT NULL, + "RESOURCE_ID" BIGINT, + "USER_ID" BIGINT, + "IS_EMPTY" BOOLEAN NOT NULL, + "TEXT_VALUE" VARCHAR(4000), + "CLOB_VALUE" CLOB(2147483647), + "CREATED_AT" BIGINT NOT NULL +); +ALTER TABLE "PROPERTIES" ADD CONSTRAINT "PK_PROPERTIES" PRIMARY KEY("ID"); +CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES"("PROP_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/DropIdColumnOfPropertiesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/DropIdColumnOfPropertiesTableTest/schema.sql new file mode 100644 index 00000000000..363c084bb6f --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/DropIdColumnOfPropertiesTableTest/schema.sql @@ -0,0 +1,13 @@ +CREATE TABLE "PROPERTIES"( + "ID" INTEGER NOT NULL, + "UUID" VARCHAR(40) NOT NULL, + "PROP_KEY" VARCHAR(512) NOT NULL, + "RESOURCE_ID" BIGINT, + "USER_ID" BIGINT, + "IS_EMPTY" BOOLEAN NOT NULL, + "TEXT_VALUE" VARCHAR(4000), + "CLOB_VALUE" CLOB(2147483647), + "CREATED_AT" BIGINT NOT NULL +); +ALTER TABLE "PROPERTIES" ADD CONSTRAINT "PK_PROPERTIES" PRIMARY KEY("UUID"); +CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES"("PROP_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/DropPrimaryKeyOnIdColumnOfPropertiesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/DropPrimaryKeyOnIdColumnOfPropertiesTableTest/schema.sql new file mode 100644 index 00000000000..87e741f36e3 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/DropPrimaryKeyOnIdColumnOfPropertiesTableTest/schema.sql @@ -0,0 +1,13 @@ +CREATE TABLE "PROPERTIES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "PROP_KEY" VARCHAR(512) NOT NULL, + "RESOURCE_ID" BIGINT, + "USER_ID" BIGINT, + "IS_EMPTY" BOOLEAN NOT NULL, + "TEXT_VALUE" VARCHAR(4000), + "CLOB_VALUE" CLOB(2147483647), + "CREATED_AT" BIGINT NOT NULL +); +ALTER TABLE "PROPERTIES" ADD CONSTRAINT "PK_PROPERTIES" PRIMARY KEY("ID"); +CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES"("PROP_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/MakeNotificationUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/MakeNotificationUuidColumnNotNullableTest/schema.sql new file mode 100644 index 00000000000..8b61cd12907 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/MakeNotificationUuidColumnNotNullableTest/schema.sql @@ -0,0 +1,13 @@ +CREATE TABLE "PROPERTIES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40), + "PROP_KEY" VARCHAR(512) NOT NULL, + "RESOURCE_ID" BIGINT, + "USER_ID" BIGINT, + "IS_EMPTY" BOOLEAN NOT NULL, + "TEXT_VALUE" VARCHAR(4000), + "CLOB_VALUE" CLOB(2147483647), + "CREATED_AT" BIGINT NOT NULL +); +ALTER TABLE "PROPERTIES" ADD CONSTRAINT "PK_PROPERTIES" PRIMARY KEY("ID"); +CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES"("PROP_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/MakePropertiesUuidColumnNotNullable/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/MakePropertiesUuidColumnNotNullable/schema.sql new file mode 100644 index 00000000000..9b6848f3a3c --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/MakePropertiesUuidColumnNotNullable/schema.sql @@ -0,0 +1,13 @@ +CREATE TABLE "PROPERTIES"( + "ID" INTEGER, + "UUID" VARCHAR(40), + "PROP_KEY" VARCHAR(512) NOT NULL, + "RESOURCE_ID" BIGINT, + "USER_ID" BIGINT, + "IS_EMPTY" BOOLEAN NOT NULL, + "TEXT_VALUE" VARCHAR(4000), + "CLOB_VALUE" CLOB(2147483647), + "CREATED_AT" BIGINT NOT NULL +); +ALTER TABLE "PROPERTIES" ADD CONSTRAINT "PK_PROPERTIES" PRIMARY KEY("ID"); +CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES"("PROP_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/PopulatePropertiesUuidAndCreatedAtTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/PopulatePropertiesUuidAndCreatedAtTest/schema.sql new file mode 100644 index 00000000000..8b61cd12907 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/properties/PopulatePropertiesUuidAndCreatedAtTest/schema.sql @@ -0,0 +1,13 @@ +CREATE TABLE "PROPERTIES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40), + "PROP_KEY" VARCHAR(512) NOT NULL, + "RESOURCE_ID" BIGINT, + "USER_ID" BIGINT, + "IS_EMPTY" BOOLEAN NOT NULL, + "TEXT_VALUE" VARCHAR(4000), + "CLOB_VALUE" CLOB(2147483647), + "CREATED_AT" BIGINT NOT NULL +); +ALTER TABLE "PROPERTIES" ADD CONSTRAINT "PK_PROPERTIES" PRIMARY KEY("ID"); +CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES"("PROP_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTableTest/schema.sql new file mode 100644 index 00000000000..eb63669fd7e --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTableTest/schema.sql @@ -0,0 +1,12 @@ +CREATE TABLE "QUALITY_GATE_CONDITIONS"( + "ID" INTEGER NOT NULL, + "UUID" VARCHAR(40) NOT NULL, + "QGATE_ID" INTEGER, + "METRIC_ID" INTEGER, + "PERIOD" INTEGER, + "OPERATOR" VARCHAR(3), + "VALUE_ERROR" VARCHAR(64), + "VALUE_WARNING" VARCHAR(64), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddUuidColumnToQualityGateConditionsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddUuidColumnToQualityGateConditionsTableTest/schema.sql new file mode 100644 index 00000000000..a347b023e66 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddUuidColumnToQualityGateConditionsTableTest/schema.sql @@ -0,0 +1,12 @@ +CREATE TABLE "QUALITY_GATE_CONDITIONS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "QGATE_ID" INTEGER, + "METRIC_ID" INTEGER, + "PERIOD" INTEGER, + "OPERATOR" VARCHAR(3), + "VALUE_ERROR" VARCHAR(64), + "VALUE_WARNING" VARCHAR(64), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "QUALITY_GATE_CONDITIONS" ADD CONSTRAINT "PK_QUALITY_GATE_CONDITIONS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropIdColumnOfQualityGateConditionsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropIdColumnOfQualityGateConditionsTableTest/schema.sql new file mode 100644 index 00000000000..68093696c1e --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropIdColumnOfQualityGateConditionsTableTest/schema.sql @@ -0,0 +1,13 @@ +CREATE TABLE "QUALITY_GATE_CONDITIONS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "QGATE_ID" INTEGER, + "METRIC_ID" INTEGER, + "PERIOD" INTEGER, + "OPERATOR" VARCHAR(3), + "VALUE_ERROR" VARCHAR(64), + "VALUE_WARNING" VARCHAR(64), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "QUALITY_GATE_CONDITIONS" ADD CONSTRAINT "PK_QUALITY_GATE_CONDITIONS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropPrimaryKeyOnIdColumnOfQualityGateConditionsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropPrimaryKeyOnIdColumnOfQualityGateConditionsTableTest/schema.sql new file mode 100644 index 00000000000..751e993b7ee --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropPrimaryKeyOnIdColumnOfQualityGateConditionsTableTest/schema.sql @@ -0,0 +1,13 @@ +CREATE TABLE "QUALITY_GATE_CONDITIONS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "QGATE_ID" INTEGER, + "METRIC_ID" INTEGER, + "PERIOD" INTEGER, + "OPERATOR" VARCHAR(3), + "VALUE_ERROR" VARCHAR(64), + "VALUE_WARNING" VARCHAR(64), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "QUALITY_GATE_CONDITIONS" ADD CONSTRAINT "PK_QUALITY_GATE_CONDITIONS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/MakeQualityGateConditionsUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/MakeQualityGateConditionsUuidColumnNotNullableTest/schema.sql new file mode 100644 index 00000000000..dd697725c44 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/MakeQualityGateConditionsUuidColumnNotNullableTest/schema.sql @@ -0,0 +1,12 @@ +CREATE TABLE "QUALITY_GATE_CONDITIONS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "QGATE_ID" INTEGER, + "METRIC_ID" INTEGER, + "PERIOD" INTEGER, + "OPERATOR" VARCHAR(3), + "VALUE_ERROR" VARCHAR(64), + "VALUE_WARNING" VARCHAR(64), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/PopulateQualityGateConditionsUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/PopulateQualityGateConditionsUuidTest/schema.sql new file mode 100644 index 00000000000..2f6bb7f50c1 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/PopulateQualityGateConditionsUuidTest/schema.sql @@ -0,0 +1,13 @@ +CREATE TABLE "QUALITY_GATE_CONDITIONS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40), + "QGATE_ID" INTEGER, + "METRIC_ID" INTEGER, + "PERIOD" INTEGER, + "OPERATOR" VARCHAR(3), + "VALUE_ERROR" VARCHAR(64), + "VALUE_WARNING" VARCHAR(64), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "QUALITY_GATE_CONDITIONS" ADD CONSTRAINT "PK_QUALITY_GATE_CONDITIONS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddPrimaryKeyOnUuidColumnOfQGatesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddPrimaryKeyOnUuidColumnOfQGatesTableTest/schema.sql new file mode 100644 index 00000000000..11efefb9936 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddPrimaryKeyOnUuidColumnOfQGatesTableTest/schema.sql @@ -0,0 +1,9 @@ +CREATE TABLE "QUALITY_GATES"( + "ID" INTEGER NOT NULL, + "UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(100) NOT NULL, + "IS_BUILT_IN" BOOLEAN NOT NULL, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +CREATE UNIQUE INDEX "UNIQ_QUALITY_GATES_UUID" ON "QUALITY_GATES"("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddQGateUuidColumnForQGateConditionsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddQGateUuidColumnForQGateConditionsTest/schema.sql new file mode 100644 index 00000000000..00b6663de81 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddQGateUuidColumnForQGateConditionsTest/schema.sql @@ -0,0 +1,23 @@ +CREATE TABLE "QUALITY_GATE_CONDITIONS"( + "QGATE_ID" INTEGER, + "METRIC_ID" INTEGER, + "PERIOD" INTEGER, + "OPERATOR" VARCHAR(3), + "VALUE_ERROR" VARCHAR(64), + "VALUE_WARNING" VARCHAR(64), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP, + "UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "QUALITY_GATE_CONDITIONS" ADD CONSTRAINT "PK_QUALITY_GATE_CONDITIONS" PRIMARY KEY("UUID"); + +CREATE TABLE "QUALITY_GATES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(100) NOT NULL, + "IS_BUILT_IN" BOOLEAN NOT NULL, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "QUALITY_GATES" ADD CONSTRAINT "PK_QUALITY_GATES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "UNIQ_QUALITY_GATES_UUID" ON "QUALITY_GATES"("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropIdColumnOfQGateTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropIdColumnOfQGateTableTest/schema.sql new file mode 100644 index 00000000000..dfcae5380ea --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropIdColumnOfQGateTableTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "QUALITY_GATES"( + "ID" INTEGER NOT NULL, + "UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(100) NOT NULL, + "IS_BUILT_IN" BOOLEAN NOT NULL, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "QUALITY_GATES" ADD CONSTRAINT "PK_QUALITY_GATES" PRIMARY KEY("UUID"); + diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropOrphansQGateConditionsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropOrphansQGateConditionsTest/schema.sql new file mode 100644 index 00000000000..497d17eddf5 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropOrphansQGateConditionsTest/schema.sql @@ -0,0 +1,24 @@ +CREATE TABLE "QUALITY_GATE_CONDITIONS"( + "QGATE_ID" INTEGER, + "QGATE_UUID" VARCHAR(40), + "METRIC_ID" INTEGER, + "PERIOD" INTEGER, + "OPERATOR" VARCHAR(3), + "VALUE_ERROR" VARCHAR(64), + "VALUE_WARNING" VARCHAR(64), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP, + "UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "QUALITY_GATE_CONDITIONS" ADD CONSTRAINT "PK_QUALITY_GATE_CONDITIONS" PRIMARY KEY("UUID"); + +CREATE TABLE "QUALITY_GATES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(100) NOT NULL, + "IS_BUILT_IN" BOOLEAN NOT NULL, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "QUALITY_GATES" ADD CONSTRAINT "PK_QUALITY_GATES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "UNIQ_QUALITY_GATES_UUID" ON "QUALITY_GATES"("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropPrimaryKeyOnIdColumnOfQGatesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropPrimaryKeyOnIdColumnOfQGatesTableTest/schema.sql new file mode 100644 index 00000000000..5093408fcda --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropPrimaryKeyOnIdColumnOfQGatesTableTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "QUALITY_GATES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(100) NOT NULL, + "IS_BUILT_IN" BOOLEAN NOT NULL, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "QUALITY_GATES" ADD CONSTRAINT "PK_QUALITY_GATES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "UNIQ_QUALITY_GATES_UUID" ON "QUALITY_GATES"("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropQGateIdColumnForQGateConditionsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropQGateIdColumnForQGateConditionsTest/schema.sql new file mode 100644 index 00000000000..cd2a8e3f853 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropQGateIdColumnForQGateConditionsTest/schema.sql @@ -0,0 +1,13 @@ +CREATE TABLE "QUALITY_GATE_CONDITIONS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "QGATE_ID" INTEGER, + "QGATE_UUID" VARCHAR(40) NOT NULL, + "METRIC_ID" INTEGER, + "PERIOD" INTEGER, + "OPERATOR" VARCHAR(3), + "VALUE_ERROR" VARCHAR(64), + "VALUE_WARNING" VARCHAR(64), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "QUALITY_GATE_CONDITIONS" ADD CONSTRAINT "PK_QUALITY_GATE_CONDITIONS" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropUniqueIndexOnUuidColumnOfQualityGatesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropUniqueIndexOnUuidColumnOfQualityGatesTableTest/schema.sql new file mode 100644 index 00000000000..11efefb9936 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropUniqueIndexOnUuidColumnOfQualityGatesTableTest/schema.sql @@ -0,0 +1,9 @@ +CREATE TABLE "QUALITY_GATES"( + "ID" INTEGER NOT NULL, + "UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(100) NOT NULL, + "IS_BUILT_IN" BOOLEAN NOT NULL, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +CREATE UNIQUE INDEX "UNIQ_QUALITY_GATES_UUID" ON "QUALITY_GATES"("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/MakeQGateUuidColumnNotNullableForQGateConditionsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/MakeQGateUuidColumnNotNullableForQGateConditionsTest/schema.sql new file mode 100644 index 00000000000..5fc71ff5b95 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/MakeQGateUuidColumnNotNullableForQGateConditionsTest/schema.sql @@ -0,0 +1,13 @@ +CREATE TABLE "QUALITY_GATE_CONDITIONS"( + "QGATE_ID" INTEGER, + "QGATE_UUID" VARCHAR(40), + "METRIC_ID" INTEGER, + "PERIOD" INTEGER, + "OPERATOR" VARCHAR(3), + "VALUE_ERROR" VARCHAR(64), + "VALUE_WARNING" VARCHAR(64), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP, + "UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "QUALITY_GATE_CONDITIONS" ADD CONSTRAINT "PK_QUALITY_GATE_CONDITIONS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/PopulateQGateUuidColumnForQGateConditionsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/PopulateQGateUuidColumnForQGateConditionsTest/schema.sql new file mode 100644 index 00000000000..497d17eddf5 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/qualitygates/PopulateQGateUuidColumnForQGateConditionsTest/schema.sql @@ -0,0 +1,24 @@ +CREATE TABLE "QUALITY_GATE_CONDITIONS"( + "QGATE_ID" INTEGER, + "QGATE_UUID" VARCHAR(40), + "METRIC_ID" INTEGER, + "PERIOD" INTEGER, + "OPERATOR" VARCHAR(3), + "VALUE_ERROR" VARCHAR(64), + "VALUE_WARNING" VARCHAR(64), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP, + "UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "QUALITY_GATE_CONDITIONS" ADD CONSTRAINT "PK_QUALITY_GATE_CONDITIONS" PRIMARY KEY("UUID"); + +CREATE TABLE "QUALITY_GATES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(100) NOT NULL, + "IS_BUILT_IN" BOOLEAN NOT NULL, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "QUALITY_GATES" ADD CONSTRAINT "PK_QUALITY_GATES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "UNIQ_QUALITY_GATES_UUID" ON "QUALITY_GATES"("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/AddPrimaryKeyOnUuidColumnOfRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/AddPrimaryKeyOnUuidColumnOfRulesTableTest/schema.sql new file mode 100644 index 00000000000..df25471a0ba --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/AddPrimaryKeyOnUuidColumnOfRulesTableTest/schema.sql @@ -0,0 +1,29 @@ +CREATE TABLE "RULES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "NAME" VARCHAR(200), + "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, + "PLUGIN_KEY" VARCHAR(200), + "PLUGIN_CONFIG_KEY" VARCHAR(200), + "PLUGIN_NAME" VARCHAR(255) NOT NULL, + "SCOPE" VARCHAR(20) NOT NULL, + "DESCRIPTION" CLOB(2147483647), + "PRIORITY" INTEGER, + "STATUS" VARCHAR(40), + "LANGUAGE" VARCHAR(20), + "DEF_REMEDIATION_FUNCTION" VARCHAR(20), + "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), + "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), + "GAP_DESCRIPTION" VARCHAR(4000), + "SYSTEM_TAGS" VARCHAR(4000), + "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, + "DESCRIPTION_FORMAT" VARCHAR(20), + "RULE_TYPE" TINYINT, + "SECURITY_STANDARDS" VARCHAR(4000), + "IS_AD_HOC" BOOLEAN NOT NULL, + "IS_EXTERNAL" BOOLEAN NOT NULL, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_UUID" VARCHAR(40) +); +CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/AddUuidAndTemplateUuidColumnsToRulesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/AddUuidAndTemplateUuidColumnsToRulesTest/schema.sql new file mode 100644 index 00000000000..66e55fb1b3f --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/AddUuidAndTemplateUuidColumnsToRulesTest/schema.sql @@ -0,0 +1,29 @@ +CREATE TABLE "RULES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "NAME" VARCHAR(200), + "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, + "PLUGIN_KEY" VARCHAR(200), + "PLUGIN_CONFIG_KEY" VARCHAR(200), + "PLUGIN_NAME" VARCHAR(255) NOT NULL, + "SCOPE" VARCHAR(20) NOT NULL, + "DESCRIPTION" CLOB(2147483647), + "PRIORITY" INTEGER, + "TEMPLATE_ID" INTEGER, + "STATUS" VARCHAR(40), + "LANGUAGE" VARCHAR(20), + "DEF_REMEDIATION_FUNCTION" VARCHAR(20), + "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), + "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), + "GAP_DESCRIPTION" VARCHAR(4000), + "SYSTEM_TAGS" VARCHAR(4000), + "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, + "DESCRIPTION_FORMAT" VARCHAR(20), + "RULE_TYPE" TINYINT, + "SECURITY_STANDARDS" VARCHAR(4000), + "IS_AD_HOC" BOOLEAN NOT NULL, + "IS_EXTERNAL" BOOLEAN NOT NULL, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT +); +ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/DropIdColumnOfRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/DropIdColumnOfRulesTableTest/schema.sql new file mode 100644 index 00000000000..4045c3e578a --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/DropIdColumnOfRulesTableTest/schema.sql @@ -0,0 +1,30 @@ +CREATE TABLE "RULES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "NAME" VARCHAR(200), + "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, + "PLUGIN_KEY" VARCHAR(200), + "PLUGIN_CONFIG_KEY" VARCHAR(200), + "PLUGIN_NAME" VARCHAR(255) NOT NULL, + "SCOPE" VARCHAR(20) NOT NULL, + "DESCRIPTION" CLOB(2147483647), + "PRIORITY" INTEGER, + "STATUS" VARCHAR(40), + "LANGUAGE" VARCHAR(20), + "DEF_REMEDIATION_FUNCTION" VARCHAR(20), + "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), + "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), + "GAP_DESCRIPTION" VARCHAR(4000), + "SYSTEM_TAGS" VARCHAR(4000), + "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, + "DESCRIPTION_FORMAT" VARCHAR(20), + "RULE_TYPE" TINYINT, + "SECURITY_STANDARDS" VARCHAR(4000), + "IS_AD_HOC" BOOLEAN NOT NULL, + "IS_EXTERNAL" BOOLEAN NOT NULL, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_UUID" VARCHAR(40) +); +ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("UUID"); +CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/DropPrimaryKeyOnIdColumnOfRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/DropPrimaryKeyOnIdColumnOfRulesTableTest/schema.sql new file mode 100644 index 00000000000..04dc8de79c8 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/DropPrimaryKeyOnIdColumnOfRulesTableTest/schema.sql @@ -0,0 +1,30 @@ +CREATE TABLE "RULES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "NAME" VARCHAR(200), + "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, + "PLUGIN_KEY" VARCHAR(200), + "PLUGIN_CONFIG_KEY" VARCHAR(200), + "PLUGIN_NAME" VARCHAR(255) NOT NULL, + "SCOPE" VARCHAR(20) NOT NULL, + "DESCRIPTION" CLOB(2147483647), + "PRIORITY" INTEGER, + "STATUS" VARCHAR(40), + "LANGUAGE" VARCHAR(20), + "DEF_REMEDIATION_FUNCTION" VARCHAR(20), + "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), + "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), + "GAP_DESCRIPTION" VARCHAR(4000), + "SYSTEM_TAGS" VARCHAR(4000), + "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, + "DESCRIPTION_FORMAT" VARCHAR(20), + "RULE_TYPE" TINYINT, + "SECURITY_STANDARDS" VARCHAR(4000), + "IS_AD_HOC" BOOLEAN NOT NULL, + "IS_EXTERNAL" BOOLEAN NOT NULL, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_UUID" VARCHAR(40) +); +ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/DropTemplateIdColumnOfRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/DropTemplateIdColumnOfRulesTableTest/schema.sql new file mode 100644 index 00000000000..ee19fb605ea --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/DropTemplateIdColumnOfRulesTableTest/schema.sql @@ -0,0 +1,31 @@ +CREATE TABLE "RULES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "NAME" VARCHAR(200), + "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, + "PLUGIN_KEY" VARCHAR(200), + "PLUGIN_CONFIG_KEY" VARCHAR(200), + "PLUGIN_NAME" VARCHAR(255) NOT NULL, + "SCOPE" VARCHAR(20) NOT NULL, + "DESCRIPTION" CLOB(2147483647), + "PRIORITY" INTEGER, + "TEMPLATE_ID" INTEGER, + "STATUS" VARCHAR(40), + "LANGUAGE" VARCHAR(20), + "DEF_REMEDIATION_FUNCTION" VARCHAR(20), + "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), + "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), + "GAP_DESCRIPTION" VARCHAR(4000), + "SYSTEM_TAGS" VARCHAR(4000), + "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, + "DESCRIPTION_FORMAT" VARCHAR(20), + "RULE_TYPE" TINYINT, + "SECURITY_STANDARDS" VARCHAR(4000), + "IS_AD_HOC" BOOLEAN NOT NULL, + "IS_EXTERNAL" BOOLEAN NOT NULL, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_UUID" VARCHAR(40) +); +ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/MakeRulesUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/MakeRulesUuidColumnNotNullableTest/schema.sql new file mode 100644 index 00000000000..e2d578ae008 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/MakeRulesUuidColumnNotNullableTest/schema.sql @@ -0,0 +1,31 @@ +CREATE TABLE "RULES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "NAME" VARCHAR(200), + "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, + "PLUGIN_KEY" VARCHAR(200), + "PLUGIN_CONFIG_KEY" VARCHAR(200), + "PLUGIN_NAME" VARCHAR(255) NOT NULL, + "SCOPE" VARCHAR(20) NOT NULL, + "DESCRIPTION" CLOB(2147483647), + "PRIORITY" INTEGER, + "TEMPLATE_ID" INTEGER, + "STATUS" VARCHAR(40), + "LANGUAGE" VARCHAR(20), + "DEF_REMEDIATION_FUNCTION" VARCHAR(20), + "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), + "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), + "GAP_DESCRIPTION" VARCHAR(4000), + "SYSTEM_TAGS" VARCHAR(4000), + "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, + "DESCRIPTION_FORMAT" VARCHAR(20), + "RULE_TYPE" TINYINT, + "SECURITY_STANDARDS" VARCHAR(4000), + "IS_AD_HOC" BOOLEAN NOT NULL, + "IS_EXTERNAL" BOOLEAN NOT NULL, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "UUID" VARCHAR(40), + "TEMPLATE_UUID" VARCHAR(40) +); +ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/PopulateRulesTemplateUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/PopulateRulesTemplateUuidTest/schema.sql new file mode 100644 index 00000000000..ee19fb605ea --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/PopulateRulesTemplateUuidTest/schema.sql @@ -0,0 +1,31 @@ +CREATE TABLE "RULES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "NAME" VARCHAR(200), + "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, + "PLUGIN_KEY" VARCHAR(200), + "PLUGIN_CONFIG_KEY" VARCHAR(200), + "PLUGIN_NAME" VARCHAR(255) NOT NULL, + "SCOPE" VARCHAR(20) NOT NULL, + "DESCRIPTION" CLOB(2147483647), + "PRIORITY" INTEGER, + "TEMPLATE_ID" INTEGER, + "STATUS" VARCHAR(40), + "LANGUAGE" VARCHAR(20), + "DEF_REMEDIATION_FUNCTION" VARCHAR(20), + "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), + "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), + "GAP_DESCRIPTION" VARCHAR(4000), + "SYSTEM_TAGS" VARCHAR(4000), + "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, + "DESCRIPTION_FORMAT" VARCHAR(20), + "RULE_TYPE" TINYINT, + "SECURITY_STANDARDS" VARCHAR(4000), + "IS_AD_HOC" BOOLEAN NOT NULL, + "IS_EXTERNAL" BOOLEAN NOT NULL, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_UUID" VARCHAR(40) +); +ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/PopulateRulesUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/PopulateRulesUuidTest/schema.sql new file mode 100644 index 00000000000..e2d578ae008 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/PopulateRulesUuidTest/schema.sql @@ -0,0 +1,31 @@ +CREATE TABLE "RULES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "NAME" VARCHAR(200), + "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, + "PLUGIN_KEY" VARCHAR(200), + "PLUGIN_CONFIG_KEY" VARCHAR(200), + "PLUGIN_NAME" VARCHAR(255) NOT NULL, + "SCOPE" VARCHAR(20) NOT NULL, + "DESCRIPTION" CLOB(2147483647), + "PRIORITY" INTEGER, + "TEMPLATE_ID" INTEGER, + "STATUS" VARCHAR(40), + "LANGUAGE" VARCHAR(20), + "DEF_REMEDIATION_FUNCTION" VARCHAR(20), + "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), + "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), + "GAP_DESCRIPTION" VARCHAR(4000), + "SYSTEM_TAGS" VARCHAR(4000), + "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, + "DESCRIPTION_FORMAT" VARCHAR(20), + "RULE_TYPE" TINYINT, + "SECURITY_STANDARDS" VARCHAR(4000), + "IS_AD_HOC" BOOLEAN NOT NULL, + "IS_EXTERNAL" BOOLEAN NOT NULL, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "UUID" VARCHAR(40), + "TEMPLATE_UUID" VARCHAR(40) +); +ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/activerules/AddIndexToActiveRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/activerules/AddIndexToActiveRulesTableTest/schema.sql new file mode 100644 index 00000000000..b3b1b4d7c04 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/activerules/AddIndexToActiveRulesTableTest/schema.sql @@ -0,0 +1,42 @@ +CREATE TABLE "RULES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "NAME" VARCHAR(200), + "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, + "PLUGIN_KEY" VARCHAR(200), + "PLUGIN_CONFIG_KEY" VARCHAR(200), + "PLUGIN_NAME" VARCHAR(255) NOT NULL, + "SCOPE" VARCHAR(20) NOT NULL, + "DESCRIPTION" CLOB(2147483647), + "PRIORITY" INTEGER, + "STATUS" VARCHAR(40), + "LANGUAGE" VARCHAR(20), + "DEF_REMEDIATION_FUNCTION" VARCHAR(20), + "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), + "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), + "GAP_DESCRIPTION" VARCHAR(4000), + "SYSTEM_TAGS" VARCHAR(4000), + "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, + "DESCRIPTION_FORMAT" VARCHAR(20), + "RULE_TYPE" TINYINT, + "SECURITY_STANDARDS" VARCHAR(4000), + "IS_AD_HOC" BOOLEAN NOT NULL, + "IS_EXTERNAL" BOOLEAN NOT NULL, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_UUID" VARCHAR(40) +); +ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); + +CREATE TABLE "ACTIVE_RULES"( + "RULE_ID" INTEGER NOT NULL, + "FAILURE_LEVEL" INTEGER NOT NULL, + "INHERITANCE" VARCHAR(10), + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "UUID" VARCHAR(40) NOT NULL, + "PROFILE_UUID" VARCHAR(40) NOT NULL, + "RULE_UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/activerules/AddRuleUuidColumnToActiveRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/activerules/AddRuleUuidColumnToActiveRulesTableTest/schema.sql new file mode 100644 index 00000000000..d05e47d8bc5 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/activerules/AddRuleUuidColumnToActiveRulesTableTest/schema.sql @@ -0,0 +1,42 @@ +CREATE TABLE "RULES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "NAME" VARCHAR(200), + "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, + "PLUGIN_KEY" VARCHAR(200), + "PLUGIN_CONFIG_KEY" VARCHAR(200), + "PLUGIN_NAME" VARCHAR(255) NOT NULL, + "SCOPE" VARCHAR(20) NOT NULL, + "DESCRIPTION" CLOB(2147483647), + "PRIORITY" INTEGER, + "STATUS" VARCHAR(40), + "LANGUAGE" VARCHAR(20), + "DEF_REMEDIATION_FUNCTION" VARCHAR(20), + "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), + "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), + "GAP_DESCRIPTION" VARCHAR(4000), + "SYSTEM_TAGS" VARCHAR(4000), + "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, + "DESCRIPTION_FORMAT" VARCHAR(20), + "RULE_TYPE" TINYINT, + "SECURITY_STANDARDS" VARCHAR(4000), + "IS_AD_HOC" BOOLEAN NOT NULL, + "IS_EXTERNAL" BOOLEAN NOT NULL, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_UUID" VARCHAR(40) +); +ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); + +CREATE TABLE "ACTIVE_RULES"( + "RULE_ID" INTEGER NOT NULL, + "FAILURE_LEVEL" INTEGER NOT NULL, + "INHERITANCE" VARCHAR(10), + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "UUID" VARCHAR(40) NOT NULL, + "PROFILE_UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("UUID"); +CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_UUID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/activerules/DropIndexOnRuleIdColumnOfActiveRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/activerules/DropIndexOnRuleIdColumnOfActiveRulesTableTest/schema.sql new file mode 100644 index 00000000000..9156127c902 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/activerules/DropIndexOnRuleIdColumnOfActiveRulesTableTest/schema.sql @@ -0,0 +1,43 @@ +CREATE TABLE "RULES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "NAME" VARCHAR(200), + "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, + "PLUGIN_KEY" VARCHAR(200), + "PLUGIN_CONFIG_KEY" VARCHAR(200), + "PLUGIN_NAME" VARCHAR(255) NOT NULL, + "SCOPE" VARCHAR(20) NOT NULL, + "DESCRIPTION" CLOB(2147483647), + "PRIORITY" INTEGER, + "STATUS" VARCHAR(40), + "LANGUAGE" VARCHAR(20), + "DEF_REMEDIATION_FUNCTION" VARCHAR(20), + "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), + "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), + "GAP_DESCRIPTION" VARCHAR(4000), + "SYSTEM_TAGS" VARCHAR(4000), + "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, + "DESCRIPTION_FORMAT" VARCHAR(20), + "RULE_TYPE" TINYINT, + "SECURITY_STANDARDS" VARCHAR(4000), + "IS_AD_HOC" BOOLEAN NOT NULL, + "IS_EXTERNAL" BOOLEAN NOT NULL, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_UUID" VARCHAR(40) +); +ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); + +CREATE TABLE "ACTIVE_RULES"( + "RULE_ID" INTEGER NOT NULL, + "FAILURE_LEVEL" INTEGER NOT NULL, + "INHERITANCE" VARCHAR(10), + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "UUID" VARCHAR(40) NOT NULL, + "PROFILE_UUID" VARCHAR(40) NOT NULL, + "RULE_UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("UUID"); +CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_UUID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/activerules/DropRuleIdColumnOfActiveRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/activerules/DropRuleIdColumnOfActiveRulesTableTest/schema.sql new file mode 100644 index 00000000000..d786db82af6 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/activerules/DropRuleIdColumnOfActiveRulesTableTest/schema.sql @@ -0,0 +1,43 @@ +CREATE TABLE "RULES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "NAME" VARCHAR(200), + "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, + "PLUGIN_KEY" VARCHAR(200), + "PLUGIN_CONFIG_KEY" VARCHAR(200), + "PLUGIN_NAME" VARCHAR(255) NOT NULL, + "SCOPE" VARCHAR(20) NOT NULL, + "DESCRIPTION" CLOB(2147483647), + "PRIORITY" INTEGER, + "STATUS" VARCHAR(40), + "LANGUAGE" VARCHAR(20), + "DEF_REMEDIATION_FUNCTION" VARCHAR(20), + "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), + "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), + "GAP_DESCRIPTION" VARCHAR(4000), + "SYSTEM_TAGS" VARCHAR(4000), + "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, + "DESCRIPTION_FORMAT" VARCHAR(20), + "RULE_TYPE" TINYINT, + "SECURITY_STANDARDS" VARCHAR(4000), + "IS_AD_HOC" BOOLEAN NOT NULL, + "IS_EXTERNAL" BOOLEAN NOT NULL, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_UUID" VARCHAR(40) +); +ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); + +CREATE TABLE "ACTIVE_RULES"( + "RULE_ID" INTEGER NOT NULL, + "FAILURE_LEVEL" INTEGER NOT NULL, + "INHERITANCE" VARCHAR(10), + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "UUID" VARCHAR(40) NOT NULL, + "PROFILE_UUID" VARCHAR(40) NOT NULL, + "RULE_UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("UUID"); +CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_UUIDS" ON "ACTIVE_RULES"("PROFILE_UUID", "RULE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/activerules/MakeActiveRulesRuleUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/activerules/MakeActiveRulesRuleUuidColumnNotNullableTest/schema.sql new file mode 100644 index 00000000000..ac68fc9c530 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/activerules/MakeActiveRulesRuleUuidColumnNotNullableTest/schema.sql @@ -0,0 +1,43 @@ +CREATE TABLE "RULES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "NAME" VARCHAR(200), + "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, + "PLUGIN_KEY" VARCHAR(200), + "PLUGIN_CONFIG_KEY" VARCHAR(200), + "PLUGIN_NAME" VARCHAR(255) NOT NULL, + "SCOPE" VARCHAR(20) NOT NULL, + "DESCRIPTION" CLOB(2147483647), + "PRIORITY" INTEGER, + "STATUS" VARCHAR(40), + "LANGUAGE" VARCHAR(20), + "DEF_REMEDIATION_FUNCTION" VARCHAR(20), + "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), + "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), + "GAP_DESCRIPTION" VARCHAR(4000), + "SYSTEM_TAGS" VARCHAR(4000), + "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, + "DESCRIPTION_FORMAT" VARCHAR(20), + "RULE_TYPE" TINYINT, + "SECURITY_STANDARDS" VARCHAR(4000), + "IS_AD_HOC" BOOLEAN NOT NULL, + "IS_EXTERNAL" BOOLEAN NOT NULL, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_UUID" VARCHAR(40) +); +ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); + +CREATE TABLE "ACTIVE_RULES"( + "RULE_ID" INTEGER NOT NULL, + "FAILURE_LEVEL" INTEGER NOT NULL, + "INHERITANCE" VARCHAR(10), + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "UUID" VARCHAR(40) NOT NULL, + "PROFILE_UUID" VARCHAR(40) NOT NULL, + "RULE_UUID" VARCHAR(40) +); +ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("UUID"); +CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_UUID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/activerules/PopulateActiveRulesRuleUuidColumnTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/activerules/PopulateActiveRulesRuleUuidColumnTest/schema.sql new file mode 100644 index 00000000000..ac68fc9c530 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/activerules/PopulateActiveRulesRuleUuidColumnTest/schema.sql @@ -0,0 +1,43 @@ +CREATE TABLE "RULES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "NAME" VARCHAR(200), + "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, + "PLUGIN_KEY" VARCHAR(200), + "PLUGIN_CONFIG_KEY" VARCHAR(200), + "PLUGIN_NAME" VARCHAR(255) NOT NULL, + "SCOPE" VARCHAR(20) NOT NULL, + "DESCRIPTION" CLOB(2147483647), + "PRIORITY" INTEGER, + "STATUS" VARCHAR(40), + "LANGUAGE" VARCHAR(20), + "DEF_REMEDIATION_FUNCTION" VARCHAR(20), + "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), + "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), + "GAP_DESCRIPTION" VARCHAR(4000), + "SYSTEM_TAGS" VARCHAR(4000), + "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, + "DESCRIPTION_FORMAT" VARCHAR(20), + "RULE_TYPE" TINYINT, + "SECURITY_STANDARDS" VARCHAR(4000), + "IS_AD_HOC" BOOLEAN NOT NULL, + "IS_EXTERNAL" BOOLEAN NOT NULL, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_UUID" VARCHAR(40) +); +ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); + +CREATE TABLE "ACTIVE_RULES"( + "RULE_ID" INTEGER NOT NULL, + "FAILURE_LEVEL" INTEGER NOT NULL, + "INHERITANCE" VARCHAR(10), + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "UUID" VARCHAR(40) NOT NULL, + "PROFILE_UUID" VARCHAR(40) NOT NULL, + "RULE_UUID" VARCHAR(40) +); +ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("UUID"); +CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_UUID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/AddIndexToDeprecatedRuleKeysTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/AddIndexToDeprecatedRuleKeysTableTest/schema.sql new file mode 100644 index 00000000000..7d99e6c84e9 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/AddIndexToDeprecatedRuleKeysTableTest/schema.sql @@ -0,0 +1,41 @@ +CREATE TABLE "RULES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "NAME" VARCHAR(200), + "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, + "PLUGIN_KEY" VARCHAR(200), + "PLUGIN_CONFIG_KEY" VARCHAR(200), + "PLUGIN_NAME" VARCHAR(255) NOT NULL, + "SCOPE" VARCHAR(20) NOT NULL, + "DESCRIPTION" CLOB(2147483647), + "PRIORITY" INTEGER, + "STATUS" VARCHAR(40), + "LANGUAGE" VARCHAR(20), + "DEF_REMEDIATION_FUNCTION" VARCHAR(20), + "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), + "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), + "GAP_DESCRIPTION" VARCHAR(4000), + "SYSTEM_TAGS" VARCHAR(4000), + "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, + "DESCRIPTION_FORMAT" VARCHAR(20), + "RULE_TYPE" TINYINT, + "SECURITY_STANDARDS" VARCHAR(4000), + "IS_AD_HOC" BOOLEAN NOT NULL, + "IS_EXTERNAL" BOOLEAN NOT NULL, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_UUID" VARCHAR(40) +); +ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); + +CREATE TABLE "DEPRECATED_RULE_KEYS"( + "UUID" VARCHAR(40) NOT NULL, + "RULE_ID" INTEGER NOT NULL, + "OLD_REPOSITORY_KEY" VARCHAR(255) NOT NULL, + "OLD_RULE_KEY" VARCHAR(200) NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "RULE_UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "DEPRECATED_RULE_KEYS" ADD CONSTRAINT "PK_DEPRECATED_RULE_KEYS" PRIMARY KEY("UUID"); +CREATE UNIQUE INDEX "UNIQ_DEPRECATED_RULE_KEYS" ON "DEPRECATED_RULE_KEYS"("OLD_REPOSITORY_KEY", "OLD_RULE_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/AddRuleUuidColumnToDeprecatedRuleKeysTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/AddRuleUuidColumnToDeprecatedRuleKeysTableTest/schema.sql new file mode 100644 index 00000000000..5f7d81c739c --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/AddRuleUuidColumnToDeprecatedRuleKeysTableTest/schema.sql @@ -0,0 +1,41 @@ +CREATE TABLE "RULES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "NAME" VARCHAR(200), + "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, + "PLUGIN_KEY" VARCHAR(200), + "PLUGIN_CONFIG_KEY" VARCHAR(200), + "PLUGIN_NAME" VARCHAR(255) NOT NULL, + "SCOPE" VARCHAR(20) NOT NULL, + "DESCRIPTION" CLOB(2147483647), + "PRIORITY" INTEGER, + "STATUS" VARCHAR(40), + "LANGUAGE" VARCHAR(20), + "DEF_REMEDIATION_FUNCTION" VARCHAR(20), + "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), + "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), + "GAP_DESCRIPTION" VARCHAR(4000), + "SYSTEM_TAGS" VARCHAR(4000), + "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, + "DESCRIPTION_FORMAT" VARCHAR(20), + "RULE_TYPE" TINYINT, + "SECURITY_STANDARDS" VARCHAR(4000), + "IS_AD_HOC" BOOLEAN NOT NULL, + "IS_EXTERNAL" BOOLEAN NOT NULL, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_UUID" VARCHAR(40) +); +ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); + +CREATE TABLE "DEPRECATED_RULE_KEYS"( + "UUID" VARCHAR(40) NOT NULL, + "RULE_ID" INTEGER NOT NULL, + "OLD_REPOSITORY_KEY" VARCHAR(255) NOT NULL, + "OLD_RULE_KEY" VARCHAR(200) NOT NULL, + "CREATED_AT" BIGINT NOT NULL +); +ALTER TABLE "DEPRECATED_RULE_KEYS" ADD CONSTRAINT "PK_DEPRECATED_RULE_KEYS" PRIMARY KEY("UUID"); +CREATE UNIQUE INDEX "UNIQ_DEPRECATED_RULE_KEYS" ON "DEPRECATED_RULE_KEYS"("OLD_REPOSITORY_KEY", "OLD_RULE_KEY"); +CREATE INDEX "RULE_ID_DEPRECATED_RULE_KEYS" ON "DEPRECATED_RULE_KEYS"("RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTableTest/schema.sql new file mode 100644 index 00000000000..9f9a6ff004a --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/DropIndexOnRuleIdColumnOfDeprecatedRuleKeysTableTest/schema.sql @@ -0,0 +1,42 @@ +CREATE TABLE "RULES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "NAME" VARCHAR(200), + "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, + "PLUGIN_KEY" VARCHAR(200), + "PLUGIN_CONFIG_KEY" VARCHAR(200), + "PLUGIN_NAME" VARCHAR(255) NOT NULL, + "SCOPE" VARCHAR(20) NOT NULL, + "DESCRIPTION" CLOB(2147483647), + "PRIORITY" INTEGER, + "STATUS" VARCHAR(40), + "LANGUAGE" VARCHAR(20), + "DEF_REMEDIATION_FUNCTION" VARCHAR(20), + "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), + "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), + "GAP_DESCRIPTION" VARCHAR(4000), + "SYSTEM_TAGS" VARCHAR(4000), + "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, + "DESCRIPTION_FORMAT" VARCHAR(20), + "RULE_TYPE" TINYINT, + "SECURITY_STANDARDS" VARCHAR(4000), + "IS_AD_HOC" BOOLEAN NOT NULL, + "IS_EXTERNAL" BOOLEAN NOT NULL, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_UUID" VARCHAR(40) +); +ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); + +CREATE TABLE "DEPRECATED_RULE_KEYS"( + "UUID" VARCHAR(40) NOT NULL, + "RULE_ID" INTEGER NOT NULL, + "OLD_REPOSITORY_KEY" VARCHAR(255) NOT NULL, + "OLD_RULE_KEY" VARCHAR(200) NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "RULE_UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "DEPRECATED_RULE_KEYS" ADD CONSTRAINT "PK_DEPRECATED_RULE_KEYS" PRIMARY KEY("UUID"); +CREATE UNIQUE INDEX "UNIQ_DEPRECATED_RULE_KEYS" ON "DEPRECATED_RULE_KEYS"("OLD_REPOSITORY_KEY", "OLD_RULE_KEY"); +CREATE INDEX "RULE_ID_DEPRECATED_RULE_KEYS" ON "DEPRECATED_RULE_KEYS"("RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/DropRuleIdColumnOfDeprecatedRuleKeysTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/DropRuleIdColumnOfDeprecatedRuleKeysTableTest/schema.sql new file mode 100644 index 00000000000..557f113a0c2 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/DropRuleIdColumnOfDeprecatedRuleKeysTableTest/schema.sql @@ -0,0 +1,42 @@ +CREATE TABLE "RULES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "NAME" VARCHAR(200), + "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, + "PLUGIN_KEY" VARCHAR(200), + "PLUGIN_CONFIG_KEY" VARCHAR(200), + "PLUGIN_NAME" VARCHAR(255) NOT NULL, + "SCOPE" VARCHAR(20) NOT NULL, + "DESCRIPTION" CLOB(2147483647), + "PRIORITY" INTEGER, + "STATUS" VARCHAR(40), + "LANGUAGE" VARCHAR(20), + "DEF_REMEDIATION_FUNCTION" VARCHAR(20), + "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), + "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), + "GAP_DESCRIPTION" VARCHAR(4000), + "SYSTEM_TAGS" VARCHAR(4000), + "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, + "DESCRIPTION_FORMAT" VARCHAR(20), + "RULE_TYPE" TINYINT, + "SECURITY_STANDARDS" VARCHAR(4000), + "IS_AD_HOC" BOOLEAN NOT NULL, + "IS_EXTERNAL" BOOLEAN NOT NULL, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_UUID" VARCHAR(40) +); +ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); + +CREATE TABLE "DEPRECATED_RULE_KEYS"( + "UUID" VARCHAR(40) NOT NULL, + "RULE_ID" INTEGER NOT NULL, + "OLD_REPOSITORY_KEY" VARCHAR(255) NOT NULL, + "OLD_RULE_KEY" VARCHAR(200) NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "RULE_UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "DEPRECATED_RULE_KEYS" ADD CONSTRAINT "PK_DEPRECATED_RULE_KEYS" PRIMARY KEY("UUID"); +CREATE UNIQUE INDEX "UNIQ_DEPRECATED_RULE_KEYS" ON "DEPRECATED_RULE_KEYS"("OLD_REPOSITORY_KEY", "OLD_RULE_KEY"); +CREATE INDEX "RULE_UUID_DEPRECATED_RULE_KEYS" ON "DEPRECATED_RULE_KEYS"("RULE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/MakeDeprecatedRuleKeysRuleUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/MakeDeprecatedRuleKeysRuleUuidColumnNotNullableTest/schema.sql new file mode 100644 index 00000000000..a33abf46805 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/MakeDeprecatedRuleKeysRuleUuidColumnNotNullableTest/schema.sql @@ -0,0 +1,42 @@ +CREATE TABLE "RULES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "NAME" VARCHAR(200), + "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, + "PLUGIN_KEY" VARCHAR(200), + "PLUGIN_CONFIG_KEY" VARCHAR(200), + "PLUGIN_NAME" VARCHAR(255) NOT NULL, + "SCOPE" VARCHAR(20) NOT NULL, + "DESCRIPTION" CLOB(2147483647), + "PRIORITY" INTEGER, + "STATUS" VARCHAR(40), + "LANGUAGE" VARCHAR(20), + "DEF_REMEDIATION_FUNCTION" VARCHAR(20), + "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), + "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), + "GAP_DESCRIPTION" VARCHAR(4000), + "SYSTEM_TAGS" VARCHAR(4000), + "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, + "DESCRIPTION_FORMAT" VARCHAR(20), + "RULE_TYPE" TINYINT, + "SECURITY_STANDARDS" VARCHAR(4000), + "IS_AD_HOC" BOOLEAN NOT NULL, + "IS_EXTERNAL" BOOLEAN NOT NULL, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_UUID" VARCHAR(40) +); +ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); + +CREATE TABLE "DEPRECATED_RULE_KEYS"( + "UUID" VARCHAR(40) NOT NULL, + "RULE_ID" INTEGER NOT NULL, + "OLD_REPOSITORY_KEY" VARCHAR(255) NOT NULL, + "OLD_RULE_KEY" VARCHAR(200) NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "RULE_UUID" VARCHAR(40) +); +ALTER TABLE "DEPRECATED_RULE_KEYS" ADD CONSTRAINT "PK_DEPRECATED_RULE_KEYS" PRIMARY KEY("UUID"); +CREATE UNIQUE INDEX "UNIQ_DEPRECATED_RULE_KEYS" ON "DEPRECATED_RULE_KEYS"("OLD_REPOSITORY_KEY", "OLD_RULE_KEY"); +CREATE INDEX "RULE_ID_DEPRECATED_RULE_KEYS" ON "DEPRECATED_RULE_KEYS"("RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/PopulateDeprecatedRuleKeysRuleUuidColumnTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/PopulateDeprecatedRuleKeysRuleUuidColumnTest/schema.sql new file mode 100644 index 00000000000..a33abf46805 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/deprecatedrulekeys/PopulateDeprecatedRuleKeysRuleUuidColumnTest/schema.sql @@ -0,0 +1,42 @@ +CREATE TABLE "RULES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "NAME" VARCHAR(200), + "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, + "PLUGIN_KEY" VARCHAR(200), + "PLUGIN_CONFIG_KEY" VARCHAR(200), + "PLUGIN_NAME" VARCHAR(255) NOT NULL, + "SCOPE" VARCHAR(20) NOT NULL, + "DESCRIPTION" CLOB(2147483647), + "PRIORITY" INTEGER, + "STATUS" VARCHAR(40), + "LANGUAGE" VARCHAR(20), + "DEF_REMEDIATION_FUNCTION" VARCHAR(20), + "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), + "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), + "GAP_DESCRIPTION" VARCHAR(4000), + "SYSTEM_TAGS" VARCHAR(4000), + "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, + "DESCRIPTION_FORMAT" VARCHAR(20), + "RULE_TYPE" TINYINT, + "SECURITY_STANDARDS" VARCHAR(4000), + "IS_AD_HOC" BOOLEAN NOT NULL, + "IS_EXTERNAL" BOOLEAN NOT NULL, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_UUID" VARCHAR(40) +); +ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); + +CREATE TABLE "DEPRECATED_RULE_KEYS"( + "UUID" VARCHAR(40) NOT NULL, + "RULE_ID" INTEGER NOT NULL, + "OLD_REPOSITORY_KEY" VARCHAR(255) NOT NULL, + "OLD_RULE_KEY" VARCHAR(200) NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "RULE_UUID" VARCHAR(40) +); +ALTER TABLE "DEPRECATED_RULE_KEYS" ADD CONSTRAINT "PK_DEPRECATED_RULE_KEYS" PRIMARY KEY("UUID"); +CREATE UNIQUE INDEX "UNIQ_DEPRECATED_RULE_KEYS" ON "DEPRECATED_RULE_KEYS"("OLD_REPOSITORY_KEY", "OLD_RULE_KEY"); +CREATE INDEX "RULE_ID_DEPRECATED_RULE_KEYS" ON "DEPRECATED_RULE_KEYS"("RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/issues/AddIndexToIssuesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/issues/AddIndexToIssuesTableTest/schema.sql new file mode 100644 index 00000000000..d02b9c74ec2 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/issues/AddIndexToIssuesTableTest/schema.sql @@ -0,0 +1,69 @@ +CREATE TABLE "RULES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "NAME" VARCHAR(200), + "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, + "PLUGIN_KEY" VARCHAR(200), + "PLUGIN_CONFIG_KEY" VARCHAR(200), + "PLUGIN_NAME" VARCHAR(255) NOT NULL, + "SCOPE" VARCHAR(20) NOT NULL, + "DESCRIPTION" CLOB(2147483647), + "PRIORITY" INTEGER, + "STATUS" VARCHAR(40), + "LANGUAGE" VARCHAR(20), + "DEF_REMEDIATION_FUNCTION" VARCHAR(20), + "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), + "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), + "GAP_DESCRIPTION" VARCHAR(4000), + "SYSTEM_TAGS" VARCHAR(4000), + "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, + "DESCRIPTION_FORMAT" VARCHAR(20), + "RULE_TYPE" TINYINT, + "SECURITY_STANDARDS" VARCHAR(4000), + "IS_AD_HOC" BOOLEAN NOT NULL, + "IS_EXTERNAL" BOOLEAN NOT NULL, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_UUID" VARCHAR(40) +); +ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); + +CREATE TABLE "ISSUES"( + "KEE" VARCHAR(50) NOT NULL, + "RULE_ID" INTEGER, + "SEVERITY" VARCHAR(10), + "MANUAL_SEVERITY" BOOLEAN NOT NULL, + "MESSAGE" VARCHAR(4000), + "LINE" INTEGER, + "GAP" DOUBLE, + "STATUS" VARCHAR(20), + "RESOLUTION" VARCHAR(20), + "CHECKSUM" VARCHAR(1000), + "REPORTER" VARCHAR(255), + "ASSIGNEE" VARCHAR(255), + "AUTHOR_LOGIN" VARCHAR(255), + "ACTION_PLAN_KEY" VARCHAR(50), + "ISSUE_ATTRIBUTES" VARCHAR(4000), + "EFFORT" INTEGER, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "ISSUE_CREATION_DATE" BIGINT, + "ISSUE_UPDATE_DATE" BIGINT, + "ISSUE_CLOSE_DATE" BIGINT, + "TAGS" VARCHAR(4000), + "COMPONENT_UUID" VARCHAR(50), + "PROJECT_UUID" VARCHAR(50), + "LOCATIONS" BLOB, + "ISSUE_TYPE" TINYINT, + "FROM_HOTSPOT" BOOLEAN, + "RULE_UUID" VARCHAR(40) +); +ALTER TABLE "ISSUES" ADD CONSTRAINT "PK_ISSUES" PRIMARY KEY("KEE"); +CREATE INDEX "ISSUES_ASSIGNEE" ON "ISSUES"("ASSIGNEE"); +CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES"("COMPONENT_UUID"); +CREATE INDEX "ISSUES_CREATION_DATE" ON "ISSUES"("ISSUE_CREATION_DATE"); +CREATE UNIQUE INDEX "ISSUES_KEE" ON "ISSUES"("KEE"); +CREATE INDEX "ISSUES_PROJECT_UUID" ON "ISSUES"("PROJECT_UUID"); +CREATE INDEX "ISSUES_RESOLUTION" ON "ISSUES"("RESOLUTION"); +CREATE INDEX "ISSUES_UPDATED_AT" ON "ISSUES"("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/issues/AddRuleUuidColumnToIssuesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/issues/AddRuleUuidColumnToIssuesTableTest/schema.sql new file mode 100644 index 00000000000..89488e5506f --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/issues/AddRuleUuidColumnToIssuesTableTest/schema.sql @@ -0,0 +1,69 @@ +CREATE TABLE "RULES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "NAME" VARCHAR(200), + "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, + "PLUGIN_KEY" VARCHAR(200), + "PLUGIN_CONFIG_KEY" VARCHAR(200), + "PLUGIN_NAME" VARCHAR(255) NOT NULL, + "SCOPE" VARCHAR(20) NOT NULL, + "DESCRIPTION" CLOB(2147483647), + "PRIORITY" INTEGER, + "STATUS" VARCHAR(40), + "LANGUAGE" VARCHAR(20), + "DEF_REMEDIATION_FUNCTION" VARCHAR(20), + "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), + "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), + "GAP_DESCRIPTION" VARCHAR(4000), + "SYSTEM_TAGS" VARCHAR(4000), + "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, + "DESCRIPTION_FORMAT" VARCHAR(20), + "RULE_TYPE" TINYINT, + "SECURITY_STANDARDS" VARCHAR(4000), + "IS_AD_HOC" BOOLEAN NOT NULL, + "IS_EXTERNAL" BOOLEAN NOT NULL, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_UUID" VARCHAR(40) +); +ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); + +CREATE TABLE "ISSUES"( + "KEE" VARCHAR(50) NOT NULL, + "RULE_ID" INTEGER, + "SEVERITY" VARCHAR(10), + "MANUAL_SEVERITY" BOOLEAN NOT NULL, + "MESSAGE" VARCHAR(4000), + "LINE" INTEGER, + "GAP" DOUBLE, + "STATUS" VARCHAR(20), + "RESOLUTION" VARCHAR(20), + "CHECKSUM" VARCHAR(1000), + "REPORTER" VARCHAR(255), + "ASSIGNEE" VARCHAR(255), + "AUTHOR_LOGIN" VARCHAR(255), + "ACTION_PLAN_KEY" VARCHAR(50), + "ISSUE_ATTRIBUTES" VARCHAR(4000), + "EFFORT" INTEGER, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "ISSUE_CREATION_DATE" BIGINT, + "ISSUE_UPDATE_DATE" BIGINT, + "ISSUE_CLOSE_DATE" BIGINT, + "TAGS" VARCHAR(4000), + "COMPONENT_UUID" VARCHAR(50), + "PROJECT_UUID" VARCHAR(50), + "LOCATIONS" BLOB, + "ISSUE_TYPE" TINYINT, + "FROM_HOTSPOT" BOOLEAN +); +ALTER TABLE "ISSUES" ADD CONSTRAINT "PK_ISSUES" PRIMARY KEY("KEE"); +CREATE INDEX "ISSUES_ASSIGNEE" ON "ISSUES"("ASSIGNEE"); +CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES"("COMPONENT_UUID"); +CREATE INDEX "ISSUES_CREATION_DATE" ON "ISSUES"("ISSUE_CREATION_DATE"); +CREATE UNIQUE INDEX "ISSUES_KEE" ON "ISSUES"("KEE"); +CREATE INDEX "ISSUES_PROJECT_UUID" ON "ISSUES"("PROJECT_UUID"); +CREATE INDEX "ISSUES_RESOLUTION" ON "ISSUES"("RESOLUTION"); +CREATE INDEX "ISSUES_RULE_ID" ON "ISSUES"("RULE_ID"); +CREATE INDEX "ISSUES_UPDATED_AT" ON "ISSUES"("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/issues/DropIndexOnRuleIdColumnOfIssuesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/issues/DropIndexOnRuleIdColumnOfIssuesTableTest/schema.sql new file mode 100644 index 00000000000..d6c8f6b855e --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/issues/DropIndexOnRuleIdColumnOfIssuesTableTest/schema.sql @@ -0,0 +1,70 @@ +CREATE TABLE "RULES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "NAME" VARCHAR(200), + "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, + "PLUGIN_KEY" VARCHAR(200), + "PLUGIN_CONFIG_KEY" VARCHAR(200), + "PLUGIN_NAME" VARCHAR(255) NOT NULL, + "SCOPE" VARCHAR(20) NOT NULL, + "DESCRIPTION" CLOB(2147483647), + "PRIORITY" INTEGER, + "STATUS" VARCHAR(40), + "LANGUAGE" VARCHAR(20), + "DEF_REMEDIATION_FUNCTION" VARCHAR(20), + "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), + "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), + "GAP_DESCRIPTION" VARCHAR(4000), + "SYSTEM_TAGS" VARCHAR(4000), + "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, + "DESCRIPTION_FORMAT" VARCHAR(20), + "RULE_TYPE" TINYINT, + "SECURITY_STANDARDS" VARCHAR(4000), + "IS_AD_HOC" BOOLEAN NOT NULL, + "IS_EXTERNAL" BOOLEAN NOT NULL, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_UUID" VARCHAR(40) +); +ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); + +CREATE TABLE "ISSUES"( + "KEE" VARCHAR(50) NOT NULL, + "RULE_ID" INTEGER, + "SEVERITY" VARCHAR(10), + "MANUAL_SEVERITY" BOOLEAN NOT NULL, + "MESSAGE" VARCHAR(4000), + "LINE" INTEGER, + "GAP" DOUBLE, + "STATUS" VARCHAR(20), + "RESOLUTION" VARCHAR(20), + "CHECKSUM" VARCHAR(1000), + "REPORTER" VARCHAR(255), + "ASSIGNEE" VARCHAR(255), + "AUTHOR_LOGIN" VARCHAR(255), + "ACTION_PLAN_KEY" VARCHAR(50), + "ISSUE_ATTRIBUTES" VARCHAR(4000), + "EFFORT" INTEGER, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "ISSUE_CREATION_DATE" BIGINT, + "ISSUE_UPDATE_DATE" BIGINT, + "ISSUE_CLOSE_DATE" BIGINT, + "TAGS" VARCHAR(4000), + "COMPONENT_UUID" VARCHAR(50), + "PROJECT_UUID" VARCHAR(50), + "LOCATIONS" BLOB, + "ISSUE_TYPE" TINYINT, + "FROM_HOTSPOT" BOOLEAN, + "RULE_UUID" VARCHAR(40) +); +ALTER TABLE "ISSUES" ADD CONSTRAINT "PK_ISSUES" PRIMARY KEY("KEE"); +CREATE INDEX "ISSUES_ASSIGNEE" ON "ISSUES"("ASSIGNEE"); +CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES"("COMPONENT_UUID"); +CREATE INDEX "ISSUES_CREATION_DATE" ON "ISSUES"("ISSUE_CREATION_DATE"); +CREATE UNIQUE INDEX "ISSUES_KEE" ON "ISSUES"("KEE"); +CREATE INDEX "ISSUES_PROJECT_UUID" ON "ISSUES"("PROJECT_UUID"); +CREATE INDEX "ISSUES_RESOLUTION" ON "ISSUES"("RESOLUTION"); +CREATE INDEX "ISSUES_RULE_ID" ON "ISSUES"("RULE_ID"); +CREATE INDEX "ISSUES_UPDATED_AT" ON "ISSUES"("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/issues/DropRuleIdColumnOfIssuesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/issues/DropRuleIdColumnOfIssuesTableTest/schema.sql new file mode 100644 index 00000000000..a2da6523742 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/issues/DropRuleIdColumnOfIssuesTableTest/schema.sql @@ -0,0 +1,70 @@ +CREATE TABLE "RULES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "NAME" VARCHAR(200), + "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, + "PLUGIN_KEY" VARCHAR(200), + "PLUGIN_CONFIG_KEY" VARCHAR(200), + "PLUGIN_NAME" VARCHAR(255) NOT NULL, + "SCOPE" VARCHAR(20) NOT NULL, + "DESCRIPTION" CLOB(2147483647), + "PRIORITY" INTEGER, + "STATUS" VARCHAR(40), + "LANGUAGE" VARCHAR(20), + "DEF_REMEDIATION_FUNCTION" VARCHAR(20), + "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), + "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), + "GAP_DESCRIPTION" VARCHAR(4000), + "SYSTEM_TAGS" VARCHAR(4000), + "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, + "DESCRIPTION_FORMAT" VARCHAR(20), + "RULE_TYPE" TINYINT, + "SECURITY_STANDARDS" VARCHAR(4000), + "IS_AD_HOC" BOOLEAN NOT NULL, + "IS_EXTERNAL" BOOLEAN NOT NULL, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_UUID" VARCHAR(40) +); +ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); + +CREATE TABLE "ISSUES"( + "KEE" VARCHAR(50) NOT NULL, + "RULE_ID" INTEGER, + "SEVERITY" VARCHAR(10), + "MANUAL_SEVERITY" BOOLEAN NOT NULL, + "MESSAGE" VARCHAR(4000), + "LINE" INTEGER, + "GAP" DOUBLE, + "STATUS" VARCHAR(20), + "RESOLUTION" VARCHAR(20), + "CHECKSUM" VARCHAR(1000), + "REPORTER" VARCHAR(255), + "ASSIGNEE" VARCHAR(255), + "AUTHOR_LOGIN" VARCHAR(255), + "ACTION_PLAN_KEY" VARCHAR(50), + "ISSUE_ATTRIBUTES" VARCHAR(4000), + "EFFORT" INTEGER, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "ISSUE_CREATION_DATE" BIGINT, + "ISSUE_UPDATE_DATE" BIGINT, + "ISSUE_CLOSE_DATE" BIGINT, + "TAGS" VARCHAR(4000), + "COMPONENT_UUID" VARCHAR(50), + "PROJECT_UUID" VARCHAR(50), + "LOCATIONS" BLOB, + "ISSUE_TYPE" TINYINT, + "FROM_HOTSPOT" BOOLEAN, + "RULE_UUID" VARCHAR(40) +); +ALTER TABLE "ISSUES" ADD CONSTRAINT "PK_ISSUES" PRIMARY KEY("KEE"); +CREATE INDEX "ISSUES_ASSIGNEE" ON "ISSUES"("ASSIGNEE"); +CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES"("COMPONENT_UUID"); +CREATE INDEX "ISSUES_CREATION_DATE" ON "ISSUES"("ISSUE_CREATION_DATE"); +CREATE UNIQUE INDEX "ISSUES_KEE" ON "ISSUES"("KEE"); +CREATE INDEX "ISSUES_PROJECT_UUID" ON "ISSUES"("PROJECT_UUID"); +CREATE INDEX "ISSUES_RESOLUTION" ON "ISSUES"("RESOLUTION"); +CREATE INDEX "ISSUES_RULE_UUID" ON "ISSUES"("RULE_UUID"); +CREATE INDEX "ISSUES_UPDATED_AT" ON "ISSUES"("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/issues/PopulateIssuesRuleUuidColumnTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/issues/PopulateIssuesRuleUuidColumnTest/schema.sql new file mode 100644 index 00000000000..d6c8f6b855e --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/issues/PopulateIssuesRuleUuidColumnTest/schema.sql @@ -0,0 +1,70 @@ +CREATE TABLE "RULES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "NAME" VARCHAR(200), + "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, + "PLUGIN_KEY" VARCHAR(200), + "PLUGIN_CONFIG_KEY" VARCHAR(200), + "PLUGIN_NAME" VARCHAR(255) NOT NULL, + "SCOPE" VARCHAR(20) NOT NULL, + "DESCRIPTION" CLOB(2147483647), + "PRIORITY" INTEGER, + "STATUS" VARCHAR(40), + "LANGUAGE" VARCHAR(20), + "DEF_REMEDIATION_FUNCTION" VARCHAR(20), + "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), + "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), + "GAP_DESCRIPTION" VARCHAR(4000), + "SYSTEM_TAGS" VARCHAR(4000), + "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, + "DESCRIPTION_FORMAT" VARCHAR(20), + "RULE_TYPE" TINYINT, + "SECURITY_STANDARDS" VARCHAR(4000), + "IS_AD_HOC" BOOLEAN NOT NULL, + "IS_EXTERNAL" BOOLEAN NOT NULL, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_UUID" VARCHAR(40) +); +ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); + +CREATE TABLE "ISSUES"( + "KEE" VARCHAR(50) NOT NULL, + "RULE_ID" INTEGER, + "SEVERITY" VARCHAR(10), + "MANUAL_SEVERITY" BOOLEAN NOT NULL, + "MESSAGE" VARCHAR(4000), + "LINE" INTEGER, + "GAP" DOUBLE, + "STATUS" VARCHAR(20), + "RESOLUTION" VARCHAR(20), + "CHECKSUM" VARCHAR(1000), + "REPORTER" VARCHAR(255), + "ASSIGNEE" VARCHAR(255), + "AUTHOR_LOGIN" VARCHAR(255), + "ACTION_PLAN_KEY" VARCHAR(50), + "ISSUE_ATTRIBUTES" VARCHAR(4000), + "EFFORT" INTEGER, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "ISSUE_CREATION_DATE" BIGINT, + "ISSUE_UPDATE_DATE" BIGINT, + "ISSUE_CLOSE_DATE" BIGINT, + "TAGS" VARCHAR(4000), + "COMPONENT_UUID" VARCHAR(50), + "PROJECT_UUID" VARCHAR(50), + "LOCATIONS" BLOB, + "ISSUE_TYPE" TINYINT, + "FROM_HOTSPOT" BOOLEAN, + "RULE_UUID" VARCHAR(40) +); +ALTER TABLE "ISSUES" ADD CONSTRAINT "PK_ISSUES" PRIMARY KEY("KEE"); +CREATE INDEX "ISSUES_ASSIGNEE" ON "ISSUES"("ASSIGNEE"); +CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES"("COMPONENT_UUID"); +CREATE INDEX "ISSUES_CREATION_DATE" ON "ISSUES"("ISSUE_CREATION_DATE"); +CREATE UNIQUE INDEX "ISSUES_KEE" ON "ISSUES"("KEE"); +CREATE INDEX "ISSUES_PROJECT_UUID" ON "ISSUES"("PROJECT_UUID"); +CREATE INDEX "ISSUES_RESOLUTION" ON "ISSUES"("RESOLUTION"); +CREATE INDEX "ISSUES_RULE_ID" ON "ISSUES"("RULE_ID"); +CREATE INDEX "ISSUES_UPDATED_AT" ON "ISSUES"("UPDATED_AT"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTableTest/schema.sql new file mode 100644 index 00000000000..7e46834a915 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTableTest/schema.sql @@ -0,0 +1,50 @@ +CREATE TABLE "RULES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "NAME" VARCHAR(200), + "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, + "PLUGIN_KEY" VARCHAR(200), + "PLUGIN_CONFIG_KEY" VARCHAR(200), + "PLUGIN_NAME" VARCHAR(255) NOT NULL, + "SCOPE" VARCHAR(20) NOT NULL, + "DESCRIPTION" CLOB(2147483647), + "PRIORITY" INTEGER, + "STATUS" VARCHAR(40), + "LANGUAGE" VARCHAR(20), + "DEF_REMEDIATION_FUNCTION" VARCHAR(20), + "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), + "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), + "GAP_DESCRIPTION" VARCHAR(4000), + "SYSTEM_TAGS" VARCHAR(4000), + "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, + "DESCRIPTION_FORMAT" VARCHAR(20), + "RULE_TYPE" TINYINT, + "SECURITY_STANDARDS" VARCHAR(4000), + "IS_AD_HOC" BOOLEAN NOT NULL, + "IS_EXTERNAL" BOOLEAN NOT NULL, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_UUID" VARCHAR(40) +); +ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); + +CREATE TABLE "RULES_METADATA"( + "RULE_ID" INTEGER NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "NOTE_DATA" CLOB(2147483647), + "NOTE_USER_UUID" VARCHAR(255), + "NOTE_CREATED_AT" BIGINT, + "NOTE_UPDATED_AT" BIGINT, + "REMEDIATION_FUNCTION" VARCHAR(20), + "REMEDIATION_GAP_MULT" VARCHAR(20), + "REMEDIATION_BASE_EFFORT" VARCHAR(20), + "TAGS" VARCHAR(4000), + "AD_HOC_NAME" VARCHAR(200), + "AD_HOC_DESCRIPTION" CLOB(2147483647), + "AD_HOC_SEVERITY" VARCHAR(10), + "AD_HOC_TYPE" TINYINT, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL, + "RULE_UUID" VARCHAR(40) NOT NULL +); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddRuleUuidColumnToRulesMetadataTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddRuleUuidColumnToRulesMetadataTableTest/schema.sql new file mode 100644 index 00000000000..6dd1263edd1 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddRuleUuidColumnToRulesMetadataTableTest/schema.sql @@ -0,0 +1,50 @@ +CREATE TABLE "RULES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "NAME" VARCHAR(200), + "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, + "PLUGIN_KEY" VARCHAR(200), + "PLUGIN_CONFIG_KEY" VARCHAR(200), + "PLUGIN_NAME" VARCHAR(255) NOT NULL, + "SCOPE" VARCHAR(20) NOT NULL, + "DESCRIPTION" CLOB(2147483647), + "PRIORITY" INTEGER, + "STATUS" VARCHAR(40), + "LANGUAGE" VARCHAR(20), + "DEF_REMEDIATION_FUNCTION" VARCHAR(20), + "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), + "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), + "GAP_DESCRIPTION" VARCHAR(4000), + "SYSTEM_TAGS" VARCHAR(4000), + "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, + "DESCRIPTION_FORMAT" VARCHAR(20), + "RULE_TYPE" TINYINT, + "SECURITY_STANDARDS" VARCHAR(4000), + "IS_AD_HOC" BOOLEAN NOT NULL, + "IS_EXTERNAL" BOOLEAN NOT NULL, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_UUID" VARCHAR(40) +); +ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); + +CREATE TABLE "RULES_METADATA"( + "RULE_ID" INTEGER NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "NOTE_DATA" CLOB(2147483647), + "NOTE_USER_UUID" VARCHAR(255), + "NOTE_CREATED_AT" BIGINT, + "NOTE_UPDATED_AT" BIGINT, + "REMEDIATION_FUNCTION" VARCHAR(20), + "REMEDIATION_GAP_MULT" VARCHAR(20), + "REMEDIATION_BASE_EFFORT" VARCHAR(20), + "TAGS" VARCHAR(4000), + "AD_HOC_NAME" VARCHAR(200), + "AD_HOC_DESCRIPTION" CLOB(2147483647), + "AD_HOC_SEVERITY" VARCHAR(10), + "AD_HOC_TYPE" TINYINT, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL +); +ALTER TABLE "RULES_METADATA" ADD CONSTRAINT "PK_RULES_METADATA" PRIMARY KEY("RULE_ID", "ORGANIZATION_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropPrimaryKeyOnIdColumnOfRulesMetadataTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropPrimaryKeyOnIdColumnOfRulesMetadataTableTest/schema.sql new file mode 100644 index 00000000000..9f014613799 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropPrimaryKeyOnIdColumnOfRulesMetadataTableTest/schema.sql @@ -0,0 +1,51 @@ +CREATE TABLE "RULES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "NAME" VARCHAR(200), + "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, + "PLUGIN_KEY" VARCHAR(200), + "PLUGIN_CONFIG_KEY" VARCHAR(200), + "PLUGIN_NAME" VARCHAR(255) NOT NULL, + "SCOPE" VARCHAR(20) NOT NULL, + "DESCRIPTION" CLOB(2147483647), + "PRIORITY" INTEGER, + "STATUS" VARCHAR(40), + "LANGUAGE" VARCHAR(20), + "DEF_REMEDIATION_FUNCTION" VARCHAR(20), + "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), + "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), + "GAP_DESCRIPTION" VARCHAR(4000), + "SYSTEM_TAGS" VARCHAR(4000), + "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, + "DESCRIPTION_FORMAT" VARCHAR(20), + "RULE_TYPE" TINYINT, + "SECURITY_STANDARDS" VARCHAR(4000), + "IS_AD_HOC" BOOLEAN NOT NULL, + "IS_EXTERNAL" BOOLEAN NOT NULL, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_UUID" VARCHAR(40) +); +ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); + +CREATE TABLE "RULES_METADATA"( + "RULE_ID" INTEGER NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "NOTE_DATA" CLOB(2147483647), + "NOTE_USER_UUID" VARCHAR(255), + "NOTE_CREATED_AT" BIGINT, + "NOTE_UPDATED_AT" BIGINT, + "REMEDIATION_FUNCTION" VARCHAR(20), + "REMEDIATION_GAP_MULT" VARCHAR(20), + "REMEDIATION_BASE_EFFORT" VARCHAR(20), + "TAGS" VARCHAR(4000), + "AD_HOC_NAME" VARCHAR(200), + "AD_HOC_DESCRIPTION" CLOB(2147483647), + "AD_HOC_SEVERITY" VARCHAR(10), + "AD_HOC_TYPE" TINYINT, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL, + "RULE_UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "RULES_METADATA" ADD CONSTRAINT "PK_RULES_METADATA" PRIMARY KEY("RULE_ID", "ORGANIZATION_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropRuleIdColumnOfRulesMetadataTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropRuleIdColumnOfRulesMetadataTableTest/schema.sql new file mode 100644 index 00000000000..d7862acb77c --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropRuleIdColumnOfRulesMetadataTableTest/schema.sql @@ -0,0 +1,51 @@ +create TABLE "RULES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "NAME" VARCHAR(200), + "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, + "PLUGIN_KEY" VARCHAR(200), + "PLUGIN_CONFIG_KEY" VARCHAR(200), + "PLUGIN_NAME" VARCHAR(255) NOT NULL, + "SCOPE" VARCHAR(20) NOT NULL, + "DESCRIPTION" CLOB(2147483647), + "PRIORITY" INTEGER, + "STATUS" VARCHAR(40), + "LANGUAGE" VARCHAR(20), + "DEF_REMEDIATION_FUNCTION" VARCHAR(20), + "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), + "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), + "GAP_DESCRIPTION" VARCHAR(4000), + "SYSTEM_TAGS" VARCHAR(4000), + "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, + "DESCRIPTION_FORMAT" VARCHAR(20), + "RULE_TYPE" TINYINT, + "SECURITY_STANDARDS" VARCHAR(4000), + "IS_AD_HOC" BOOLEAN NOT NULL, + "IS_EXTERNAL" BOOLEAN NOT NULL, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_UUID" VARCHAR(40) +); +alter table "RULES" add CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); +create UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); + +CREATE TABLE "RULES_METADATA"( + "RULE_ID" INTEGER NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "NOTE_DATA" CLOB(2147483647), + "NOTE_USER_UUID" VARCHAR(255), + "NOTE_CREATED_AT" BIGINT, + "NOTE_UPDATED_AT" BIGINT, + "REMEDIATION_FUNCTION" VARCHAR(20), + "REMEDIATION_GAP_MULT" VARCHAR(20), + "REMEDIATION_BASE_EFFORT" VARCHAR(20), + "TAGS" VARCHAR(4000), + "AD_HOC_NAME" VARCHAR(200), + "AD_HOC_DESCRIPTION" CLOB(2147483647), + "AD_HOC_SEVERITY" VARCHAR(10), + "AD_HOC_TYPE" TINYINT, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL, + "RULE_UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "RULES_METADATA" ADD CONSTRAINT "PK_RULES_METADATA" PRIMARY KEY("RULE_UUID", "ORGANIZATION_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/MakeRulesMetadataRuleUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/MakeRulesMetadataRuleUuidColumnNotNullableTest/schema.sql new file mode 100644 index 00000000000..9e725d8243b --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/MakeRulesMetadataRuleUuidColumnNotNullableTest/schema.sql @@ -0,0 +1,51 @@ +CREATE TABLE "RULES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "NAME" VARCHAR(200), + "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, + "PLUGIN_KEY" VARCHAR(200), + "PLUGIN_CONFIG_KEY" VARCHAR(200), + "PLUGIN_NAME" VARCHAR(255) NOT NULL, + "SCOPE" VARCHAR(20) NOT NULL, + "DESCRIPTION" CLOB(2147483647), + "PRIORITY" INTEGER, + "STATUS" VARCHAR(40), + "LANGUAGE" VARCHAR(20), + "DEF_REMEDIATION_FUNCTION" VARCHAR(20), + "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), + "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), + "GAP_DESCRIPTION" VARCHAR(4000), + "SYSTEM_TAGS" VARCHAR(4000), + "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, + "DESCRIPTION_FORMAT" VARCHAR(20), + "RULE_TYPE" TINYINT, + "SECURITY_STANDARDS" VARCHAR(4000), + "IS_AD_HOC" BOOLEAN NOT NULL, + "IS_EXTERNAL" BOOLEAN NOT NULL, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_UUID" VARCHAR(40) +); +ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); + +CREATE TABLE "RULES_METADATA"( + "RULE_ID" INTEGER NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "NOTE_DATA" CLOB(2147483647), + "NOTE_USER_UUID" VARCHAR(255), + "NOTE_CREATED_AT" BIGINT, + "NOTE_UPDATED_AT" BIGINT, + "REMEDIATION_FUNCTION" VARCHAR(20), + "REMEDIATION_GAP_MULT" VARCHAR(20), + "REMEDIATION_BASE_EFFORT" VARCHAR(20), + "TAGS" VARCHAR(4000), + "AD_HOC_NAME" VARCHAR(200), + "AD_HOC_DESCRIPTION" CLOB(2147483647), + "AD_HOC_SEVERITY" VARCHAR(10), + "AD_HOC_TYPE" TINYINT, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL, + "RULE_UUID" VARCHAR(40) +); +ALTER TABLE "RULES_METADATA" ADD CONSTRAINT "PK_RULES_METADATA" PRIMARY KEY("RULE_ID", "ORGANIZATION_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/PopulateRulesMetadataRuleUuidColumnTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/PopulateRulesMetadataRuleUuidColumnTest/schema.sql new file mode 100644 index 00000000000..9e725d8243b --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/PopulateRulesMetadataRuleUuidColumnTest/schema.sql @@ -0,0 +1,51 @@ +CREATE TABLE "RULES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "NAME" VARCHAR(200), + "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, + "PLUGIN_KEY" VARCHAR(200), + "PLUGIN_CONFIG_KEY" VARCHAR(200), + "PLUGIN_NAME" VARCHAR(255) NOT NULL, + "SCOPE" VARCHAR(20) NOT NULL, + "DESCRIPTION" CLOB(2147483647), + "PRIORITY" INTEGER, + "STATUS" VARCHAR(40), + "LANGUAGE" VARCHAR(20), + "DEF_REMEDIATION_FUNCTION" VARCHAR(20), + "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), + "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), + "GAP_DESCRIPTION" VARCHAR(4000), + "SYSTEM_TAGS" VARCHAR(4000), + "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, + "DESCRIPTION_FORMAT" VARCHAR(20), + "RULE_TYPE" TINYINT, + "SECURITY_STANDARDS" VARCHAR(4000), + "IS_AD_HOC" BOOLEAN NOT NULL, + "IS_EXTERNAL" BOOLEAN NOT NULL, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_UUID" VARCHAR(40) +); +ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); + +CREATE TABLE "RULES_METADATA"( + "RULE_ID" INTEGER NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "NOTE_DATA" CLOB(2147483647), + "NOTE_USER_UUID" VARCHAR(255), + "NOTE_CREATED_AT" BIGINT, + "NOTE_UPDATED_AT" BIGINT, + "REMEDIATION_FUNCTION" VARCHAR(20), + "REMEDIATION_GAP_MULT" VARCHAR(20), + "REMEDIATION_BASE_EFFORT" VARCHAR(20), + "TAGS" VARCHAR(4000), + "AD_HOC_NAME" VARCHAR(200), + "AD_HOC_DESCRIPTION" CLOB(2147483647), + "AD_HOC_SEVERITY" VARCHAR(10), + "AD_HOC_TYPE" TINYINT, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL, + "RULE_UUID" VARCHAR(40) +); +ALTER TABLE "RULES_METADATA" ADD CONSTRAINT "PK_RULES_METADATA" PRIMARY KEY("RULE_ID", "ORGANIZATION_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/AddIndexesToRulesParametersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/AddIndexesToRulesParametersTableTest/schema.sql new file mode 100644 index 00000000000..13198189e57 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/AddIndexesToRulesParametersTableTest/schema.sql @@ -0,0 +1,41 @@ +CREATE TABLE "RULES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "NAME" VARCHAR(200), + "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, + "PLUGIN_KEY" VARCHAR(200), + "PLUGIN_CONFIG_KEY" VARCHAR(200), + "PLUGIN_NAME" VARCHAR(255) NOT NULL, + "SCOPE" VARCHAR(20) NOT NULL, + "DESCRIPTION" CLOB(2147483647), + "PRIORITY" INTEGER, + "STATUS" VARCHAR(40), + "LANGUAGE" VARCHAR(20), + "DEF_REMEDIATION_FUNCTION" VARCHAR(20), + "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), + "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), + "GAP_DESCRIPTION" VARCHAR(4000), + "SYSTEM_TAGS" VARCHAR(4000), + "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, + "DESCRIPTION_FORMAT" VARCHAR(20), + "RULE_TYPE" TINYINT, + "SECURITY_STANDARDS" VARCHAR(4000), + "IS_AD_HOC" BOOLEAN NOT NULL, + "IS_EXTERNAL" BOOLEAN NOT NULL, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_UUID" VARCHAR(40) +); +ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); + +CREATE TABLE "RULES_PARAMETERS"( + "UUID" VARCHAR(40) NOT NULL, + "RULE_ID" INTEGER NOT NULL, + "NAME" VARCHAR(128) NOT NULL, + "DESCRIPTION" VARCHAR(4000), + "PARAM_TYPE" VARCHAR(512) NOT NULL, + "DEFAULT_VALUE" VARCHAR(4000), + "RULE_UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "RULES_PARAMETERS" ADD CONSTRAINT "PK_RULES_PARAMETERS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/AddRuleUuidColumnToRulesParametersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/AddRuleUuidColumnToRulesParametersTableTest/schema.sql new file mode 100644 index 00000000000..88e9e77a4e3 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/AddRuleUuidColumnToRulesParametersTableTest/schema.sql @@ -0,0 +1,42 @@ +CREATE TABLE "RULES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "NAME" VARCHAR(200), + "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, + "PLUGIN_KEY" VARCHAR(200), + "PLUGIN_CONFIG_KEY" VARCHAR(200), + "PLUGIN_NAME" VARCHAR(255) NOT NULL, + "SCOPE" VARCHAR(20) NOT NULL, + "DESCRIPTION" CLOB(2147483647), + "PRIORITY" INTEGER, + "STATUS" VARCHAR(40), + "LANGUAGE" VARCHAR(20), + "DEF_REMEDIATION_FUNCTION" VARCHAR(20), + "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), + "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), + "GAP_DESCRIPTION" VARCHAR(4000), + "SYSTEM_TAGS" VARCHAR(4000), + "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, + "DESCRIPTION_FORMAT" VARCHAR(20), + "RULE_TYPE" TINYINT, + "SECURITY_STANDARDS" VARCHAR(4000), + "IS_AD_HOC" BOOLEAN NOT NULL, + "IS_EXTERNAL" BOOLEAN NOT NULL, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_UUID" VARCHAR(40) +); +ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); + +CREATE TABLE "RULES_PARAMETERS"( + "UUID" VARCHAR(40) NOT NULL, + "RULE_ID" INTEGER NOT NULL, + "NAME" VARCHAR(128) NOT NULL, + "DESCRIPTION" VARCHAR(4000), + "PARAM_TYPE" VARCHAR(512) NOT NULL, + "DEFAULT_VALUE" VARCHAR(4000) +); +ALTER TABLE "RULES_PARAMETERS" ADD CONSTRAINT "PK_RULES_PARAMETERS" PRIMARY KEY("UUID"); +CREATE INDEX "RULES_PARAMETERS_RULE_ID" ON "RULES_PARAMETERS"("RULE_ID"); +CREATE UNIQUE INDEX "RULES_PARAMETERS_UNIQUE" ON "RULES_PARAMETERS"("RULE_ID", "NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/DropIndexesOnRuleIdColumnOfRulesParametersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/DropIndexesOnRuleIdColumnOfRulesParametersTableTest/schema.sql new file mode 100644 index 00000000000..81bbe5119c2 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/DropIndexesOnRuleIdColumnOfRulesParametersTableTest/schema.sql @@ -0,0 +1,43 @@ +CREATE TABLE "RULES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "NAME" VARCHAR(200), + "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, + "PLUGIN_KEY" VARCHAR(200), + "PLUGIN_CONFIG_KEY" VARCHAR(200), + "PLUGIN_NAME" VARCHAR(255) NOT NULL, + "SCOPE" VARCHAR(20) NOT NULL, + "DESCRIPTION" CLOB(2147483647), + "PRIORITY" INTEGER, + "STATUS" VARCHAR(40), + "LANGUAGE" VARCHAR(20), + "DEF_REMEDIATION_FUNCTION" VARCHAR(20), + "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), + "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), + "GAP_DESCRIPTION" VARCHAR(4000), + "SYSTEM_TAGS" VARCHAR(4000), + "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, + "DESCRIPTION_FORMAT" VARCHAR(20), + "RULE_TYPE" TINYINT, + "SECURITY_STANDARDS" VARCHAR(4000), + "IS_AD_HOC" BOOLEAN NOT NULL, + "IS_EXTERNAL" BOOLEAN NOT NULL, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_UUID" VARCHAR(40) +); +ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); + +CREATE TABLE "RULES_PARAMETERS"( + "UUID" VARCHAR(40) NOT NULL, + "RULE_ID" INTEGER NOT NULL, + "NAME" VARCHAR(128) NOT NULL, + "DESCRIPTION" VARCHAR(4000), + "PARAM_TYPE" VARCHAR(512) NOT NULL, + "DEFAULT_VALUE" VARCHAR(4000), + "RULE_UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "RULES_PARAMETERS" ADD CONSTRAINT "PK_RULES_PARAMETERS" PRIMARY KEY("UUID"); +CREATE INDEX "RULES_PARAMETERS_RULE_ID" ON "RULES_PARAMETERS"("RULE_ID"); +CREATE UNIQUE INDEX "RULES_PARAMETERS_UNIQUE" ON "RULES_PARAMETERS"("RULE_ID", "NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/DropRuleIdColumnOfRulesParametersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/DropRuleIdColumnOfRulesParametersTableTest/schema.sql new file mode 100644 index 00000000000..eafb90192e1 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/DropRuleIdColumnOfRulesParametersTableTest/schema.sql @@ -0,0 +1,43 @@ +create TABLE "RULES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "NAME" VARCHAR(200), + "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, + "PLUGIN_KEY" VARCHAR(200), + "PLUGIN_CONFIG_KEY" VARCHAR(200), + "PLUGIN_NAME" VARCHAR(255) NOT NULL, + "SCOPE" VARCHAR(20) NOT NULL, + "DESCRIPTION" CLOB(2147483647), + "PRIORITY" INTEGER, + "STATUS" VARCHAR(40), + "LANGUAGE" VARCHAR(20), + "DEF_REMEDIATION_FUNCTION" VARCHAR(20), + "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), + "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), + "GAP_DESCRIPTION" VARCHAR(4000), + "SYSTEM_TAGS" VARCHAR(4000), + "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, + "DESCRIPTION_FORMAT" VARCHAR(20), + "RULE_TYPE" TINYINT, + "SECURITY_STANDARDS" VARCHAR(4000), + "IS_AD_HOC" BOOLEAN NOT NULL, + "IS_EXTERNAL" BOOLEAN NOT NULL, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_UUID" VARCHAR(40) +); +alter table "RULES" add CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); +create UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); + +create TABLE "RULES_PARAMETERS"( + "UUID" VARCHAR(40) NOT NULL, + "RULE_ID" INTEGER NOT NULL, + "NAME" VARCHAR(128) NOT NULL, + "DESCRIPTION" VARCHAR(4000), + "PARAM_TYPE" VARCHAR(512) NOT NULL, + "DEFAULT_VALUE" VARCHAR(4000), + "RULE_UUID" VARCHAR(40) NOT NULL +); +alter table "RULES_PARAMETERS" add CONSTRAINT "PK_RULES_PARAMETERS" PRIMARY KEY("UUID"); +create INDEX "RULES_PARAMETERS_RULE_UUID" ON "RULES_PARAMETERS"("RULE_UUID"); +create UNIQUE INDEX "RULES_PARAMETERS_UNIQUE" ON "RULES_PARAMETERS"("RULE_UUID", "NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/MakeRulesParametersRuleUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/MakeRulesParametersRuleUuidColumnNotNullableTest/schema.sql new file mode 100644 index 00000000000..9fdc54dfb08 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/MakeRulesParametersRuleUuidColumnNotNullableTest/schema.sql @@ -0,0 +1,43 @@ +CREATE TABLE "RULES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "NAME" VARCHAR(200), + "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, + "PLUGIN_KEY" VARCHAR(200), + "PLUGIN_CONFIG_KEY" VARCHAR(200), + "PLUGIN_NAME" VARCHAR(255) NOT NULL, + "SCOPE" VARCHAR(20) NOT NULL, + "DESCRIPTION" CLOB(2147483647), + "PRIORITY" INTEGER, + "STATUS" VARCHAR(40), + "LANGUAGE" VARCHAR(20), + "DEF_REMEDIATION_FUNCTION" VARCHAR(20), + "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), + "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), + "GAP_DESCRIPTION" VARCHAR(4000), + "SYSTEM_TAGS" VARCHAR(4000), + "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, + "DESCRIPTION_FORMAT" VARCHAR(20), + "RULE_TYPE" TINYINT, + "SECURITY_STANDARDS" VARCHAR(4000), + "IS_AD_HOC" BOOLEAN NOT NULL, + "IS_EXTERNAL" BOOLEAN NOT NULL, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_UUID" VARCHAR(40) +); +ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); + +CREATE TABLE "RULES_PARAMETERS"( + "UUID" VARCHAR(40) NOT NULL, + "RULE_ID" INTEGER NOT NULL, + "NAME" VARCHAR(128) NOT NULL, + "DESCRIPTION" VARCHAR(4000), + "PARAM_TYPE" VARCHAR(512) NOT NULL, + "DEFAULT_VALUE" VARCHAR(4000), + "RULE_UUID" VARCHAR(40) +); +ALTER TABLE "RULES_PARAMETERS" ADD CONSTRAINT "PK_RULES_PARAMETERS" PRIMARY KEY("UUID"); +CREATE INDEX "RULES_PARAMETERS_RULE_ID" ON "RULES_PARAMETERS"("RULE_ID"); +CREATE UNIQUE INDEX "RULES_PARAMETERS_UNIQUE" ON "RULES_PARAMETERS"("RULE_ID", "NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/PopulateRulesParametersRuleUuidColumnTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/PopulateRulesParametersRuleUuidColumnTest/schema.sql new file mode 100644 index 00000000000..9fdc54dfb08 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rules/rulesparameters/PopulateRulesParametersRuleUuidColumnTest/schema.sql @@ -0,0 +1,43 @@ +CREATE TABLE "RULES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "NAME" VARCHAR(200), + "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, + "PLUGIN_KEY" VARCHAR(200), + "PLUGIN_CONFIG_KEY" VARCHAR(200), + "PLUGIN_NAME" VARCHAR(255) NOT NULL, + "SCOPE" VARCHAR(20) NOT NULL, + "DESCRIPTION" CLOB(2147483647), + "PRIORITY" INTEGER, + "STATUS" VARCHAR(40), + "LANGUAGE" VARCHAR(20), + "DEF_REMEDIATION_FUNCTION" VARCHAR(20), + "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), + "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), + "GAP_DESCRIPTION" VARCHAR(4000), + "SYSTEM_TAGS" VARCHAR(4000), + "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, + "DESCRIPTION_FORMAT" VARCHAR(20), + "RULE_TYPE" TINYINT, + "SECURITY_STANDARDS" VARCHAR(4000), + "IS_AD_HOC" BOOLEAN NOT NULL, + "IS_EXTERNAL" BOOLEAN NOT NULL, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "UUID" VARCHAR(40) NOT NULL, + "TEMPLATE_UUID" VARCHAR(40) +); +ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY", "PLUGIN_NAME"); + +CREATE TABLE "RULES_PARAMETERS"( + "UUID" VARCHAR(40) NOT NULL, + "RULE_ID" INTEGER NOT NULL, + "NAME" VARCHAR(128) NOT NULL, + "DESCRIPTION" VARCHAR(4000), + "PARAM_TYPE" VARCHAR(512) NOT NULL, + "DEFAULT_VALUE" VARCHAR(4000), + "RULE_UUID" VARCHAR(40) +); +ALTER TABLE "RULES_PARAMETERS" ADD CONSTRAINT "PK_RULES_PARAMETERS" PRIMARY KEY("UUID"); +CREATE INDEX "RULES_PARAMETERS_RULE_ID" ON "RULES_PARAMETERS"("RULE_ID"); +CREATE UNIQUE INDEX "RULES_PARAMETERS_UNIQUE" ON "RULES_PARAMETERS"("RULE_ID", "NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddPrimaryKeyOnUuidColumnOfRulesParametersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddPrimaryKeyOnUuidColumnOfRulesParametersTableTest/schema.sql new file mode 100644 index 00000000000..961a5cb8cac --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddPrimaryKeyOnUuidColumnOfRulesParametersTableTest/schema.sql @@ -0,0 +1,11 @@ +CREATE TABLE "RULES_PARAMETERS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "RULE_ID" INTEGER NOT NULL, + "NAME" VARCHAR(128) NOT NULL, + "DESCRIPTION" VARCHAR(4000), + "PARAM_TYPE" VARCHAR(512) NOT NULL, + "DEFAULT_VALUE" VARCHAR(4000) +); +CREATE INDEX "RULES_PARAMETERS_RULE_ID" ON "RULES_PARAMETERS"("RULE_ID"); +CREATE UNIQUE INDEX "RULES_PARAMETERS_UNIQUE" ON "RULES_PARAMETERS"("RULE_ID", "NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddUuidColumnToRulesParametersTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddUuidColumnToRulesParametersTest/schema.sql new file mode 100644 index 00000000000..98a62c638d9 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddUuidColumnToRulesParametersTest/schema.sql @@ -0,0 +1,11 @@ +CREATE TABLE "RULES_PARAMETERS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "RULE_ID" INTEGER NOT NULL, + "NAME" VARCHAR(128) NOT NULL, + "DESCRIPTION" VARCHAR(4000), + "PARAM_TYPE" VARCHAR(512) NOT NULL, + "DEFAULT_VALUE" VARCHAR(4000) +); +ALTER TABLE "RULES_PARAMETERS" ADD CONSTRAINT "PK_RULES_PARAMETERS" PRIMARY KEY("ID"); +CREATE INDEX "RULES_PARAMETERS_RULE_ID" ON "RULES_PARAMETERS"("RULE_ID"); +CREATE UNIQUE INDEX "RULES_PARAMETERS_UNIQUE" ON "RULES_PARAMETERS"("RULE_ID", "NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropIdColumnOfRulesParametersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropIdColumnOfRulesParametersTableTest/schema.sql new file mode 100644 index 00000000000..60597fff321 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropIdColumnOfRulesParametersTableTest/schema.sql @@ -0,0 +1,12 @@ +CREATE TABLE "RULES_PARAMETERS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "RULE_ID" INTEGER NOT NULL, + "NAME" VARCHAR(128) NOT NULL, + "DESCRIPTION" VARCHAR(4000), + "PARAM_TYPE" VARCHAR(512) NOT NULL, + "DEFAULT_VALUE" VARCHAR(4000) +); +ALTER TABLE "RULES_PARAMETERS" ADD CONSTRAINT "PK_RULES_PARAMETERS" PRIMARY KEY("UUID"); +CREATE INDEX "RULES_PARAMETERS_RULE_ID" ON "RULES_PARAMETERS"("RULE_ID"); +CREATE UNIQUE INDEX "RULES_PARAMETERS_UNIQUE" ON "RULES_PARAMETERS"("RULE_ID", "NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropPrimaryKeyOnIdColumnOfRulesParametersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropPrimaryKeyOnIdColumnOfRulesParametersTableTest/schema.sql new file mode 100644 index 00000000000..efdec30874f --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropPrimaryKeyOnIdColumnOfRulesParametersTableTest/schema.sql @@ -0,0 +1,12 @@ +CREATE TABLE "RULES_PARAMETERS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "RULE_ID" INTEGER NOT NULL, + "NAME" VARCHAR(128) NOT NULL, + "DESCRIPTION" VARCHAR(4000), + "PARAM_TYPE" VARCHAR(512) NOT NULL, + "DEFAULT_VALUE" VARCHAR(4000) +); +ALTER TABLE "RULES_PARAMETERS" ADD CONSTRAINT "PK_RULES_PARAMETERS" PRIMARY KEY("ID"); +CREATE INDEX "RULES_PARAMETERS_RULE_ID" ON "RULES_PARAMETERS"("RULE_ID"); +CREATE UNIQUE INDEX "RULES_PARAMETERS_UNIQUE" ON "RULES_PARAMETERS"("RULE_ID", "NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/MakeRulesParametersUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/MakeRulesParametersUuidColumnNotNullableTest/schema.sql new file mode 100644 index 00000000000..55efee58993 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/MakeRulesParametersUuidColumnNotNullableTest/schema.sql @@ -0,0 +1,12 @@ +CREATE TABLE "RULES_PARAMETERS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40), + "RULE_ID" INTEGER NOT NULL, + "NAME" VARCHAR(128) NOT NULL, + "DESCRIPTION" VARCHAR(4000), + "PARAM_TYPE" VARCHAR(512) NOT NULL, + "DEFAULT_VALUE" VARCHAR(4000) +); +ALTER TABLE "RULES_PARAMETERS" ADD CONSTRAINT "PK_RULES_PARAMETERS" PRIMARY KEY("ID"); +CREATE INDEX "RULES_PARAMETERS_RULE_ID" ON "RULES_PARAMETERS"("RULE_ID"); +CREATE UNIQUE INDEX "RULES_PARAMETERS_UNIQUE" ON "RULES_PARAMETERS"("RULE_ID", "NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/PopulateRulesParametersUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/PopulateRulesParametersUuidTest/schema.sql new file mode 100644 index 00000000000..55efee58993 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/PopulateRulesParametersUuidTest/schema.sql @@ -0,0 +1,12 @@ +CREATE TABLE "RULES_PARAMETERS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40), + "RULE_ID" INTEGER NOT NULL, + "NAME" VARCHAR(128) NOT NULL, + "DESCRIPTION" VARCHAR(4000), + "PARAM_TYPE" VARCHAR(512) NOT NULL, + "DEFAULT_VALUE" VARCHAR(4000) +); +ALTER TABLE "RULES_PARAMETERS" ADD CONSTRAINT "PK_RULES_PARAMETERS" PRIMARY KEY("ID"); +CREATE INDEX "RULES_PARAMETERS_RULE_ID" ON "RULES_PARAMETERS"("RULE_ID"); +CREATE UNIQUE INDEX "RULES_PARAMETERS_UNIQUE" ON "RULES_PARAMETERS"("RULE_ID", "NAME"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/AddRulesParameterUuidColumnToActiveRuleParametersTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/AddRulesParameterUuidColumnToActiveRuleParametersTest/schema.sql new file mode 100644 index 00000000000..04d58e9edf0 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/AddRulesParameterUuidColumnToActiveRuleParametersTest/schema.sql @@ -0,0 +1,9 @@ +CREATE TABLE "ACTIVE_RULE_PARAMETERS"( + "ACTIVE_RULE_ID" INTEGER NOT NULL, + "RULES_PARAMETER_ID" INTEGER NOT NULL, + "VALUE" VARCHAR(4000), + "RULES_PARAMETER_KEY" VARCHAR(128), + "UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("UUID"); +CREATE INDEX "IX_ARP_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/DropRulesParameterIdColumnOfActiveRuleParametersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/DropRulesParameterIdColumnOfActiveRuleParametersTableTest/schema.sql new file mode 100644 index 00000000000..3782982a167 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/DropRulesParameterIdColumnOfActiveRuleParametersTableTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "ACTIVE_RULE_PARAMETERS"( + "ACTIVE_RULE_ID" INTEGER NOT NULL, + "RULES_PARAMETER_ID" INTEGER NOT NULL, + "RULES_PARAMETER_UUID" VARCHAR(40) NOT NULL, + "VALUE" VARCHAR(4000), + "RULES_PARAMETER_KEY" VARCHAR(128), + "UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("UUID"); +CREATE INDEX "IX_ARP_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/MakeActiveRuleParametersRulesParameterUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/MakeActiveRuleParametersRulesParameterUuidColumnNotNullableTest/schema.sql new file mode 100644 index 00000000000..de06e416db2 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/MakeActiveRuleParametersRulesParameterUuidColumnNotNullableTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "ACTIVE_RULE_PARAMETERS"( + "ACTIVE_RULE_ID" INTEGER NOT NULL, + "RULES_PARAMETER_ID" INTEGER NOT NULL, + "RULES_PARAMETER_UUID" VARCHAR(40), + "VALUE" VARCHAR(4000), + "RULES_PARAMETER_KEY" VARCHAR(128), + "UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("UUID"); +CREATE INDEX "IX_ARP_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/PopulateActiveRuleParametersRulesParameterUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/PopulateActiveRuleParametersRulesParameterUuidTest/schema.sql new file mode 100644 index 00000000000..0bb696c346c --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesparameters/fk/PopulateActiveRuleParametersRulesParameterUuidTest/schema.sql @@ -0,0 +1,23 @@ +CREATE TABLE "RULES_PARAMETERS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "RULE_ID" INTEGER NOT NULL, + "NAME" VARCHAR(128) NOT NULL, + "DESCRIPTION" VARCHAR(4000), + "PARAM_TYPE" VARCHAR(512) NOT NULL, + "DEFAULT_VALUE" VARCHAR(4000) +); +ALTER TABLE "RULES_PARAMETERS" ADD CONSTRAINT "PK_RULES_PARAMETERS" PRIMARY KEY("ID"); +CREATE INDEX "RULES_PARAMETERS_RULE_ID" ON "RULES_PARAMETERS"("RULE_ID"); +CREATE UNIQUE INDEX "RULES_PARAMETERS_UNIQUE" ON "RULES_PARAMETERS"("RULE_ID", "NAME"); + +CREATE TABLE "ACTIVE_RULE_PARAMETERS"( + "ACTIVE_RULE_ID" INTEGER NOT NULL, + "RULES_PARAMETER_ID" INTEGER NOT NULL, + "RULES_PARAMETER_UUID" VARCHAR(40), + "VALUE" VARCHAR(4000), + "RULES_PARAMETER_KEY" VARCHAR(128), + "UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "PK_ACTIVE_RULE_PARAMETERS" PRIMARY KEY("UUID"); +CREATE INDEX "IX_ARP_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_PARAMETERS"("ACTIVE_RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddPrimaryKeyOnUuidColumnOfRulesProfilesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddPrimaryKeyOnUuidColumnOfRulesProfilesTableTest/schema.sql new file mode 100644 index 00000000000..8f7a7f216ae --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddPrimaryKeyOnUuidColumnOfRulesProfilesTableTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "RULES_PROFILES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(100) NOT NULL, + "LANGUAGE" VARCHAR(20), + "IS_BUILT_IN" BOOLEAN NOT NULL, + "RULES_UPDATED_AT" VARCHAR(100), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddUuidColumnToRulesProfilesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddUuidColumnToRulesProfilesTableTest/schema.sql new file mode 100644 index 00000000000..de92d69aeb0 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddUuidColumnToRulesProfilesTableTest/schema.sql @@ -0,0 +1,12 @@ +CREATE TABLE "RULES_PROFILES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "NAME" VARCHAR(100) NOT NULL, + "LANGUAGE" VARCHAR(20), + "KEE" VARCHAR(255) NOT NULL, + "IS_BUILT_IN" BOOLEAN NOT NULL, + "RULES_UPDATED_AT" VARCHAR(100), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "RULES_PROFILES" ADD CONSTRAINT "PK_RULES_PROFILES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "UNIQ_QPROF_KEY" ON "RULES_PROFILES"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropIdColumnOfRulesProfilesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropIdColumnOfRulesProfilesTableTest/schema.sql new file mode 100644 index 00000000000..0236b7e6554 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropIdColumnOfRulesProfilesTableTest/schema.sql @@ -0,0 +1,11 @@ +CREATE TABLE "RULES_PROFILES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(100) NOT NULL, + "LANGUAGE" VARCHAR(20), + "IS_BUILT_IN" BOOLEAN NOT NULL, + "RULES_UPDATED_AT" VARCHAR(100), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "RULES_PROFILES" ADD CONSTRAINT "PK_RULES_PROFILES" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropKeeColumnOfRulesProfilesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropKeeColumnOfRulesProfilesTableTest/schema.sql new file mode 100644 index 00000000000..eeb2ebcbd94 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropKeeColumnOfRulesProfilesTableTest/schema.sql @@ -0,0 +1,13 @@ +CREATE TABLE "RULES_PROFILES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(100) NOT NULL, + "LANGUAGE" VARCHAR(20), + "KEE" VARCHAR(255) NOT NULL, + "IS_BUILT_IN" BOOLEAN NOT NULL, + "RULES_UPDATED_AT" VARCHAR(100), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "RULES_PROFILES" ADD CONSTRAINT "PK_RULES_PROFILES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "UNIQ_QPROF_KEY" ON "RULES_PROFILES"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropPrimaryKeyOnIdColumnOfRulesProfilesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropPrimaryKeyOnIdColumnOfRulesProfilesTableTest/schema.sql new file mode 100644 index 00000000000..20448a4d9fe --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropPrimaryKeyOnIdColumnOfRulesProfilesTableTest/schema.sql @@ -0,0 +1,11 @@ +CREATE TABLE "RULES_PROFILES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(100) NOT NULL, + "LANGUAGE" VARCHAR(20), + "IS_BUILT_IN" BOOLEAN NOT NULL, + "RULES_UPDATED_AT" VARCHAR(100), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "RULES_PROFILES" ADD CONSTRAINT "PK_RULES_PROFILES" PRIMARY KEY("ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropUniqueIndexOnKeeColumnOfRulesProfilesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropUniqueIndexOnKeeColumnOfRulesProfilesTableTest/schema.sql new file mode 100644 index 00000000000..eeb2ebcbd94 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropUniqueIndexOnKeeColumnOfRulesProfilesTableTest/schema.sql @@ -0,0 +1,13 @@ +CREATE TABLE "RULES_PROFILES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(100) NOT NULL, + "LANGUAGE" VARCHAR(20), + "KEE" VARCHAR(255) NOT NULL, + "IS_BUILT_IN" BOOLEAN NOT NULL, + "RULES_UPDATED_AT" VARCHAR(100), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "RULES_PROFILES" ADD CONSTRAINT "PK_RULES_PROFILES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "UNIQ_QPROF_KEY" ON "RULES_PROFILES"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/MakeRulesProfilesUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/MakeRulesProfilesUuidColumnNotNullableTest/schema.sql new file mode 100644 index 00000000000..fd1ad1ea6a2 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/MakeRulesProfilesUuidColumnNotNullableTest/schema.sql @@ -0,0 +1,13 @@ +CREATE TABLE "RULES_PROFILES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40), + "NAME" VARCHAR(100) NOT NULL, + "LANGUAGE" VARCHAR(20), + "KEE" VARCHAR(255) NOT NULL, + "IS_BUILT_IN" BOOLEAN NOT NULL, + "RULES_UPDATED_AT" VARCHAR(100), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "RULES_PROFILES" ADD CONSTRAINT "PK_RULES_PROFILES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "UNIQ_QPROF_KEY" ON "RULES_PROFILES"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/PopulateRulesProfilesUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/PopulateRulesProfilesUuidTest/schema.sql new file mode 100644 index 00000000000..fd1ad1ea6a2 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/PopulateRulesProfilesUuidTest/schema.sql @@ -0,0 +1,13 @@ +CREATE TABLE "RULES_PROFILES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40), + "NAME" VARCHAR(100) NOT NULL, + "LANGUAGE" VARCHAR(20), + "KEE" VARCHAR(255) NOT NULL, + "IS_BUILT_IN" BOOLEAN NOT NULL, + "RULES_UPDATED_AT" VARCHAR(100), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "RULES_PROFILES" ADD CONSTRAINT "PK_RULES_PROFILES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "UNIQ_QPROF_KEY" ON "RULES_PROFILES"("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/AddProfileUuidColumnToActiveRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/AddProfileUuidColumnToActiveRulesTableTest/schema.sql new file mode 100644 index 00000000000..d2e7c11c080 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/AddProfileUuidColumnToActiveRulesTableTest/schema.sql @@ -0,0 +1,11 @@ +CREATE TABLE "ACTIVE_RULES"( + "UUID" VARCHAR(40) NOT NULL, + "PROFILE_ID" INTEGER NOT NULL, + "RULE_ID" INTEGER NOT NULL, + "FAILURE_LEVEL" INTEGER NOT NULL, + "INHERITANCE" VARCHAR(10), + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT +); +ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("UUID"); +CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_ID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/AddUniqueIndexOnProfileUuidColumnOfActiveRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/AddUniqueIndexOnProfileUuidColumnOfActiveRulesTableTest/schema.sql new file mode 100644 index 00000000000..2dedcc6b5e2 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/AddUniqueIndexOnProfileUuidColumnOfActiveRulesTableTest/schema.sql @@ -0,0 +1,11 @@ +CREATE TABLE "ACTIVE_RULES"( + "UUID" VARCHAR(40) NOT NULL, + "PROFILE_ID" INTEGER NOT NULL, + "PROFILE_UUID" VARCHAR(40), + "RULE_ID" INTEGER NOT NULL, + "FAILURE_LEVEL" INTEGER NOT NULL, + "INHERITANCE" VARCHAR(10), + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT +); +ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/DropProfileIdColumnOfActiveRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/DropProfileIdColumnOfActiveRulesTableTest/schema.sql new file mode 100644 index 00000000000..2adacc4076d --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/DropProfileIdColumnOfActiveRulesTableTest/schema.sql @@ -0,0 +1,12 @@ +CREATE TABLE "ACTIVE_RULES"( + "UUID" VARCHAR(40) NOT NULL, + "PROFILE_ID" INTEGER NOT NULL, + "PROFILE_UUID" VARCHAR(40) NOT NULL, + "RULE_ID" INTEGER NOT NULL, + "FAILURE_LEVEL" INTEGER NOT NULL, + "INHERITANCE" VARCHAR(10), + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT +); +ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("UUID"); +CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_UUID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/DropUniqueIndexOnProfileIdColumnOfActiveRulesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/DropUniqueIndexOnProfileIdColumnOfActiveRulesTableTest/schema.sql new file mode 100644 index 00000000000..d7d0db7aa73 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/DropUniqueIndexOnProfileIdColumnOfActiveRulesTableTest/schema.sql @@ -0,0 +1,12 @@ +CREATE TABLE "ACTIVE_RULES"( + "UUID" VARCHAR(40) NOT NULL, + "PROFILE_ID" INTEGER NOT NULL, + "PROFILE_UUID" VARCHAR(40), + "RULE_ID" INTEGER NOT NULL, + "FAILURE_LEVEL" INTEGER NOT NULL, + "INHERITANCE" VARCHAR(10), + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT +); +ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("UUID"); +CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_ID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/MakeActiveRulesProfileUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/MakeActiveRulesProfileUuidColumnNotNullableTest/schema.sql new file mode 100644 index 00000000000..161696a041f --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/MakeActiveRulesProfileUuidColumnNotNullableTest/schema.sql @@ -0,0 +1,26 @@ +CREATE TABLE "RULES_PROFILES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(100) NOT NULL, + "LANGUAGE" VARCHAR(20), + "KEE" VARCHAR(255) NOT NULL, + "IS_BUILT_IN" BOOLEAN NOT NULL, + "RULES_UPDATED_AT" VARCHAR(100), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "RULES_PROFILES" ADD CONSTRAINT "PK_RULES_PROFILES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "UNIQ_QPROF_KEY" ON "RULES_PROFILES"("KEE"); + +CREATE TABLE "ACTIVE_RULES"( + "UUID" VARCHAR(40) NOT NULL, + "PROFILE_ID" INTEGER NOT NULL, + "PROFILE_UUID" VARCHAR(40), + "RULE_ID" INTEGER NOT NULL, + "FAILURE_LEVEL" INTEGER NOT NULL, + "INHERITANCE" VARCHAR(10), + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT +); +ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("UUID"); +CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_ID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/PopulateActiveRulesProfileUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/PopulateActiveRulesProfileUuidTest/schema.sql new file mode 100644 index 00000000000..161696a041f --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/activerules/PopulateActiveRulesProfileUuidTest/schema.sql @@ -0,0 +1,26 @@ +CREATE TABLE "RULES_PROFILES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(100) NOT NULL, + "LANGUAGE" VARCHAR(20), + "KEE" VARCHAR(255) NOT NULL, + "IS_BUILT_IN" BOOLEAN NOT NULL, + "RULES_UPDATED_AT" VARCHAR(100), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "RULES_PROFILES" ADD CONSTRAINT "PK_RULES_PROFILES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "UNIQ_QPROF_KEY" ON "RULES_PROFILES"("KEE"); + +CREATE TABLE "ACTIVE_RULES"( + "UUID" VARCHAR(40) NOT NULL, + "PROFILE_ID" INTEGER NOT NULL, + "PROFILE_UUID" VARCHAR(40), + "RULE_ID" INTEGER NOT NULL, + "FAILURE_LEVEL" INTEGER NOT NULL, + "INHERITANCE" VARCHAR(10), + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT +); +ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("UUID"); +CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_IDS" ON "ACTIVE_RULES"("PROFILE_ID", "RULE_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/orgqprofiles/PopulateOrgQProfilesRulesProfileUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/orgqprofiles/PopulateOrgQProfilesRulesProfileUuidTest/schema.sql new file mode 100644 index 00000000000..a1781cb90cc --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/orgqprofiles/PopulateOrgQProfilesRulesProfileUuidTest/schema.sql @@ -0,0 +1,28 @@ +CREATE TABLE "RULES_PROFILES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(100) NOT NULL, + "LANGUAGE" VARCHAR(20), + "KEE" VARCHAR(255) NOT NULL, + "IS_BUILT_IN" BOOLEAN NOT NULL, + "RULES_UPDATED_AT" VARCHAR(100), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "RULES_PROFILES" ADD CONSTRAINT "PK_RULES_PROFILES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "UNIQ_QPROF_KEY" ON "RULES_PROFILES"("KEE"); + +CREATE TABLE "ORG_QPROFILES"( + "UUID" VARCHAR(255) NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "RULES_PROFILE_UUID" VARCHAR(255) NOT NULL, + "PARENT_UUID" VARCHAR(255), + "LAST_USED" BIGINT, + "USER_UPDATED_AT" BIGINT, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL +); +ALTER TABLE "ORG_QPROFILES" ADD CONSTRAINT "PK_ORG_QPROFILES" PRIMARY KEY("UUID"); +CREATE INDEX "QPROFILES_ORG_UUID" ON "ORG_QPROFILES"("ORGANIZATION_UUID"); +CREATE INDEX "QPROFILES_RP_UUID" ON "ORG_QPROFILES"("RULES_PROFILE_UUID"); +CREATE INDEX "ORG_QPROFILES_PARENT_UUID" ON "ORG_QPROFILES"("PARENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/qprofilechanges/PopulateQProfileChangesRulesProfileUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/qprofilechanges/PopulateQProfileChangesRulesProfileUuidTest/schema.sql new file mode 100644 index 00000000000..75148b62b24 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/fk/qprofilechanges/PopulateQProfileChangesRulesProfileUuidTest/schema.sql @@ -0,0 +1,24 @@ +CREATE TABLE "RULES_PROFILES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(100) NOT NULL, + "LANGUAGE" VARCHAR(20), + "KEE" VARCHAR(255) NOT NULL, + "IS_BUILT_IN" BOOLEAN NOT NULL, + "RULES_UPDATED_AT" VARCHAR(100), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); +ALTER TABLE "RULES_PROFILES" ADD CONSTRAINT "PK_RULES_PROFILES" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "UNIQ_QPROF_KEY" ON "RULES_PROFILES"("KEE"); + +CREATE TABLE "QPROFILE_CHANGES"( + "KEE" VARCHAR(40) NOT NULL, + "RULES_PROFILE_UUID" VARCHAR(255) NOT NULL, + "CHANGE_TYPE" VARCHAR(20) NOT NULL, + "USER_UUID" VARCHAR(255), + "CHANGE_DATA" CLOB(2147483647), + "CREATED_AT" BIGINT NOT NULL +); +ALTER TABLE "QPROFILE_CHANGES" ADD CONSTRAINT "PK_QPROFILE_CHANGES" PRIMARY KEY("KEE"); +CREATE INDEX "QP_CHANGES_RULES_PROFILE_UUID" ON "QPROFILE_CHANGES"("RULES_PROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/snapshots/AddPrimaryKeyOnUuidColumnOfSnapshotsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/snapshots/AddPrimaryKeyOnUuidColumnOfSnapshotsTableTest/schema.sql new file mode 100644 index 00000000000..dcc23f6b586 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/snapshots/AddPrimaryKeyOnUuidColumnOfSnapshotsTableTest/schema.sql @@ -0,0 +1,30 @@ +CREATE TABLE "SNAPSHOTS"( + "ID" INTEGER NOT NULL, + "UUID" VARCHAR(50) NOT NULL, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "STATUS" VARCHAR(4) DEFAULT 'U' NOT NULL, + "ISLAST" BOOLEAN DEFAULT FALSE NOT NULL, + "VERSION" VARCHAR(500), + "PURGE_STATUS" INTEGER, + "BUILD_STRING" VARCHAR(100), + "REVISION" VARCHAR(100), + "BUILD_DATE" BIGINT, + "PERIOD1_MODE" VARCHAR(100), + "PERIOD1_PARAM" VARCHAR(100), + "PERIOD2_MODE" VARCHAR(100), + "PERIOD2_PARAM" VARCHAR(100), + "PERIOD3_MODE" VARCHAR(100), + "PERIOD3_PARAM" VARCHAR(100), + "PERIOD4_MODE" VARCHAR(100), + "PERIOD4_PARAM" VARCHAR(100), + "PERIOD5_MODE" VARCHAR(100), + "PERIOD5_PARAM" VARCHAR(100), + "PERIOD1_DATE" BIGINT, + "PERIOD2_DATE" BIGINT, + "PERIOD3_DATE" BIGINT, + "PERIOD4_DATE" BIGINT, + "PERIOD5_DATE" BIGINT, + "CREATED_AT" BIGINT +); +CREATE UNIQUE INDEX "ANALYSES_UUID" ON "SNAPSHOTS"("UUID"); +CREATE INDEX "SNAPSHOT_COMPONENT" ON "SNAPSHOTS"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/snapshots/DropIdColumnOfSnapshotsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/snapshots/DropIdColumnOfSnapshotsTableTest/schema.sql new file mode 100644 index 00000000000..c1891409f11 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/snapshots/DropIdColumnOfSnapshotsTableTest/schema.sql @@ -0,0 +1,31 @@ +CREATE TABLE "SNAPSHOTS"( + "ID" INTEGER NOT NULL, + "UUID" VARCHAR(50) NOT NULL, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "STATUS" VARCHAR(4) DEFAULT 'U' NOT NULL, + "ISLAST" BOOLEAN DEFAULT FALSE NOT NULL, + "VERSION" VARCHAR(500), + "PURGE_STATUS" INTEGER, + "BUILD_STRING" VARCHAR(100), + "REVISION" VARCHAR(100), + "BUILD_DATE" BIGINT, + "PERIOD1_MODE" VARCHAR(100), + "PERIOD1_PARAM" VARCHAR(100), + "PERIOD2_MODE" VARCHAR(100), + "PERIOD2_PARAM" VARCHAR(100), + "PERIOD3_MODE" VARCHAR(100), + "PERIOD3_PARAM" VARCHAR(100), + "PERIOD4_MODE" VARCHAR(100), + "PERIOD4_PARAM" VARCHAR(100), + "PERIOD5_MODE" VARCHAR(100), + "PERIOD5_PARAM" VARCHAR(100), + "PERIOD1_DATE" BIGINT, + "PERIOD2_DATE" BIGINT, + "PERIOD3_DATE" BIGINT, + "PERIOD4_DATE" BIGINT, + "PERIOD5_DATE" BIGINT, + "CREATED_AT" BIGINT +); +ALTER TABLE "SNAPSHOTS" ADD CONSTRAINT "PK_SNAPSHOTS" PRIMARY KEY("UUID"); +CREATE UNIQUE INDEX "ANALYSES_UUID" ON "SNAPSHOTS"("UUID"); +CREATE INDEX "SNAPSHOT_COMPONENT" ON "SNAPSHOTS"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/snapshots/DropPrimaryKeyOnIdColumnOfSnapshotsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/snapshots/DropPrimaryKeyOnIdColumnOfSnapshotsTableTest/schema.sql new file mode 100644 index 00000000000..3d3e2694b15 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/snapshots/DropPrimaryKeyOnIdColumnOfSnapshotsTableTest/schema.sql @@ -0,0 +1,31 @@ +CREATE TABLE "SNAPSHOTS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(50) NOT NULL, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "STATUS" VARCHAR(4) DEFAULT 'U' NOT NULL, + "ISLAST" BOOLEAN DEFAULT FALSE NOT NULL, + "VERSION" VARCHAR(500), + "PURGE_STATUS" INTEGER, + "BUILD_STRING" VARCHAR(100), + "REVISION" VARCHAR(100), + "BUILD_DATE" BIGINT, + "PERIOD1_MODE" VARCHAR(100), + "PERIOD1_PARAM" VARCHAR(100), + "PERIOD2_MODE" VARCHAR(100), + "PERIOD2_PARAM" VARCHAR(100), + "PERIOD3_MODE" VARCHAR(100), + "PERIOD3_PARAM" VARCHAR(100), + "PERIOD4_MODE" VARCHAR(100), + "PERIOD4_PARAM" VARCHAR(100), + "PERIOD5_MODE" VARCHAR(100), + "PERIOD5_PARAM" VARCHAR(100), + "PERIOD1_DATE" BIGINT, + "PERIOD2_DATE" BIGINT, + "PERIOD3_DATE" BIGINT, + "PERIOD4_DATE" BIGINT, + "PERIOD5_DATE" BIGINT, + "CREATED_AT" BIGINT +); +ALTER TABLE "SNAPSHOTS" ADD CONSTRAINT "PK_SNAPSHOTS" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "ANALYSES_UUID" ON "SNAPSHOTS"("UUID"); +CREATE INDEX "SNAPSHOT_COMPONENT" ON "SNAPSHOTS"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/userroles/AddPrimaryKeyOnUuidColumnOfUserRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/userroles/AddPrimaryKeyOnUuidColumnOfUserRolesTableTest/schema.sql new file mode 100644 index 00000000000..782ae4e6684 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/userroles/AddPrimaryKeyOnUuidColumnOfUserRolesTableTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "USER_ROLES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "USER_ID" INTEGER, + "ROLE" VARCHAR(64) NOT NULL, + "COMPONENT_UUID" VARCHAR(40) +); +CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES"("USER_ID"); +CREATE INDEX "USER_ROLES_COMPONENT_UUID" ON "USER_ROLES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/userroles/AddUuidColumnToUserRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/userroles/AddUuidColumnToUserRolesTableTest/schema.sql new file mode 100644 index 00000000000..b30da4d7928 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/userroles/AddUuidColumnToUserRolesTableTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "USER_ROLES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "USER_ID" INTEGER, + "ROLE" VARCHAR(64) NOT NULL, + "COMPONENT_UUID" VARCHAR(40) +); +ALTER TABLE "USER_ROLES" ADD CONSTRAINT "PK_USER_ROLES" PRIMARY KEY("ID"); +CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES"("USER_ID"); +CREATE INDEX "USER_ROLES_COMPONENT_UUID" ON "USER_ROLES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/userroles/DropIdColumnOfUserRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/userroles/DropIdColumnOfUserRolesTableTest/schema.sql new file mode 100644 index 00000000000..334d2d2b80f --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/userroles/DropIdColumnOfUserRolesTableTest/schema.sql @@ -0,0 +1,11 @@ +CREATE TABLE "USER_ROLES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "USER_ID" INTEGER, + "ROLE" VARCHAR(64) NOT NULL, + "COMPONENT_UUID" VARCHAR(40) +); +ALTER TABLE "USER_ROLES" ADD CONSTRAINT "PK_USER_ROLES" PRIMARY KEY("UUID"); +CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES"("USER_ID"); +CREATE INDEX "USER_ROLES_COMPONENT_UUID" ON "USER_ROLES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/userroles/DropPrimaryKeyOnIdColumnOfUserRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/userroles/DropPrimaryKeyOnIdColumnOfUserRolesTableTest/schema.sql new file mode 100644 index 00000000000..1970f132a00 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/userroles/DropPrimaryKeyOnIdColumnOfUserRolesTableTest/schema.sql @@ -0,0 +1,11 @@ +CREATE TABLE "USER_ROLES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40) NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "USER_ID" INTEGER, + "ROLE" VARCHAR(64) NOT NULL, + "COMPONENT_UUID" VARCHAR(40) +); +ALTER TABLE "USER_ROLES" ADD CONSTRAINT "PK_USER_ROLES" PRIMARY KEY("ID"); +CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES"("USER_ID"); +CREATE INDEX "USER_ROLES_COMPONENT_UUID" ON "USER_ROLES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/userroles/MakeUserRolesUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/userroles/MakeUserRolesUuidColumnNotNullableTest/schema.sql new file mode 100644 index 00000000000..80f78b06ede --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/userroles/MakeUserRolesUuidColumnNotNullableTest/schema.sql @@ -0,0 +1,11 @@ +CREATE TABLE "USER_ROLES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40), + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "USER_ID" INTEGER, + "ROLE" VARCHAR(64) NOT NULL, + "COMPONENT_UUID" VARCHAR(40) +); +ALTER TABLE "USER_ROLES" ADD CONSTRAINT "PK_USER_ROLES" PRIMARY KEY("ID"); +CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES"("USER_ID"); +CREATE INDEX "USER_ROLES_COMPONENT_UUID" ON "USER_ROLES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/userroles/PopulateUserRolesUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/userroles/PopulateUserRolesUuidTest/schema.sql new file mode 100644 index 00000000000..80f78b06ede --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/userroles/PopulateUserRolesUuidTest/schema.sql @@ -0,0 +1,11 @@ +CREATE TABLE "USER_ROLES"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40), + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "USER_ID" INTEGER, + "ROLE" VARCHAR(64) NOT NULL, + "COMPONENT_UUID" VARCHAR(40) +); +ALTER TABLE "USER_ROLES" ADD CONSTRAINT "PK_USER_ROLES" PRIMARY KEY("ID"); +CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES"("USER_ID"); +CREATE INDEX "USER_ROLES_COMPONENT_UUID" ON "USER_ROLES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/AddPrimaryKeyOnUuidColumnOfUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/AddPrimaryKeyOnUuidColumnOfUsersTableTest/schema.sql new file mode 100644 index 00000000000..3b7668e51e3 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/AddPrimaryKeyOnUuidColumnOfUsersTableTest/schema.sql @@ -0,0 +1,29 @@ +CREATE TABLE "USERS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(255) NOT NULL, + "LOGIN" VARCHAR(255) NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40), + "NAME" VARCHAR(200), + "EMAIL" VARCHAR(100), + "CRYPTED_PASSWORD" VARCHAR(100), + "SALT" VARCHAR(40), + "HASH_METHOD" VARCHAR(10), + "ACTIVE" BOOLEAN DEFAULT TRUE, + "SCM_ACCOUNTS" VARCHAR(4000), + "EXTERNAL_LOGIN" VARCHAR(255) NOT NULL, + "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100) NOT NULL, + "EXTERNAL_ID" VARCHAR(255) NOT NULL, + "IS_ROOT" BOOLEAN NOT NULL, + "USER_LOCAL" BOOLEAN, + "ONBOARDED" BOOLEAN NOT NULL, + "HOMEPAGE_TYPE" VARCHAR(40), + "HOMEPAGE_PARAMETER" VARCHAR(40), + "LAST_CONNECTION_DATE" BIGINT, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT +); +CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS"("LOGIN"); +CREATE INDEX "USERS_UPDATED_AT" ON "USERS"("UPDATED_AT"); +CREATE UNIQUE INDEX "USERS_UUID" ON "USERS"("UUID"); +CREATE UNIQUE INDEX "UNIQ_EXTERNAL_ID" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_ID"); +CREATE UNIQUE INDEX "UNIQ_EXTERNAL_LOGIN" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_LOGIN"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/DropIdColumnOfUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/DropIdColumnOfUsersTableTest/schema.sql new file mode 100644 index 00000000000..c1eab3c95ac --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/DropIdColumnOfUsersTableTest/schema.sql @@ -0,0 +1,30 @@ +CREATE TABLE "USERS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(255) NOT NULL, + "LOGIN" VARCHAR(255) NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40), + "NAME" VARCHAR(200), + "EMAIL" VARCHAR(100), + "CRYPTED_PASSWORD" VARCHAR(100), + "SALT" VARCHAR(40), + "HASH_METHOD" VARCHAR(10), + "ACTIVE" BOOLEAN DEFAULT TRUE, + "SCM_ACCOUNTS" VARCHAR(4000), + "EXTERNAL_LOGIN" VARCHAR(255) NOT NULL, + "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100) NOT NULL, + "EXTERNAL_ID" VARCHAR(255) NOT NULL, + "IS_ROOT" BOOLEAN NOT NULL, + "USER_LOCAL" BOOLEAN, + "ONBOARDED" BOOLEAN NOT NULL, + "HOMEPAGE_TYPE" VARCHAR(40), + "HOMEPAGE_PARAMETER" VARCHAR(40), + "LAST_CONNECTION_DATE" BIGINT, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT +); +ALTER TABLE "USERS" ADD CONSTRAINT "PK_USERS" PRIMARY KEY("UUID"); +CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS"("LOGIN"); +CREATE INDEX "USERS_UPDATED_AT" ON "USERS"("UPDATED_AT"); +CREATE UNIQUE INDEX "USERS_UUID" ON "USERS"("UUID"); +CREATE UNIQUE INDEX "UNIQ_EXTERNAL_ID" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_ID"); +CREATE UNIQUE INDEX "UNIQ_EXTERNAL_LOGIN" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_LOGIN"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/DropPrimaryKeyOnIdColumnOfUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/DropPrimaryKeyOnIdColumnOfUsersTableTest/schema.sql new file mode 100644 index 00000000000..014607f5179 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/DropPrimaryKeyOnIdColumnOfUsersTableTest/schema.sql @@ -0,0 +1,30 @@ +CREATE TABLE "USERS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(255) NOT NULL, + "LOGIN" VARCHAR(255) NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40), + "NAME" VARCHAR(200), + "EMAIL" VARCHAR(100), + "CRYPTED_PASSWORD" VARCHAR(100), + "SALT" VARCHAR(40), + "HASH_METHOD" VARCHAR(10), + "ACTIVE" BOOLEAN DEFAULT TRUE, + "SCM_ACCOUNTS" VARCHAR(4000), + "EXTERNAL_LOGIN" VARCHAR(255) NOT NULL, + "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100) NOT NULL, + "EXTERNAL_ID" VARCHAR(255) NOT NULL, + "IS_ROOT" BOOLEAN NOT NULL, + "USER_LOCAL" BOOLEAN, + "ONBOARDED" BOOLEAN NOT NULL, + "HOMEPAGE_TYPE" VARCHAR(40), + "HOMEPAGE_PARAMETER" VARCHAR(40), + "LAST_CONNECTION_DATE" BIGINT, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT +); +ALTER TABLE "USERS" ADD CONSTRAINT "PK_USERS" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS"("LOGIN"); +CREATE INDEX "USERS_UPDATED_AT" ON "USERS"("UPDATED_AT"); +CREATE UNIQUE INDEX "USERS_UUID" ON "USERS"("UUID"); +CREATE UNIQUE INDEX "UNIQ_EXTERNAL_ID" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_ID"); +CREATE UNIQUE INDEX "UNIQ_EXTERNAL_LOGIN" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_LOGIN"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/DropUniqueIndexOnUuidColumnOfUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/DropUniqueIndexOnUuidColumnOfUsersTableTest/schema.sql new file mode 100644 index 00000000000..3b7668e51e3 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/DropUniqueIndexOnUuidColumnOfUsersTableTest/schema.sql @@ -0,0 +1,29 @@ +CREATE TABLE "USERS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(255) NOT NULL, + "LOGIN" VARCHAR(255) NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40), + "NAME" VARCHAR(200), + "EMAIL" VARCHAR(100), + "CRYPTED_PASSWORD" VARCHAR(100), + "SALT" VARCHAR(40), + "HASH_METHOD" VARCHAR(10), + "ACTIVE" BOOLEAN DEFAULT TRUE, + "SCM_ACCOUNTS" VARCHAR(4000), + "EXTERNAL_LOGIN" VARCHAR(255) NOT NULL, + "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100) NOT NULL, + "EXTERNAL_ID" VARCHAR(255) NOT NULL, + "IS_ROOT" BOOLEAN NOT NULL, + "USER_LOCAL" BOOLEAN, + "ONBOARDED" BOOLEAN NOT NULL, + "HOMEPAGE_TYPE" VARCHAR(40), + "HOMEPAGE_PARAMETER" VARCHAR(40), + "LAST_CONNECTION_DATE" BIGINT, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT +); +CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS"("LOGIN"); +CREATE INDEX "USERS_UPDATED_AT" ON "USERS"("UPDATED_AT"); +CREATE UNIQUE INDEX "USERS_UUID" ON "USERS"("UUID"); +CREATE UNIQUE INDEX "UNIQ_EXTERNAL_ID" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_ID"); +CREATE UNIQUE INDEX "UNIQ_EXTERNAL_LOGIN" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_LOGIN"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddIndexOnUserUuidOfGroupsUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddIndexOnUserUuidOfGroupsUsersTableTest/schema.sql new file mode 100644 index 00000000000..87f8c34ea67 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddIndexOnUserUuidOfGroupsUsersTableTest/schema.sql @@ -0,0 +1,7 @@ +CREATE TABLE "GROUPS_USERS"( + "USER_ID" BIGINT, + "GROUP_UUID" VARCHAR(40) NOT NULL, + "USER_UUID" VARCHAR(40) NOT NULL +); +CREATE INDEX "INDEX_GROUPS_USERS_GROUP_UUID" ON "GROUPS_USERS"("GROUP_UUID"); +CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS"("GROUP_UUID", "USER_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTableTest/schema.sql new file mode 100644 index 00000000000..98085c9b74d --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddUniqueIndexOnUserUuidAndGroupIdOfGroupsUsersTableTest/schema.sql @@ -0,0 +1,7 @@ +CREATE TABLE "GROUPS_USERS"( + "USER_ID" BIGINT, + "GROUP_UUID" VARCHAR(40) NOT NULL, + "USER_UUID" VARCHAR(40) NOT NULL +); +CREATE INDEX "INDEX_GROUPS_USERS_USER_UUID" ON "GROUPS_USERS"("USER_UUID"); +CREATE INDEX "INDEX_GROUPS_USERS_GROUP_UUID" ON "GROUPS_USERS"("GROUP_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddUserUuidColumnToGroupsUsersTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddUserUuidColumnToGroupsUsersTest/schema.sql new file mode 100644 index 00000000000..a8f6820a912 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/AddUserUuidColumnToGroupsUsersTest/schema.sql @@ -0,0 +1,7 @@ +CREATE TABLE "GROUPS_USERS"( + "USER_ID" BIGINT, + "GROUP_UUID" VARCHAR(40) NOT NULL +); +CREATE INDEX "INDEX_GROUPS_USERS_ON_USER_ID" ON "GROUPS_USERS"("USER_ID"); +CREATE INDEX "INDEX_GROUPS_USERS_GROUP_UUID" ON "GROUPS_USERS"("GROUP_UUID"); +CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS"("GROUP_UUID", "USER_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropIndexOnUserIdOfGroupsUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropIndexOnUserIdOfGroupsUsersTableTest/schema.sql new file mode 100644 index 00000000000..e0a585dd66e --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropIndexOnUserIdOfGroupsUsersTableTest/schema.sql @@ -0,0 +1,8 @@ +CREATE TABLE "GROUPS_USERS"( + "USER_ID" BIGINT, + "GROUP_UUID" VARCHAR(40) NOT NULL, + "USER_UUID" VARCHAR(40) NOT NULL +); +CREATE INDEX "INDEX_GROUPS_USERS_ON_USER_ID" ON "GROUPS_USERS"("USER_ID"); +CREATE INDEX "INDEX_GROUPS_USERS_GROUP_UUID" ON "GROUPS_USERS"("GROUP_UUID"); +CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS"("GROUP_UUID", "USER_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTableTest/schema.sql new file mode 100644 index 00000000000..b71880d2f10 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropUniqueIndexOnUserIdAndGroupIdOfGroupsUsersTableTest/schema.sql @@ -0,0 +1,8 @@ +CREATE TABLE "GROUPS_USERS"( + "USER_ID" BIGINT, + "GROUP_UUID" VARCHAR(40) NOT NULL, + "USER_UUID" VARCHAR(40) NOT NULL +); +CREATE INDEX "INDEX_GROUPS_USERS_USER_UUID" ON "GROUPS_USERS"("USER_UUID"); +CREATE INDEX "INDEX_GROUPS_USERS_GROUP_UUID" ON "GROUPS_USERS"("GROUP_UUID"); +CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS"("GROUP_UUID", "USER_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropUserIdColumnOfGroupsUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropUserIdColumnOfGroupsUsersTableTest/schema.sql new file mode 100644 index 00000000000..b74eac2c904 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/DropUserIdColumnOfGroupsUsersTableTest/schema.sql @@ -0,0 +1,8 @@ +CREATE TABLE "GROUPS_USERS"( + "USER_ID" BIGINT, + "GROUP_UUID" VARCHAR(40) NOT NULL, + "USER_UUID" VARCHAR(40) NOT NULL +); +CREATE INDEX "INDEX_GROUPS_USERS_USER_UUID" ON "GROUPS_USERS"("USER_UUID"); +CREATE INDEX "INDEX_GROUPS_USERS_GROUP_UUID" ON "GROUPS_USERS"("GROUP_UUID"); +CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS"("GROUP_UUID", "USER_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/MakeGroupsUsersUserUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/MakeGroupsUsersUserUuidColumnNotNullableTest/schema.sql new file mode 100644 index 00000000000..167965e4750 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/MakeGroupsUsersUserUuidColumnNotNullableTest/schema.sql @@ -0,0 +1,8 @@ +CREATE TABLE "GROUPS_USERS"( + "USER_ID" BIGINT, + "GROUP_UUID" VARCHAR(40) NOT NULL, + "USER_UUID" VARCHAR(40) +); +CREATE INDEX "INDEX_GROUPS_USERS_ON_USER_ID" ON "GROUPS_USERS"("USER_ID"); +CREATE INDEX "INDEX_GROUPS_USERS_ON_GROUP_UUID" ON "GROUPS_USERS"("GROUP_UUID"); +CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS"("GROUP_UUID", "USER_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/PopulateGroupsUsersUserUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/PopulateGroupsUsersUserUuidTest/schema.sql new file mode 100644 index 00000000000..38059ac5a3a --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/groupsusers/PopulateGroupsUsersUserUuidTest/schema.sql @@ -0,0 +1,40 @@ +CREATE TABLE "USERS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(255) NOT NULL, + "LOGIN" VARCHAR(255) NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40), + "NAME" VARCHAR(200), + "EMAIL" VARCHAR(100), + "CRYPTED_PASSWORD" VARCHAR(100), + "SALT" VARCHAR(40), + "HASH_METHOD" VARCHAR(10), + "ACTIVE" BOOLEAN DEFAULT TRUE, + "SCM_ACCOUNTS" VARCHAR(4000), + "EXTERNAL_LOGIN" VARCHAR(255) NOT NULL, + "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100) NOT NULL, + "EXTERNAL_ID" VARCHAR(255) NOT NULL, + "IS_ROOT" BOOLEAN NOT NULL, + "USER_LOCAL" BOOLEAN, + "ONBOARDED" BOOLEAN NOT NULL, + "HOMEPAGE_TYPE" VARCHAR(40), + "HOMEPAGE_PARAMETER" VARCHAR(40), + "LAST_CONNECTION_DATE" BIGINT, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT +); +ALTER TABLE "USERS" ADD CONSTRAINT "PK_USERS" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS"("LOGIN"); +CREATE INDEX "USERS_UPDATED_AT" ON "USERS"("UPDATED_AT"); +CREATE UNIQUE INDEX "USERS_UUID" ON "USERS"("UUID"); +CREATE UNIQUE INDEX "UNIQ_EXTERNAL_ID" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_ID"); +CREATE UNIQUE INDEX "UNIQ_EXTERNAL_LOGIN" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_LOGIN"); + + +CREATE TABLE "GROUPS_USERS"( + "USER_ID" BIGINT, + "GROUP_UUID" VARCHAR(40) NOT NULL, + "USER_UUID" VARCHAR(40) +); +CREATE INDEX "INDEX_GROUPS_USERS_ON_USER_ID" ON "GROUPS_USERS"("USER_ID"); +CREATE INDEX "INDEX_GROUPS_USERS_ON_GROUP_UUID" ON "GROUPS_USERS"("GROUP_UUID"); +CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS"("GROUP_UUID", "USER_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddIndexOnUserUuidOfOrganizationMembersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddIndexOnUserUuidOfOrganizationMembersTableTest/schema.sql new file mode 100644 index 00000000000..20cd2336941 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddIndexOnUserUuidOfOrganizationMembersTableTest/schema.sql @@ -0,0 +1,7 @@ +CREATE TABLE "ORGANIZATION_MEMBERS"( + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "USER_ID" INTEGER NOT NULL, + "USER_UUID" VARCHAR(40) NOT NULL, +); +ALTER TABLE "ORGANIZATION_MEMBERS" ADD CONSTRAINT "PK_ORGANIZATION_MEMBERS" PRIMARY KEY("ORGANIZATION_UUID", "USER_ID"); + diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTableTest/schema.sql new file mode 100644 index 00000000000..3fa77611bd6 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTableTest/schema.sql @@ -0,0 +1,7 @@ +CREATE TABLE "ORGANIZATION_MEMBERS"( + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "USER_ID" INTEGER NOT NULL, + "USER_UUID" VARCHAR(40) NOT NULL, +); +CREATE INDEX "ORG_MEMBERS_ON_USER_ID" ON "ORGANIZATION_MEMBERS"("USER_UUID"); + diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddUserUuidColumnToOrganizationMembersTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddUserUuidColumnToOrganizationMembersTest/schema.sql new file mode 100644 index 00000000000..1a0f1aa45a5 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddUserUuidColumnToOrganizationMembersTest/schema.sql @@ -0,0 +1,7 @@ +CREATE TABLE "ORGANIZATION_MEMBERS"( + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "USER_ID" INTEGER NOT NULL +); +ALTER TABLE "ORGANIZATION_MEMBERS" ADD CONSTRAINT "PK_ORGANIZATION_MEMBERS" PRIMARY KEY("ORGANIZATION_UUID", "USER_ID"); +CREATE INDEX "IX_ORG_MEMBERS_ON_USER_ID" ON "ORGANIZATION_MEMBERS"("USER_ID"); + diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropIndexOnUserIdOfOrganizationMembersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropIndexOnUserIdOfOrganizationMembersTableTest/schema.sql new file mode 100644 index 00000000000..83a23943158 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropIndexOnUserIdOfOrganizationMembersTableTest/schema.sql @@ -0,0 +1,8 @@ +CREATE TABLE "ORGANIZATION_MEMBERS"( + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "USER_ID" INTEGER NOT NULL, + "USER_UUID" VARCHAR(40) NOT NULL, +); +ALTER TABLE "ORGANIZATION_MEMBERS" ADD CONSTRAINT "PK_ORGANIZATION_MEMBERS" PRIMARY KEY("ORGANIZATION_UUID", "USER_ID"); +CREATE INDEX "IX_ORG_MEMBERS_ON_USER_ID" ON "ORGANIZATION_MEMBERS"("USER_ID"); + diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTableTest/schema.sql new file mode 100644 index 00000000000..e72612d2481 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTableTest/schema.sql @@ -0,0 +1,8 @@ +CREATE TABLE "ORGANIZATION_MEMBERS"( + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "USER_ID" INTEGER NOT NULL, + "USER_UUID" VARCHAR(40) NOT NULL, +); +ALTER TABLE "ORGANIZATION_MEMBERS" ADD CONSTRAINT "PK_ORGANIZATION_MEMBERS" PRIMARY KEY("ORGANIZATION_UUID", "USER_ID"); +CREATE INDEX "ORG_MEMBERS_ON_USER_UUID" ON "ORGANIZATION_MEMBERS"("USER_UUID"); + diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropUserIdColumnOfOrganizationMembersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropUserIdColumnOfOrganizationMembersTableTest/schema.sql new file mode 100644 index 00000000000..6f3084dc7ba --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropUserIdColumnOfOrganizationMembersTableTest/schema.sql @@ -0,0 +1,7 @@ +CREATE TABLE "ORGANIZATION_MEMBERS"( + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "USER_ID" INTEGER NOT NULL, + "USER_UUID" VARCHAR(40) NOT NULL, +); +CREATE INDEX "ORG_MEMBERS_ON_USER_ID" ON "ORGANIZATION_MEMBERS"("USER_UUID"); +ALTER TABLE "ORGANIZATION_MEMBERS" ADD CONSTRAINT "PK_ORGANIZATION_MEMBERS" PRIMARY KEY("ORGANIZATION_UUID", "USER_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/MakeOrganizationMembersUserUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/MakeOrganizationMembersUserUuidColumnNotNullableTest/schema.sql new file mode 100644 index 00000000000..5951c00d434 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/MakeOrganizationMembersUserUuidColumnNotNullableTest/schema.sql @@ -0,0 +1,8 @@ +CREATE TABLE "ORGANIZATION_MEMBERS"( + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "USER_ID" INTEGER NOT NULL, + "USER_UUID" VARCHAR(40), +); +ALTER TABLE "ORGANIZATION_MEMBERS" ADD CONSTRAINT "PK_ORGANIZATION_MEMBERS" PRIMARY KEY("ORGANIZATION_UUID", "USER_ID"); +CREATE INDEX "IX_ORG_MEMBERS_ON_USER_ID" ON "ORGANIZATION_MEMBERS"("USER_ID"); + diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/PopulateOrganizationMembersUserUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/PopulateOrganizationMembersUserUuidTest/schema.sql new file mode 100644 index 00000000000..3dbd7d9a215 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/PopulateOrganizationMembersUserUuidTest/schema.sql @@ -0,0 +1,40 @@ +CREATE TABLE "USERS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(255) NOT NULL, + "LOGIN" VARCHAR(255) NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40), + "NAME" VARCHAR(200), + "EMAIL" VARCHAR(100), + "CRYPTED_PASSWORD" VARCHAR(100), + "SALT" VARCHAR(40), + "HASH_METHOD" VARCHAR(10), + "ACTIVE" BOOLEAN DEFAULT TRUE, + "SCM_ACCOUNTS" VARCHAR(4000), + "EXTERNAL_LOGIN" VARCHAR(255) NOT NULL, + "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100) NOT NULL, + "EXTERNAL_ID" VARCHAR(255) NOT NULL, + "IS_ROOT" BOOLEAN NOT NULL, + "USER_LOCAL" BOOLEAN, + "ONBOARDED" BOOLEAN NOT NULL, + "HOMEPAGE_TYPE" VARCHAR(40), + "HOMEPAGE_PARAMETER" VARCHAR(40), + "LAST_CONNECTION_DATE" BIGINT, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT +); +ALTER TABLE "USERS" ADD CONSTRAINT "PK_USERS" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS"("LOGIN"); +CREATE INDEX "USERS_UPDATED_AT" ON "USERS"("UPDATED_AT"); +CREATE UNIQUE INDEX "USERS_UUID" ON "USERS"("UUID"); +CREATE UNIQUE INDEX "UNIQ_EXTERNAL_ID" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_ID"); +CREATE UNIQUE INDEX "UNIQ_EXTERNAL_LOGIN" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_LOGIN"); + + +CREATE TABLE "ORGANIZATION_MEMBERS"( + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "USER_ID" INTEGER NOT NULL, + "USER_UUID" VARCHAR(40), +); +ALTER TABLE "ORGANIZATION_MEMBERS" ADD CONSTRAINT "PK_ORGANIZATION_MEMBERS" PRIMARY KEY("ORGANIZATION_UUID", "USER_ID"); +CREATE INDEX "IX_ORG_MEMBERS_ON_USER_ID" ON "ORGANIZATION_MEMBERS"("USER_ID"); + diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/AddUserUuidColumnToPermTemplatesUsersTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/AddUserUuidColumnToPermTemplatesUsersTest/schema.sql new file mode 100644 index 00000000000..10b095f9b4a --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/AddUserUuidColumnToPermTemplatesUsersTest/schema.sql @@ -0,0 +1,9 @@ +CREATE TABLE "PERM_TEMPLATES_USERS"( + "USER_ID" INTEGER NOT NULL, + "TEMPLATE_ID" INTEGER NOT NULL, + "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP, + "UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "PERM_TEMPLATES_USERS" ADD CONSTRAINT "PK_PERM_TEMPLATES_USERS" PRIMARY KEY("UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/DropUserIdColumnOfPermTemplatesUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/DropUserIdColumnOfPermTemplatesUsersTableTest/schema.sql new file mode 100644 index 00000000000..fc2cdb8b524 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/DropUserIdColumnOfPermTemplatesUsersTableTest/schema.sql @@ -0,0 +1,11 @@ +CREATE TABLE "PERM_TEMPLATES_USERS"( + "USER_ID" INTEGER NOT NULL, + "TEMPLATE_ID" INTEGER NOT NULL, + "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP, + "UUID" VARCHAR(40) NOT NULL, + "USER_UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "PERM_TEMPLATES_USERS" ADD CONSTRAINT "PK_PERM_TEMPLATES_USERS" PRIMARY KEY("UUID"); + diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/MakePermTemplatesUsersUserUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/MakePermTemplatesUsersUserUuidColumnNotNullableTest/schema.sql new file mode 100644 index 00000000000..752db98d466 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/MakePermTemplatesUsersUserUuidColumnNotNullableTest/schema.sql @@ -0,0 +1,11 @@ +CREATE TABLE "PERM_TEMPLATES_USERS"( + "USER_ID" INTEGER NOT NULL, + "TEMPLATE_ID" INTEGER NOT NULL, + "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP, + "UUID" VARCHAR(40) NOT NULL, + "USER_UUID" VARCHAR(40) +); +ALTER TABLE "PERM_TEMPLATES_USERS" ADD CONSTRAINT "PK_PERM_TEMPLATES_USERS" PRIMARY KEY("UUID"); + diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/PopulatePermTemplatesUsersUserUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/PopulatePermTemplatesUsersUserUuidTest/schema.sql new file mode 100644 index 00000000000..cd73faec4b4 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/permtemplatesusers/PopulatePermTemplatesUsersUserUuidTest/schema.sql @@ -0,0 +1,42 @@ +CREATE TABLE "USERS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(255) NOT NULL, + "LOGIN" VARCHAR(255) NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40), + "NAME" VARCHAR(200), + "EMAIL" VARCHAR(100), + "CRYPTED_PASSWORD" VARCHAR(100), + "SALT" VARCHAR(40), + "HASH_METHOD" VARCHAR(10), + "ACTIVE" BOOLEAN DEFAULT TRUE, + "SCM_ACCOUNTS" VARCHAR(4000), + "EXTERNAL_LOGIN" VARCHAR(255) NOT NULL, + "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100) NOT NULL, + "EXTERNAL_ID" VARCHAR(255) NOT NULL, + "IS_ROOT" BOOLEAN NOT NULL, + "USER_LOCAL" BOOLEAN, + "ONBOARDED" BOOLEAN NOT NULL, + "HOMEPAGE_TYPE" VARCHAR(40), + "HOMEPAGE_PARAMETER" VARCHAR(40), + "LAST_CONNECTION_DATE" BIGINT, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT +); +ALTER TABLE "USERS" ADD CONSTRAINT "PK_USERS" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS"("LOGIN"); +CREATE INDEX "USERS_UPDATED_AT" ON "USERS"("UPDATED_AT"); +CREATE UNIQUE INDEX "USERS_UUID" ON "USERS"("UUID"); +CREATE UNIQUE INDEX "UNIQ_EXTERNAL_ID" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_ID"); +CREATE UNIQUE INDEX "UNIQ_EXTERNAL_LOGIN" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_LOGIN"); + +CREATE TABLE "PERM_TEMPLATES_USERS"( + "USER_ID" INTEGER NOT NULL, + "TEMPLATE_ID" INTEGER NOT NULL, + "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP, + "UUID" VARCHAR(40) NOT NULL, + "USER_UUID" VARCHAR(40) +); +ALTER TABLE "PERM_TEMPLATES_USERS" ADD CONSTRAINT "PK_PERM_TEMPLATES_USERS" PRIMARY KEY("UUID"); + diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/AddUserUuidColumnToPropertiesUsersTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/AddUserUuidColumnToPropertiesUsersTest/schema.sql new file mode 100644 index 00000000000..e63f2fb66c8 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/AddUserUuidColumnToPropertiesUsersTest/schema.sql @@ -0,0 +1,11 @@ +CREATE TABLE "PROPERTIES"( + "UUID" VARCHAR(40) NOT NULL, + "PROP_KEY" VARCHAR(512) NOT NULL, + "IS_EMPTY" BOOLEAN NOT NULL, + "TEXT_VALUE" VARCHAR(4000), + "CLOB_VALUE" CLOB(2147483647), + "CREATED_AT" BIGINT NOT NULL, + "COMPONENT_UUID" VARCHAR(40) +); +ALTER TABLE "PROPERTIES" ADD CONSTRAINT "PK_PROPERTIES" PRIMARY KEY("UUID"); +CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES"("PROP_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/DropUserIdColumnOfPropertiesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/DropUserIdColumnOfPropertiesTableTest/schema.sql new file mode 100644 index 00000000000..a3d1fbfeeea --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/DropUserIdColumnOfPropertiesTableTest/schema.sql @@ -0,0 +1,15 @@ +CREATE TABLE "PROPERTIES"( + "UUID" VARCHAR(40) NOT NULL, + "PROP_KEY" VARCHAR(512) NOT NULL, + "USER_ID" INTEGER, + "IS_EMPTY" BOOLEAN NOT NULL, + "TEXT_VALUE" VARCHAR(4000), + "CLOB_VALUE" CLOB(2147483647), + "CREATED_AT" BIGINT NOT NULL, + "COMPONENT_UUID" VARCHAR(40), + "USER_UUID" VARCHAR(40) +); +ALTER TABLE "PROPERTIES" ADD CONSTRAINT "PK_PROPERTIES" PRIMARY KEY("UUID"); +CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES"("PROP_KEY"); + + diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/PopulatePropertiesUserUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/PopulatePropertiesUserUuidTest/schema.sql new file mode 100644 index 00000000000..7b392af768c --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/properties/PopulatePropertiesUserUuidTest/schema.sql @@ -0,0 +1,44 @@ +CREATE TABLE "USERS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(255) NOT NULL, + "LOGIN" VARCHAR(255) NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40), + "NAME" VARCHAR(200), + "EMAIL" VARCHAR(100), + "CRYPTED_PASSWORD" VARCHAR(100), + "SALT" VARCHAR(40), + "HASH_METHOD" VARCHAR(10), + "ACTIVE" BOOLEAN DEFAULT TRUE, + "SCM_ACCOUNTS" VARCHAR(4000), + "EXTERNAL_LOGIN" VARCHAR(255) NOT NULL, + "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100) NOT NULL, + "EXTERNAL_ID" VARCHAR(255) NOT NULL, + "IS_ROOT" BOOLEAN NOT NULL, + "USER_LOCAL" BOOLEAN, + "ONBOARDED" BOOLEAN NOT NULL, + "HOMEPAGE_TYPE" VARCHAR(40), + "HOMEPAGE_PARAMETER" VARCHAR(40), + "LAST_CONNECTION_DATE" BIGINT, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT +); +ALTER TABLE "USERS" ADD CONSTRAINT "PK_USERS" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS"("LOGIN"); +CREATE INDEX "USERS_UPDATED_AT" ON "USERS"("UPDATED_AT"); +CREATE UNIQUE INDEX "USERS_UUID" ON "USERS"("UUID"); +CREATE UNIQUE INDEX "UNIQ_EXTERNAL_ID" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_ID"); +CREATE UNIQUE INDEX "UNIQ_EXTERNAL_LOGIN" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_LOGIN"); + +CREATE TABLE "PROPERTIES"( + "UUID" VARCHAR(40) NOT NULL, + "PROP_KEY" VARCHAR(512) NOT NULL, + "USER_ID" INTEGER, + "IS_EMPTY" BOOLEAN NOT NULL, + "TEXT_VALUE" VARCHAR(4000), + "CLOB_VALUE" CLOB(2147483647), + "CREATED_AT" BIGINT NOT NULL, + "COMPONENT_UUID" VARCHAR(40), + "USER_UUID" VARCHAR(40) +); +ALTER TABLE "PROPERTIES" ADD CONSTRAINT "PK_PROPERTIES" PRIMARY KEY("UUID"); +CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES"("PROP_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTableTest/schema.sql new file mode 100644 index 00000000000..6111eb1f8e1 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/AddUniqueIndexOnUserUuidAndQProfileUuidOfQProfileEditUsersTableTest/schema.sql @@ -0,0 +1,9 @@ +CREATE TABLE "QPROFILE_EDIT_USERS"( + "UUID" VARCHAR(40) NOT NULL, + "USER_ID" INTEGER NOT NULL, + "QPROFILE_UUID" VARCHAR(255) NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "USER_UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "QPROFILE_EDIT_USERS" ADD CONSTRAINT "PK_QPROFILE_EDIT_USERS" PRIMARY KEY("UUID"); +CREATE INDEX "QPROFILE_EDIT_USERS_QPROFILE" ON "QPROFILE_EDIT_USERS"("QPROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/AddUserUuidColumnToQProfileEditUsersTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/AddUserUuidColumnToQProfileEditUsersTest/schema.sql new file mode 100644 index 00000000000..1149cf96ee7 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/AddUserUuidColumnToQProfileEditUsersTest/schema.sql @@ -0,0 +1,9 @@ +CREATE TABLE "QPROFILE_EDIT_USERS"( + "UUID" VARCHAR(40) NOT NULL, + "USER_ID" INTEGER NOT NULL, + "QPROFILE_UUID" VARCHAR(255) NOT NULL, + "CREATED_AT" BIGINT NOT NULL +); +ALTER TABLE "QPROFILE_EDIT_USERS" ADD CONSTRAINT "PK_QPROFILE_EDIT_USERS" PRIMARY KEY("UUID"); +CREATE INDEX "QPROFILE_EDIT_USERS_QPROFILE" ON "QPROFILE_EDIT_USERS"("QPROFILE_UUID"); +CREATE UNIQUE INDEX "QPROFILE_EDIT_USERS_UNIQUE" ON "QPROFILE_EDIT_USERS"("USER_ID", "QPROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTableTest/schema.sql new file mode 100644 index 00000000000..94fa29f1c1a --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/DropUniqueIndexOnUserIdAndQProfileUuidOfQProfileEditUsersTableTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "QPROFILE_EDIT_USERS"( + "UUID" VARCHAR(40) NOT NULL, + "USER_ID" INTEGER NOT NULL, + "QPROFILE_UUID" VARCHAR(255) NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "USER_UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "QPROFILE_EDIT_USERS" ADD CONSTRAINT "PK_QPROFILE_EDIT_USERS" PRIMARY KEY("UUID"); +CREATE INDEX "QPROFILE_EDIT_USERS_QPROFILE" ON "QPROFILE_EDIT_USERS"("QPROFILE_UUID"); +CREATE UNIQUE INDEX "QPROFILE_EDIT_USERS_UNIQUE" ON "QPROFILE_EDIT_USERS"("USER_ID", "QPROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/DropUserIdColumnOfQProfileEditUsersTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/DropUserIdColumnOfQProfileEditUsersTableTest/schema.sql new file mode 100644 index 00000000000..e1a14b02b7b --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/DropUserIdColumnOfQProfileEditUsersTableTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "QPROFILE_EDIT_USERS"( + "UUID" VARCHAR(40) NOT NULL, + "USER_ID" INTEGER NOT NULL, + "QPROFILE_UUID" VARCHAR(255) NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "USER_UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "QPROFILE_EDIT_USERS" ADD CONSTRAINT "PK_QPROFILE_EDIT_USERS" PRIMARY KEY("UUID"); +CREATE INDEX "QPROFILE_EDIT_USERS_QPROFILE" ON "QPROFILE_EDIT_USERS"("QPROFILE_UUID"); +CREATE UNIQUE INDEX "QPROFILE_EDIT_USERS_UNIQUE" ON "QPROFILE_EDIT_USERS"("USER_UUID", "QPROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/MakeQProfileEditUsersUserUuidColumnNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/MakeQProfileEditUsersUserUuidColumnNotNullableTest/schema.sql new file mode 100644 index 00000000000..d1a00b9e64b --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/MakeQProfileEditUsersUserUuidColumnNotNullableTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "QPROFILE_EDIT_USERS"( + "UUID" VARCHAR(40) NOT NULL, + "USER_ID" INTEGER NOT NULL, + "QPROFILE_UUID" VARCHAR(255) NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "USER_UUID" VARCHAR(40) +); +ALTER TABLE "QPROFILE_EDIT_USERS" ADD CONSTRAINT "PK_QPROFILE_EDIT_USERS" PRIMARY KEY("UUID"); +CREATE INDEX "QPROFILE_EDIT_USERS_QPROFILE" ON "QPROFILE_EDIT_USERS"("QPROFILE_UUID"); +CREATE UNIQUE INDEX "QPROFILE_EDIT_USERS_UNIQUE" ON "QPROFILE_EDIT_USERS"("USER_ID", "QPROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/PopulateQProfileEditUsersUserUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/PopulateQProfileEditUsersUserUuidTest/schema.sql new file mode 100644 index 00000000000..d10b8b5184c --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/qprofileeditusers/PopulateQProfileEditUsersUserUuidTest/schema.sql @@ -0,0 +1,41 @@ +CREATE TABLE "USERS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(255) NOT NULL, + "LOGIN" VARCHAR(255) NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40), + "NAME" VARCHAR(200), + "EMAIL" VARCHAR(100), + "CRYPTED_PASSWORD" VARCHAR(100), + "SALT" VARCHAR(40), + "HASH_METHOD" VARCHAR(10), + "ACTIVE" BOOLEAN DEFAULT TRUE, + "SCM_ACCOUNTS" VARCHAR(4000), + "EXTERNAL_LOGIN" VARCHAR(255) NOT NULL, + "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100) NOT NULL, + "EXTERNAL_ID" VARCHAR(255) NOT NULL, + "IS_ROOT" BOOLEAN NOT NULL, + "USER_LOCAL" BOOLEAN, + "ONBOARDED" BOOLEAN NOT NULL, + "HOMEPAGE_TYPE" VARCHAR(40), + "HOMEPAGE_PARAMETER" VARCHAR(40), + "LAST_CONNECTION_DATE" BIGINT, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT +); +ALTER TABLE "USERS" ADD CONSTRAINT "PK_USERS" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS"("LOGIN"); +CREATE INDEX "USERS_UPDATED_AT" ON "USERS"("UPDATED_AT"); +CREATE UNIQUE INDEX "USERS_UUID" ON "USERS"("UUID"); +CREATE UNIQUE INDEX "UNIQ_EXTERNAL_ID" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_ID"); +CREATE UNIQUE INDEX "UNIQ_EXTERNAL_LOGIN" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_LOGIN"); + +CREATE TABLE "QPROFILE_EDIT_USERS"( + "UUID" VARCHAR(40) NOT NULL, + "USER_ID" INTEGER NOT NULL, + "QPROFILE_UUID" VARCHAR(255) NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "USER_UUID" VARCHAR(40) +); +ALTER TABLE "QPROFILE_EDIT_USERS" ADD CONSTRAINT "PK_QPROFILE_EDIT_USERS" PRIMARY KEY("UUID"); +CREATE INDEX "QPROFILE_EDIT_USERS_QPROFILE" ON "QPROFILE_EDIT_USERS"("QPROFILE_UUID"); +CREATE UNIQUE INDEX "QPROFILE_EDIT_USERS_UNIQUE" ON "QPROFILE_EDIT_USERS"("USER_ID", "QPROFILE_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/AddIndexOnUserUuidOfUserRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/AddIndexOnUserUuidOfUserRolesTableTest/schema.sql new file mode 100644 index 00000000000..fee4bf2e2c9 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/AddIndexOnUserUuidOfUserRolesTableTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "USER_ROLES"( + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "USER_ID" INTEGER, + "ROLE" VARCHAR(64) NOT NULL, + "COMPONENT_UUID" VARCHAR(40), + "UUID" VARCHAR(40) NOT NULL, + "USER_UUID" VARCHAR(40) +); +ALTER TABLE "USER_ROLES" ADD CONSTRAINT "PK_USER_ROLES" PRIMARY KEY("UUID"); +CREATE INDEX "USER_ROLES_COMPONENT_UUID" ON "USER_ROLES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/AddUserUuidColumnToUserRolesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/AddUserUuidColumnToUserRolesTest/schema.sql new file mode 100644 index 00000000000..b1619df129c --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/AddUserUuidColumnToUserRolesTest/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE "USER_ROLES"( + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "USER_ID" INTEGER, + "ROLE" VARCHAR(64) NOT NULL, + "COMPONENT_UUID" VARCHAR(40), + "UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "USER_ROLES" ADD CONSTRAINT "PK_USER_ROLES" PRIMARY KEY("UUID"); +CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES"("USER_ID"); +CREATE INDEX "USER_ROLES_COMPONENT_UUID" ON "USER_ROLES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/DropIndexOnUserIdOfUserRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/DropIndexOnUserIdOfUserRolesTableTest/schema.sql new file mode 100644 index 00000000000..6080af78618 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/DropIndexOnUserIdOfUserRolesTableTest/schema.sql @@ -0,0 +1,11 @@ +CREATE TABLE "USER_ROLES"( + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "USER_ID" INTEGER, + "ROLE" VARCHAR(64) NOT NULL, + "COMPONENT_UUID" VARCHAR(40), + "UUID" VARCHAR(40) NOT NULL, + "USER_UUID" VARCHAR(40) +); +ALTER TABLE "USER_ROLES" ADD CONSTRAINT "PK_USER_ROLES" PRIMARY KEY("UUID"); +CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES"("USER_ID"); +CREATE INDEX "USER_ROLES_COMPONENT_UUID" ON "USER_ROLES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/DropUserIdColumnOfUserRolesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/DropUserIdColumnOfUserRolesTableTest/schema.sql new file mode 100644 index 00000000000..6080af78618 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/DropUserIdColumnOfUserRolesTableTest/schema.sql @@ -0,0 +1,11 @@ +CREATE TABLE "USER_ROLES"( + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "USER_ID" INTEGER, + "ROLE" VARCHAR(64) NOT NULL, + "COMPONENT_UUID" VARCHAR(40), + "UUID" VARCHAR(40) NOT NULL, + "USER_UUID" VARCHAR(40) +); +ALTER TABLE "USER_ROLES" ADD CONSTRAINT "PK_USER_ROLES" PRIMARY KEY("UUID"); +CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES"("USER_ID"); +CREATE INDEX "USER_ROLES_COMPONENT_UUID" ON "USER_ROLES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/PopulateUserRolesUserUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/PopulateUserRolesUserUuidTest/schema.sql new file mode 100644 index 00000000000..a1ad51f0b38 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/users/fk/userroles/PopulateUserRolesUserUuidTest/schema.sql @@ -0,0 +1,42 @@ +CREATE TABLE "USERS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(255) NOT NULL, + "LOGIN" VARCHAR(255) NOT NULL, + "ORGANIZATION_UUID" VARCHAR(40), + "NAME" VARCHAR(200), + "EMAIL" VARCHAR(100), + "CRYPTED_PASSWORD" VARCHAR(100), + "SALT" VARCHAR(40), + "HASH_METHOD" VARCHAR(10), + "ACTIVE" BOOLEAN DEFAULT TRUE, + "SCM_ACCOUNTS" VARCHAR(4000), + "EXTERNAL_LOGIN" VARCHAR(255) NOT NULL, + "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100) NOT NULL, + "EXTERNAL_ID" VARCHAR(255) NOT NULL, + "IS_ROOT" BOOLEAN NOT NULL, + "USER_LOCAL" BOOLEAN, + "ONBOARDED" BOOLEAN NOT NULL, + "HOMEPAGE_TYPE" VARCHAR(40), + "HOMEPAGE_PARAMETER" VARCHAR(40), + "LAST_CONNECTION_DATE" BIGINT, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT +); +ALTER TABLE "USERS" ADD CONSTRAINT "PK_USERS" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS"("LOGIN"); +CREATE INDEX "USERS_UPDATED_AT" ON "USERS"("UPDATED_AT"); +CREATE UNIQUE INDEX "USERS_UUID" ON "USERS"("UUID"); +CREATE UNIQUE INDEX "UNIQ_EXTERNAL_ID" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_ID"); +CREATE UNIQUE INDEX "UNIQ_EXTERNAL_LOGIN" ON "USERS"("EXTERNAL_IDENTITY_PROVIDER", "EXTERNAL_LOGIN"); + +CREATE TABLE "USER_ROLES"( + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "USER_ID" INTEGER, + "ROLE" VARCHAR(64) NOT NULL, + "COMPONENT_UUID" VARCHAR(40), + "UUID" VARCHAR(40) NOT NULL, + "USER_UUID" VARCHAR(40) +); +ALTER TABLE "USER_ROLES" ADD CONSTRAINT "PK_USER_ROLES" PRIMARY KEY("UUID"); +CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES"("USER_ID"); +CREATE INDEX "USER_ROLES_COMPONENT_UUID" ON "USER_ROLES"("COMPONENT_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/usertokens/AddPrimaryKeyOnUuidColumnOfUserTokensTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/usertokens/AddPrimaryKeyOnUuidColumnOfUserTokensTableTest/schema.sql new file mode 100644 index 00000000000..ca5001f995a --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/usertokens/AddPrimaryKeyOnUuidColumnOfUserTokensTableTest/schema.sql @@ -0,0 +1,11 @@ +CREATE TABLE "USER_TOKENS"( + "ID" INTEGER NOT NULL, + "UUID" VARCHAR(40) NOT NULL, + "USER_UUID" VARCHAR(255) NOT NULL, + "NAME" VARCHAR(100) NOT NULL, + "TOKEN_HASH" VARCHAR(255) NOT NULL, + "LAST_CONNECTION_DATE" BIGINT, + "CREATED_AT" BIGINT NOT NULL +); +CREATE UNIQUE INDEX "USER_TOKENS_USER_UUID_NAME" ON "USER_TOKENS"("USER_UUID", "NAME"); +CREATE UNIQUE INDEX "USER_TOKENS_TOKEN_HASH" ON "USER_TOKENS"("TOKEN_HASH"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/usertokens/AddUuidColumnToUserTokensTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/usertokens/AddUuidColumnToUserTokensTest/schema.sql new file mode 100644 index 00000000000..485c3d4f80c --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/usertokens/AddUuidColumnToUserTokensTest/schema.sql @@ -0,0 +1,11 @@ +CREATE TABLE "USER_TOKENS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "USER_UUID" VARCHAR(255) NOT NULL, + "NAME" VARCHAR(100) NOT NULL, + "TOKEN_HASH" VARCHAR(255) NOT NULL, + "LAST_CONNECTION_DATE" BIGINT, + "CREATED_AT" BIGINT NOT NULL +); +ALTER TABLE "USER_TOKENS" ADD CONSTRAINT "PK_USER_TOKENS" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "USER_TOKENS_USER_UUID_NAME" ON "USER_TOKENS"("USER_UUID", "NAME"); +CREATE UNIQUE INDEX "USER_TOKENS_TOKEN_HASH" ON "USER_TOKENS"("TOKEN_HASH"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/usertokens/DropIdColumnOfUserTokensTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/usertokens/DropIdColumnOfUserTokensTableTest/schema.sql new file mode 100644 index 00000000000..894ee4b0fc4 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/usertokens/DropIdColumnOfUserTokensTableTest/schema.sql @@ -0,0 +1,12 @@ +CREATE TABLE "USER_TOKENS"( + "ID" INTEGER NOT NULL, + "UUID" VARCHAR(40) NOT NULL, + "USER_UUID" VARCHAR(255) NOT NULL, + "NAME" VARCHAR(100) NOT NULL, + "TOKEN_HASH" VARCHAR(255) NOT NULL, + "LAST_CONNECTION_DATE" BIGINT, + "CREATED_AT" BIGINT NOT NULL +); +ALTER TABLE "USER_TOKENS" ADD CONSTRAINT "PK_USER_TOKENS" PRIMARY KEY("UUID"); +CREATE UNIQUE INDEX "USER_TOKENS_USER_UUID_NAME" ON "USER_TOKENS"("USER_UUID", "NAME"); +CREATE UNIQUE INDEX "USER_TOKENS_TOKEN_HASH" ON "USER_TOKENS"("TOKEN_HASH"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/usertokens/DropPrimaryKeyOnIdColumnOfUserTokensTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/usertokens/DropPrimaryKeyOnIdColumnOfUserTokensTableTest/schema.sql new file mode 100644 index 00000000000..485c3d4f80c --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/usertokens/DropPrimaryKeyOnIdColumnOfUserTokensTableTest/schema.sql @@ -0,0 +1,11 @@ +CREATE TABLE "USER_TOKENS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "USER_UUID" VARCHAR(255) NOT NULL, + "NAME" VARCHAR(100) NOT NULL, + "TOKEN_HASH" VARCHAR(255) NOT NULL, + "LAST_CONNECTION_DATE" BIGINT, + "CREATED_AT" BIGINT NOT NULL +); +ALTER TABLE "USER_TOKENS" ADD CONSTRAINT "PK_USER_TOKENS" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "USER_TOKENS_USER_UUID_NAME" ON "USER_TOKENS"("USER_UUID", "NAME"); +CREATE UNIQUE INDEX "USER_TOKENS_TOKEN_HASH" ON "USER_TOKENS"("TOKEN_HASH"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/usertokens/MakeUserTokensUuidNotNullableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/usertokens/MakeUserTokensUuidNotNullableTest/schema.sql new file mode 100644 index 00000000000..df2072a73cb --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/usertokens/MakeUserTokensUuidNotNullableTest/schema.sql @@ -0,0 +1,12 @@ +CREATE TABLE "USER_TOKENS"( + "ID" INTEGER NOT NULL, + "UUID" VARCHAR(40), + "USER_UUID" VARCHAR(255) NOT NULL, + "NAME" VARCHAR(100) NOT NULL, + "TOKEN_HASH" VARCHAR(255) NOT NULL, + "LAST_CONNECTION_DATE" BIGINT, + "CREATED_AT" BIGINT NOT NULL +); +ALTER TABLE "USER_TOKENS" ADD CONSTRAINT "PK_USER_TOKENS" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "USER_TOKENS_USER_UUID_NAME" ON "USER_TOKENS"("USER_UUID", "NAME"); +CREATE UNIQUE INDEX "USER_TOKENS_TOKEN_HASH" ON "USER_TOKENS"("TOKEN_HASH"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/usertokens/PopulateUserTokensUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/usertokens/PopulateUserTokensUuidTest/schema.sql new file mode 100644 index 00000000000..b4869dc5a9c --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v84/usertokens/PopulateUserTokensUuidTest/schema.sql @@ -0,0 +1,12 @@ +CREATE TABLE "USER_TOKENS"( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "UUID" VARCHAR(40), + "USER_UUID" VARCHAR(255) NOT NULL, + "NAME" VARCHAR(100) NOT NULL, + "TOKEN_HASH" VARCHAR(255) NOT NULL, + "LAST_CONNECTION_DATE" BIGINT, + "CREATED_AT" BIGINT NOT NULL +); +ALTER TABLE "USER_TOKENS" ADD CONSTRAINT "PK_USER_TOKENS" PRIMARY KEY("ID"); +CREATE UNIQUE INDEX "USER_TOKENS_USER_UUID_NAME" ON "USER_TOKENS"("USER_UUID", "NAME"); +CREATE UNIQUE INDEX "USER_TOKENS_TOKEN_HASH" ON "USER_TOKENS"("TOKEN_HASH"); -- cgit v1.2.3